[valadoc] Bug #400882



commit 8acbb54a9ab2f7997b615beb58b66e365bb5a4b6
Author: Florian Brosch <flo brosch gmail com>
Date:   Sat Jul 18 22:15:26 2009 +0200

    Bug #400882

 config.guess                                 | 1526 ---
 config.h.in                                  |   59 -
 config.sub                                   | 1658 ---
 configure                                    |14408 --------------------------
 depcomp                                      |  589 --
 install-sh                                   |  519 -
 ltmain.sh                                    | 8412 ---------------
 missing                                      |  367 -
 src/doclets/valadoc.org/doclet/Makefile.in   |  526 -
 src/doclets/valadoc.org/doclet/template.vala |   36 +-
 src/libvaladoc/apitree.vala                  |  260 +-
 src/libvaladoc/settings.vala                 |   14 +
 src/valadoc/valadoc.vala                     |   83 +-
 13 files changed, 225 insertions(+), 28232 deletions(-)
---
diff --git a/src/doclets/valadoc.org/doclet/template.vala b/src/doclets/valadoc.org/doclet/template.vala
index f472962..3669dfa 100644
--- a/src/doclets/valadoc.org/doclet/template.vala
+++ b/src/doclets/valadoc.org/doclet/template.vala
@@ -49,7 +49,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 	// get_type_path()
 	private void write_insert_into_valadoc_element_str (string name, string pkgname, string fullname) {
 		string fullname2 = (pkgname == fullname)? pkgname : pkgname+"/"+fullname;
-		this.file.printf ("INSERT INTO `ValadocElement` (`name`, `fullname`) VALUES ('%s', '%s');\n", name, fullname2);
+		this.file.printf ("INSERT INTO `ValadocApiElement` (`name`, `fullname`) VALUES ('%s', '%s');\n", name, fullname2);
 	}
 
 	// get_type_path()
@@ -69,14 +69,14 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 	}
 
 	private void write_insert_into_valadoc_package (Package pkg) {
-		this.file.printf ("INSERT INTO `ValadocPackage` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE `fullname`='%s' LIMIT 1));\n", pkg.name);
+		this.file.printf ("INSERT INTO `ValadocPackage` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE `fullname`='%s' LIMIT 1));\n", pkg.name);
 	}
 
 	// get_type_path()
 	private void write_insert_into_code_element_str (string fullname, string pkgname, string valaapi, string parentnodepkgname, string parentnodefullname) {
 		string parentnodetypepath = (parentnodepkgname == parentnodefullname)? parentnodepkgname : parentnodepkgname+"/"+parentnodefullname;
 		string typepath = pkgname+"/"+fullname;
-		this.file.printf ("INSERT INTO `ValadocCodeElement` (`id`, `parent`, `valaapi`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1), (SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", typepath, parentnodetypepath, valaapi);
+		this.file.printf ("INSERT INTO `ValadocCodeElement` (`id`, `parent`, `valaapi`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1), (SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", typepath, parentnodetypepath, valaapi);
 	}
 
 	// get_type_path()
@@ -230,7 +230,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			}			
 		}
 
-		this.file.printf ("INSERT INTO `ValadocNamespaces` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(ns));
+		this.file.printf ("INSERT INTO `ValadocNamespaces` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(ns));
 	}
 
 	public override void visit_interface ( Interface iface ) {
@@ -308,7 +308,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			}			
 		}
 
-		this.file.printf ("INSERT INTO `ValadocInterfaces` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(iface));
+		this.file.printf ("INSERT INTO `ValadocInterfaces` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(iface));
 	}
 
 	public override void visit_class ( Class cl ) {
@@ -402,7 +402,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			modifier = "NORMAL";
 		}
 	
-		this.file.printf ("INSERT INTO `ValadocClasses` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1),'%s');\n", this.get_type_path(cl), modifier);
+		this.file.printf ("INSERT INTO `ValadocClasses` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1),'%s');\n", this.get_type_path(cl), modifier);
 	}
 
 	public override void visit_struct ( Struct stru ) {
@@ -440,7 +440,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			}			
 		}
 
-		this.file.printf ("INSERT INTO `ValadocStructs` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(stru));
+		this.file.printf ("INSERT INTO `ValadocStructs` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(stru));
 	}
 
 	public override void visit_error_domain ( ErrorDomain errdom ) {
@@ -470,7 +470,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			}			
 		}
 
-		this.file.printf ("INSERT INTO `ValadocErrordomains` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(errdom));
+		this.file.printf ("INSERT INTO `ValadocErrordomains` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(errdom));
 	}
 
 	public override void visit_enum ( Enum en ) {
@@ -500,7 +500,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			}			
 		}
 
-		this.file.printf ("INSERT INTO `ValadocEnum` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(en));
+		this.file.printf ("INSERT INTO `ValadocEnum` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(en));
 	}
 
 	public override void visit_property ( Property prop ) {
@@ -528,7 +528,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			modifier = "NORMAL";
 		}
 
-		this.file.printf ("INSERT INTO `ValadocProperties` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(prop), modifier);
+		this.file.printf ("INSERT INTO `ValadocProperties` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(prop), modifier);
 	}
 
 	public override void visit_constant ( Constant constant, ConstantHandler parent ) {
@@ -542,7 +542,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			return ;
 		}
 
-		this.file.printf ("INSERT INTO `ValadocConstants` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(constant));
+		this.file.printf ("INSERT INTO `ValadocConstants` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(constant));
 	}
 
 	public override void visit_field ( Field field, FieldHandler parent ) {
@@ -564,7 +564,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			modifier = "NORMAL";
 		}
 
-		this.file.printf ("INSERT INTO `ValadocFields` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(field), modifier);
+		this.file.printf ("INSERT INTO `ValadocFields` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(field), modifier);
 	}
 
 	public override void visit_error_code ( ErrorCode errcode ) {
@@ -578,7 +578,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			return ;
 		}
 
-		this.file.printf ("INSERT INTO `ValadocErrorcodes` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n" , this.get_type_path(errcode));
+		this.file.printf ("INSERT INTO `ValadocErrorcodes` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n" , this.get_type_path(errcode));
 	}
 
 	public override void visit_enum_value ( EnumValue enval ) {
@@ -592,7 +592,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			return ;
 		}
 
-		this.file.printf ("INSERT INTO `ValadocEnumvalues` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(enval));
+		this.file.printf ("INSERT INTO `ValadocEnumvalues` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(enval));
 	}
 
 	public override void visit_delegate ( Delegate del ) {
@@ -614,7 +614,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			modifier = "NORMAL";
 		}
 
-		this.file.printf ("INSERT INTO `ValadocDelegates` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE  BINARY`fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(del), modifier);
+		this.file.printf ("INSERT INTO `ValadocDelegates` (`id`, `modifier`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE  BINARY`fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(del), modifier);
 	}
 
 	public override void visit_signal ( Signal sig ) {
@@ -628,7 +628,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 			return ;
 		}
 
-		this.file.printf ("INSERT INTO `ValadocSignals` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(sig));
+		this.file.printf ("INSERT INTO `ValadocSignals` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(sig));
 	}
 
 	public override void visit_method ( Method m, Valadoc.MethodHandler parent ) {
@@ -644,7 +644,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 
 
 		if (m.is_constructor) {
-			this.file.printf ("INSERT INTO `ValadocConstructors` (`id`) VALUES ((SELECT `id` FROM `ValadocElement` WHERE `fullname`='%s' LIMIT 1));\n", this.get_type_path(m));
+			this.file.printf ("INSERT INTO `ValadocConstructors` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE `fullname`='%s' LIMIT 1));\n", this.get_type_path(m));
 		}
 		else {
 			string modifier;
@@ -661,7 +661,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
 				modifier = "NORMAL";
 			}
 
-			this.file.printf("INSERT INTO `ValadocMethods` (`id`, `modifier`)VALUES ((SELECT `id` FROM `ValadocElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(m), modifier);
+			this.file.printf("INSERT INTO `ValadocMethods` (`id`, `modifier`)VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1), '%s');\n", this.get_type_path(m), modifier);
 		}
 	}
 
diff --git a/src/libvaladoc/apitree.vala b/src/libvaladoc/apitree.vala
index 4c895c4..354fd14 100755
--- a/src/libvaladoc/apitree.vala
+++ b/src/libvaladoc/apitree.vala
@@ -4117,14 +4117,6 @@ public class Valadoc.Tree : Vala.CodeVisitor {
 		get;
 	}
 
-	public int get_errors () {
-		return this.context.report.get_errors ();
-	}
-
-	public int get_warnings () {
-		return this.context.report.get_warnings ();
-	}
-
 	public Gee.ReadOnlyCollection<Package> get_package_list () {
 		return new Gee.ReadOnlyCollection<Package> ( this.packages );
 	}
@@ -4141,93 +4133,6 @@ public class Valadoc.Tree : Vala.CodeVisitor {
 		}
 	}
 
-	public bool add_file ( string path ) {
-		string source = realpath ( path );
-
-		if ( FileUtils.test ( source, FileTest.EXISTS ) == false )
-			return false;
-
-		if ( path.has_suffix ( ".c" ) ) {
-			this.context.add_c_source_file ( source );
-			return true;
-		}
-
-		Vala.SourceFile vfile = null;
-
-		if ( path.has_suffix ( ".vala" ) || path.has_suffix ( ".gs" ) ) {
-			vfile = new Vala.SourceFile (this.context, source, false);
-			vfile.add_using_directive (new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)));
-			this.context.add_source_file ( vfile );
-		}
-		else if ( path.has_suffix ( ".vapi" ) ) {
-			vfile = new Vala.SourceFile ( this.context, source, true );
-			this.context.add_source_file ( vfile );
-		}
-		else {
-			return false;
-		}
-
-		if ( this.source_package == null ) {
-			this.source_package = new Package.with_name ( this.settings, vfile, this.settings.pkg_name, this );
-			this.packages.add ( this.source_package );
-		}
-
-		this.source_package.add_file ( vfile );
-		return true;
-	}
-
-	public bool add_external_package ( string[] vapi_directories, string pkg ) {
-		if ( this.context.has_package ( pkg ) ) {
-			return true;
-		}
-
-		var package_path = this.context.get_package_path ( pkg, vapi_directories );
-		if ( package_path == null ) {
-			return false;
-		}
-	
-		this.context.add_package ( pkg );
-
-
-		Vala.SourceFile vfile = new Vala.SourceFile ( this.context, package_path, true );
-		this.context.add_source_file ( vfile );
-
-
-		Package vdpkg = new Package ( this.settings, vfile, this, true ); 
-		this.packages.add ( vdpkg );
-
-
-		var deps_filename = Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg));
-		if (FileUtils.test (deps_filename, FileTest.EXISTS)) {
-			try {
-				Gee.ArrayList<Package> deppkglst = new Gee.ArrayList<Package> ();
-				string deps_content;
-				ulong deps_len;
-
-				FileUtils.get_contents ( deps_filename, out deps_content, out deps_len );
-				foreach (string dep in deps_content.split ( "\n" )) {
-					if (dep != "") {
-						if ( add_external_package ( vapi_directories, dep ) ) {
-							Package? deppkg = get_external_package_by_name ( dep );
-							if ( deppkg != null ) {
-								deppkglst.add ( deppkg );
-							}
-						}
-						else {
-							this.reporter.simple_error  ( "%s, dependency of %s, not found in specified Vala API directories".printf(dep, pkg) );
-						}
-					}
-				}
-				vdpkg.set_dependency_list ( deppkglst );
-			}
-			catch (FileError e) {
-				this.reporter.simple_error ( "Unable to read dependency file: %s".printf(e.message) );
-			}
-		}
-		
-		return true;
-	}
-
 	public void visit ( Doclet doclet ) {
 		doclet.initialisation ( this.settings, this );
 	}
@@ -4413,7 +4318,7 @@ public class Valadoc.Tree : Vala.CodeVisitor {
 		ns.add_error_domain ( verrdom );
 	}
 
-	public Tree ( Valadoc.ErrorReporter reporter, Valadoc.Settings settings, bool non_null_experimental, bool disable_checking, string? basedir, string? directory ) {
+	public Tree ( Valadoc.ErrorReporter reporter, Valadoc.Settings settings) {
 		this.context = new Vala.CodeContext ( );
 		CodeContext.push (context);
 
@@ -4422,28 +4327,153 @@ public class Valadoc.Tree : Vala.CodeVisitor {
 
 		reporter.vreporter = this.context.report;
 
-		if ( basedir != null ) {
-			this.context.basedir = realpath ( basedir );
+		this.context.checking = settings.enable_checking;
+		this.context.deprecated = settings.deprecated;
+		this.context.experimental = settings.experimental;
+		this.context.non_null_experimental = settings.non_null_experimental;
+		this.context.dbus_transformation = !settings.disable_dbus_transformation;
+
+
+		if (settings.basedir == null) {
+			context.basedir = realpath (".");
+		} else {
+			context.basedir = realpath (settings.basedir);
 		}
 
-		if ( directory != null ) {
-			this.context.directory = realpath ( directory );
+		if (settings.directory != null) {
+			context.directory = realpath (settings.directory);
+		} else {
+			context.directory = context.basedir;
+		}
+
+		if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
+			context.profile = Profile.GOBJECT;
+			context.add_define ("GOBJECT");
+		}
+
+		if (settings.defines != null) {
+			foreach (string define in settings.defines) {
+				context.add_define (define);
+			}
+		}
+
+		if (context.profile == Profile.POSIX) {
+			/* default package */
+			if (!add_package ("posix")) {
+				Report.error (null, "posix not found in specified Vala API directories");
+			}
+		}
+		else if (context.profile == Profile.GOBJECT) {
+			int glib_major = 2;
+			int glib_minor = 12;
+
+
+			context.target_glib_major = glib_major;
+			context.target_glib_minor = glib_minor;
+			if (context.target_glib_major != 2) {
+				Report.error (null, "This version of valac only supports GLib 2");
+			}
+
+			/* default packages */
+			if (!this.add_package ("glib-2.0")) { //
+				Report.error (null, "glib-2.0 not found in specified Vala API directories");
+			}
+
+			if (!this.add_package ("gobject-2.0")) { //
+				Report.error (null, "gobject-2.0 not found in specified Vala API directories");
+			}
+		}
+	}
+
+
+	private bool add_package (string pkg) {
+		if (context.has_package (pkg)) {
+			// ignore multiple occurences of the same package
+			return true;
+		}
+	
+		var package_path = context.get_package_path (pkg, settings.vapi_directories);
+		
+		if (package_path == null) {
+			return false;
+		}
+
+		context.add_package (pkg);
+
+
+		var vfile = new SourceFile (context, package_path, true);
+		context.add_source_file (vfile);
+
+		Package vdpkg = new Package (this.settings, vfile, this, true);
+		this.packages.add (vdpkg);
+
+		var deps_filename = Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg));
+		if (FileUtils.test (deps_filename, FileTest.EXISTS)) {
+			try {
+				string deps_content;
+				ulong deps_len;
+				FileUtils.get_contents (deps_filename, out deps_content, out deps_len);
+				foreach (string dep in deps_content.split ("\n")) {
+					dep.strip ();
+					if (dep != "") {
+						if (!add_package (dep)) {
+							Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg));
+						}
+					}
+				}
+			} catch (FileError e) {
+				Report.error (null, "Unable to read dependency file: %s".printf (e.message));
+			}
+		}
+		
+		return true;
+	}
+
+
+	public void add_depencies (string[] packages) {
+		foreach (string package in packages) {
+			if (!add_package (package)) {
+				Report.error (null, "%s not found in specified Vala API directories".printf (package));
+			}
+		}
+	}
+
+	public void add_documented_file (string[] sources) {
+		if (sources == null) {
+			return ;
+		}
+
+		foreach (string source in sources) {
+			if (FileUtils.test (source, FileTest.EXISTS)) {
+				var rpath = realpath (source);
+				if (source.has_suffix (".vala") || source.has_suffix (".gs")) {
+					var source_file = new SourceFile (context, rpath);
+					Package vdpkg = new Package (this.settings, source_file, this, false); 
+					this.packages.add (vdpkg);
+
+					if (context.profile == Profile.POSIX) {
+						// import the Posix namespace by default (namespace of backend-specific standard library)
+						source_file.add_using_directive (new UsingDirective (new UnresolvedSymbol (null, "Posix", null)));
+					} else if (context.profile == Profile.GOBJECT) {
+						// import the GLib namespace by default (namespace of backend-specific standard library)
+						source_file.add_using_directive (new UsingDirective (new UnresolvedSymbol (null, "GLib", null)));
+					}
+
+					context.add_source_file (source_file);
+				} else if (source.has_suffix (".vapi")) {
+					var vfile = new SourceFile (context, rpath, true);
+					Package vdpkg = new Package (this.settings, vfile, this, true); 
+					context.add_source_file (vfile);
+					this.packages.add (vdpkg);
+				} else if (source.has_suffix (".c")) {
+					context.add_c_source_file (rpath);
+				} else {
+					Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source));
+				}
+			} else {
+				Report.error (null, "%s not found".printf (source));
+			}
 		}
-		else {
-			this.context.directory = context.basedir;
-		}
-
-		this.context.non_null_experimental = non_null_experimental;
-		this.context.checking = !disable_checking;
-		this.context.compile_only = false;
-		this.context.save_temps = false;
-		this.context.save_temps = false;
-		this.context.checking = false;
-		this.context.assert = false;
-		this.context.thread = false;
-		this.context.debug = false;
-		this.context.output = null;
-		this.context.optlevel = 0;
 	}
 
 	public bool create_tree ( ) {
diff --git a/src/libvaladoc/settings.vala b/src/libvaladoc/settings.vala
index 4a2f011..7595f8b 100755
--- a/src/libvaladoc/settings.vala
+++ b/src/libvaladoc/settings.vala
@@ -25,11 +25,25 @@ public class Valadoc.Settings : Object {
 	public string pkg_name = null;
 	public string pkg_version;
 	public string wiki_directory;
+
 	public bool _private = false;
 	public bool _protected = false;
 	public bool with_deps = false;
 	public bool add_inherited = false;
 	public bool verbose = false;
+
+	public bool enable_checking;
+	public bool deprecated;
+	public bool experimental;
+	public bool non_null_experimental;
+	public bool disable_dbus_transformation;
+
+	public string? profile;
+	public string? basedir;
+	public string? directory;
+
+	public string[] defines;
+	public string[] vapi_directories;
 }
 
 
diff --git a/src/valadoc/valadoc.vala b/src/valadoc/valadoc.vala
index 54f3496..110f9df 100755
--- a/src/valadoc/valadoc.vala
+++ b/src/valadoc/valadoc.vala
@@ -31,7 +31,6 @@ public class ValaDoc : Object {
 	private static string pluginpath = null;
 	private static string directory = null;
 	private static string pkg_name = null;
-	private static string basedir = null;
 
 	private static bool add_inherited = false;
 	private static bool _protected = false;
@@ -39,30 +38,47 @@ public class ValaDoc : Object {
 	private static bool _private = false;
 	private static bool version = false;
 
-	private static bool non_null_experimental = false;
-	private static bool disable_checking;
 	private static bool verbose = false;
 	private static bool force = false;
 
+	private static string basedir = null;
+	private static string[] defines;
+	private static bool enable_checking;
+	private static bool deprecated;
+	private static bool experimental;
+	private static bool non_null_experimental = false;
+	private static bool disable_dbus_transformation;
+	private static string profile;
 
 	[CCode (array_length = false, array_null_terminated = true)]
 	private static string[] vapi_directories;
 	[CCode (array_length = false, array_null_terminated = true)]
 	private static string[] tsources;
 	[CCode (array_length = false, array_null_terminated = true)]
-	private static string[] tpackages;
+	private static string[] packages;
 
 	private const GLib.OptionEntry[] options = {
+		{ "basedir", 'b', 0, OptionArg.FILENAME, ref basedir, "Base source directory", "DIRECTORY" },
+		{ "define", 'D', 0, OptionArg.STRING_ARRAY, ref defines, "Define SYMBOL", "SYMBOL..." },
+		{ "enable-checking", 0, 0, OptionArg.NONE, ref enable_checking, "Enable additional run-time checks", null },
+		{ "enable-deprecated", 0, 0, OptionArg.NONE, ref deprecated, "Enable deprecated features", null },
+		{ "enable-experimental", 0, 0, OptionArg.NONE, ref experimental, "Enable experimental features", null },
+		{ "enable-non-null-experimental", 0, 0, OptionArg.NONE, ref non_null_experimental, "Enable experimental enhancements for non-null types", null },
+		{ "disable-dbus-transformation", 0, 0, OptionArg.NONE, ref disable_dbus_transformation, "Disable transformation of D-Bus member names", null },
 		{ "vapidir", 0, 0, OptionArg.FILENAME_ARRAY, ref vapi_directories, "Look for package bindings in DIRECTORY", "DIRECTORY..." },
-		{ "pkg", 0, 0, OptionArg.STRING_ARRAY, ref tpackages, "Include binding for PACKAGE", "PACKAGE..." },
+		{ "profile", 0, 0, OptionArg.STRING, ref profile, "Use the given profile instead of the default", "PROFILE" },
+
+
+		{ "pkg", 0, 0, OptionArg.STRING_ARRAY, ref packages, "Include binding for PACKAGE", "PACKAGE..." },
 		{ "directory", 'o', 0, OptionArg.FILENAME, ref directory, "Output directory", "DIRECTORY" },
-		{ "protected", 0, 0, OptionArg.NONE, ref _protected, "Adds protected elements to documentation", null },
-		{ "private", 0, 0, OptionArg.NONE, ref _private, "Adds private elements to documentation", null },
-		{ "inherit", 0, 0, OptionArg.NONE, ref add_inherited, "Adds inherited elements to a class", null },
-		{ "deps", 0, 0, OptionArg.NONE, ref with_deps, "Adds packages to the documentation", null },
-		{ "enable-non-null-experimental", 0, 0, OptionArg.NONE, ref non_null_experimental, "Enable experimentalenhancements for non-null types", null },
+
 		{ "wiki", 0, 0, OptionArg.FILENAME, ref wikidirectory, "Wiki directory", "DIRECTORY" },
+		{ "deps", 0, 0, OptionArg.NONE, ref with_deps, "Adds packages to the documentation", null },
 		{ "doclet", 0, 0, OptionArg.STRING, ref pluginpath, "plugin", "Name of an included doclet or path to custom doclet" },
+
+		{ "protected", 0, 0, OptionArg.NONE, ref _protected, "Adds protected elements to documentation", null },
+		{ "private", 0, 0, OptionArg.NONE, ref _private, "Adds private elements to documentation", null },
+//		{ "inherit", 0, 0, OptionArg.NONE, ref add_inherited, "Adds inherited elements to a class", null },
 		{ "package-name", 0, 0, OptionArg.STRING, ref pkg_name, "package name", "DIRECTORY" },
 		{ "package-version", 0, 0, OptionArg.STRING, ref pkg_version, "package version", "DIRECTORY" },
 		{ "force", 0, 0, OptionArg.NONE, ref force, "force", null },
@@ -120,6 +136,18 @@ public class ValaDoc : Object {
 		settings.verbose = this.verbose;
 		settings.wiki_directory = this.wikidirectory;
 
+		settings.enable_checking = enable_checking;
+		settings.deprecated = deprecated;
+		settings.experimental = experimental;
+		settings.non_null_experimental = non_null_experimental;
+		settings.disable_dbus_transformation = disable_dbus_transformation;
+		settings.basedir = basedir;
+		settings.directory = directory;
+		settings.vapi_directories = vapi_directories;
+
+		settings.profile = profile;
+		settings.defines = defines;
+
 		string fulldirpath = "";
 		if ( pluginpath == null ) {
 			fulldirpath = build_filename ( Config.plugin_dir, "html" );
@@ -147,41 +175,26 @@ public class ValaDoc : Object {
 			return quit ( reporter );
 		}
 
-		Valadoc.Tree doctree = new Valadoc.Tree ( reporter, settings, non_null_experimental, disable_checking, basedir, directory );
-		Valadoc.Parser docparser = new Valadoc.Parser ( settings, reporter, doctree, modules );
 
-		if (!doctree.add_external_package ( vapi_directories, "glib-2.0" )) {
-			reporter.simple_error ( "glib-2.0 not found in specified Vala API directories" );
+		Valadoc.Tree doctree = new Valadoc.Tree ( reporter, settings);
+		Valadoc.Parser docparser = new Valadoc.Parser ( settings, reporter, doctree, modules );
+		if (reporter.errors > 0) {
 			return quit ( reporter );
 		}
 
-		if (!doctree.add_external_package ( vapi_directories, "gobject-2.0" )) {
-			reporter.simple_error ( "gobject-2.0 not found in specified Vala API directories" );
+		doctree.add_depencies (packages);
+		if (reporter.errors > 0) {
 			return quit ( reporter );
 		}
 
-		if ( this.tpackages != null ) {
-			foreach (string package in this.tpackages ) {
-				if (!doctree.add_external_package ( vapi_directories, package )) {
-					reporter.simple_error ( "%s not found in specified Vala API directories".printf(package) );
-					return quit ( reporter );
-				}
-			}
-			this.tpackages = null;
-		}
 
-		if ( tsources != null ) {
-			foreach ( string src in tsources ) {
-				if ( !doctree.add_file ( src ) ) {
-					reporter.simple_error ( "%s not found".printf(src) );
-					return quit ( reporter );
-				}
-			}
-			tsources = null;
+		doctree.add_documented_file (tsources);
+		if (reporter.errors > 0) {
+			return quit ( reporter );
 		}
 
-		if ( !doctree.create_tree( ) )
-			return quit ( reporter );
+		if (!doctree.create_tree())
+			return quit (reporter);
 
 		doctree.parse_comments ( docparser );
 		if ( reporter.errors > 0 )



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]