valadoc r20 - in trunk/src: doclets/devhelp/linkhelper doclets/html/doclet doclets/html/linkhelper doclets/htmlhelpers doclets/valadoc.org/doclet libvaladoc valadoc
- From: flobrosch svn gnome org
- To: svn-commits-list gnome org
- Subject: valadoc r20 - in trunk/src: doclets/devhelp/linkhelper doclets/html/doclet doclets/html/linkhelper doclets/htmlhelpers doclets/valadoc.org/doclet libvaladoc valadoc
- Date: Thu, 20 Nov 2008 21:26:42 +0000 (UTC)
Author: flobrosch
Date: Thu Nov 20 21:26:41 2008
New Revision: 20
URL: http://svn.gnome.org/viewvc/valadoc?rev=20&view=rev
Log:
- cleanups
- ui-bugfix
Modified:
trunk/src/doclets/devhelp/linkhelper/helper.vala
trunk/src/doclets/html/doclet/template.vala
trunk/src/doclets/html/linkhelper/helper.vala
trunk/src/doclets/htmlhelpers/htmlhelpers.vala
trunk/src/doclets/valadoc.org/doclet/template.vala
trunk/src/libvaladoc/doctree.vala
trunk/src/libvaladoc/drawer.vala
trunk/src/libvaladoc/parser.vala
trunk/src/libvaladoc/settings.vala
trunk/src/valadoc/valadoc.vala
Modified: trunk/src/doclets/devhelp/linkhelper/helper.vala
==============================================================================
--- trunk/src/doclets/devhelp/linkhelper/helper.vala (original)
+++ trunk/src/doclets/devhelp/linkhelper/helper.vala Thu Nov 20 21:26:41 2008
@@ -24,12 +24,12 @@
public interface Valadoc.HtmlHelper {
protected string? get_html_link ( Settings settings, Basic element, Basic pos ) {
- string tmp = "";
- string prefix = "";
-
if ( element is Package ) {
return "../" + element.name + "/index.html";
}
+
+ string tmp = "";
+ string prefix = "";
if ( element != pos ) {
prefix = "../" + element.file.name;
Modified: trunk/src/doclets/html/doclet/template.vala
==============================================================================
--- trunk/src/doclets/html/doclet/template.vala (original)
+++ trunk/src/doclets/html/doclet/template.vala Thu Nov 20 21:26:41 2008
@@ -127,7 +127,7 @@
public override void visit_package ( Package file ) {
this.package_name = file.name;
- this.is_vapi = file.is_external_package;
+ this.is_vapi = file.is_package;
if ( this.is_vapi )
this.files.add ( file );
else
Modified: trunk/src/doclets/html/linkhelper/helper.vala
==============================================================================
--- trunk/src/doclets/html/linkhelper/helper.vala (original)
+++ trunk/src/doclets/html/linkhelper/helper.vala Thu Nov 20 21:26:41 2008
@@ -35,6 +35,10 @@
}
protected string? get_html_link ( Valadoc.Settings settings, Valadoc.Basic element, Valadoc.Basic pos2 ) {
+ Package pkg = ( element is Package )? (Package)element : element.file;
+ if ( pkg.is_visitor_accessible () == false )
+ return null;
+
GLib.StringBuilder str = new GLib.StringBuilder ( "" );
Valadoc.Basic pos = element;
string? link_id = null;
@@ -44,6 +48,10 @@
link_id = "#" + element.name;
pos = pos.parent;
}
+ else if ( element is Visitable ) {
+ if ( !((Visitable)element).is_visitor_accessible() )
+ return null;
+ }
while ( pos != null ) {
if ( pos.name == null )
Modified: trunk/src/doclets/htmlhelpers/htmlhelpers.vala
==============================================================================
--- trunk/src/doclets/htmlhelpers/htmlhelpers.vala (original)
+++ trunk/src/doclets/htmlhelpers/htmlhelpers.vala Thu Nov 20 21:26:41 2008
@@ -655,7 +655,6 @@
}
public override void write_delegate ( Valadoc.Delegate del, void* ptr ) {
- GLib.StringBuilder modifiers = new GLib.StringBuilder ( "" );
weak GLib.FileStream file = (GLib.FileStream)ptr;
this.position = del;
@@ -850,7 +849,7 @@
// if ( mself == null )
// mself = element;
- string package_name = element.file.name;
+// string package_name = element.file.name;
this.write_top_element ( file, mself );
@@ -895,7 +894,7 @@
file.printf ( "\t\t\t\t<ul class=\"%s\">\n", css_navi );
- Namespace globals;
+ Namespace globals = null;
foreach ( Namespace ns in ns_list ) {
if ( ns.name == null )
@@ -1648,7 +1647,11 @@
file.printf ( "<ul class=\"%s\">\n", css_inline_navigation );
foreach ( Package p in deps ) {
- file.printf ( "\t<li class=\"%s\"><a class=\"%s\" href=\"%s\">%s</a></li>\n", css_inline_navigation_package, css_navi_link, this.get_link(p, mself), p.name );
+ string link = this.get_link(p, mself);
+ if ( link == null )
+ file.printf ( "\t<li class=\"%s\">%s</li>\n", css_inline_navigation_package, p.name );
+ else
+ file.printf ( "\t<li class=\"%s\"><a class=\"%s\" href=\"%s\">%s</a></li>\n", css_inline_navigation_package, css_navi_link, link, p.name );
}
file.puts ( "</ul>\n" );
}
Modified: trunk/src/doclets/valadoc.org/doclet/template.vala
==============================================================================
--- trunk/src/doclets/valadoc.org/doclet/template.vala (original)
+++ trunk/src/doclets/valadoc.org/doclet/template.vala Thu Nov 20 21:26:41 2008
@@ -105,7 +105,7 @@
public override void visit_package ( Package file ) {
string package_name = file.name;
- this.is_vapi = file.is_external_package;
+ this.is_vapi = file.is_package;
string new_path = this.settings.path + package_name + "/";
@@ -140,7 +140,7 @@
var rt = DirUtils.create ( this.current_path, 0777 );
GLib.FileStream navi = GLib.FileStream.open ( this.current_path + "navi.html", "w" );
- this.write_navi_child_namespaces ( navi, ns, ns );
+ this.write_navi_namespace ( navi, ns );
navi = null;
GLib.FileStream file = GLib.FileStream.open ( this.current_path + "index.html", "w" );
Modified: trunk/src/libvaladoc/doctree.vala
==============================================================================
--- trunk/src/libvaladoc/doctree.vala (original)
+++ trunk/src/libvaladoc/doctree.vala Thu Nov 20 21:26:41 2008
@@ -37,14 +37,22 @@
return true;
}
- public void copy_directory ( string src, string dest ) {
+ public bool copy_directory ( string src, string dest ) {
string _src = ( src.has_suffix ( "/" ) )? src : src + "/";
string _dest = ( dest.has_suffix ( "/" ) )? dest : dest + "/";
- GLib.Dir dir = GLib.Dir.open ( _src );
- for ( weak string name = dir.read_name (); name != null ; name = dir.read_name () ) {
- copy_file ( _src+name, _dest+name );
+ try {
+ GLib.Dir dir = GLib.Dir.open ( _src );
+ for ( weak string name = dir.read_name (); name != null ; name = dir.read_name () ) {
+ if ( !copy_file ( _src+name, _dest+name ) ) {
+ return false;
+ }
+ }
+ }
+ catch ( GLib.FileError err ) {
+ return false;
}
+ return true;
}
public string realpath (string name) {
@@ -1023,14 +1031,22 @@
}
}
+ protected void add_construction_method ( Vala.CreationMethod vm ) {
+ var tmp = new Method ( this.settings, vm, this, this.head );
+ this.construction_methods.add ( tmp );
+ tmp.initialisation ( );
+ }
+
protected void add_methods_and_construction_methods ( Gee.Collection<Vala.Method> vmethods ) {
foreach ( Vala.Method vm in vmethods ) {
- var tmp = new Method ( this.settings, vm, this, this.head );
- tmp.initialisation ( );
- if ( tmp.is_constructor )
- this.construction_methods.add ( tmp );
- else
- this.methods.add ( tmp );
+ if ( vm is Vala.CreationMethod ) {
+ if ( ((Vala.CreationMethod)vm).generated == false ) {
+ this.add_construction_method ( (Vala.CreationMethod)vm );
+ }
+ }
+ else {
+ this.add_method ( vm );
+ }
}
}
}
@@ -1203,7 +1219,7 @@
return true;
}
- protected bool is_visitor_accessible ( ) {
+ public bool is_visitor_accessible ( ) {
if ( !this.settings._private && this.is_private )
return false;
@@ -1416,6 +1432,9 @@
// internal
public void add_field ( Vala.Field vf ) {
+ if ( vf.generated == true )
+ return ;
+
var tmp = new Field ( this.settings, vf, this, this.head );
this.fields.add ( tmp );
tmp.initialisation ( );
@@ -1753,6 +1772,7 @@
return new Gee.ReadOnlyCollection<TypeReference> ( this.type_arguments );
}
+
private void set_template_argument_list ( Gee.Collection<Vala.DataType> varguments ) {
foreach ( Vala.DataType vdtype in varguments ) {
var dtype = new TypeReference ( this.settings, vdtype, this, this.head );
@@ -1907,11 +1927,14 @@
// internal
public void set_type_references ( ) {
Vala.DataType vtype = this.vtyperef;
+
while ( vtype is Vala.PointerType || vtype is Vala.ArrayType ) {
for ( ; vtype is Vala.PointerType ; vtype = ((Vala.PointerType)vtype).base_type );
for ( ; vtype is Vala.ArrayType ; vtype = ((Vala.ArrayType)vtype).element_type );
}
+ this.set_template_argument_list ( vtype.get_type_arguments () );
+
if ( vtype is Vala.ErrorType ) {
Vala.ErrorDomain verrdom = ((Vala.ErrorType)vtype).error_domain;
if ( verrdom != null )
@@ -4240,13 +4263,25 @@
public class Valadoc.Package : Basic, NamespaceHandler {
+ private Gee.ArrayList<Vala.SourceFile> vfiles = new Gee.ArrayList<Vala.SourceFile> ();
+
+ // internal
+ public void add_file ( Vala.SourceFile vfile ) {
+ this.vfiles.add ( vfile );
+ }
+
public Gee.ArrayList<Namespace> namespaces {
default = new Gee.ArrayList<Namespace>();
private set;
private get;
}
-
+/*
public bool is_external_package {
+ /+ internal +/ set;
+ get;
+ }
+*/
+ public bool is_package {
private set;
get;
}
@@ -4305,7 +4340,7 @@
return new Gee.ReadOnlyCollection<Package> ( this._dependencies );
}
- private string extract_package_name ( Vala.SourceFile vfile ) {
+ private static string extract_package_name ( Settings settings, Vala.SourceFile vfile ) {
if ( vfile.filename.has_suffix (".vapi") ) {
string file_name = GLib.Path.get_basename (vfile.filename);
return file_name.ndup ( file_name.size() - ".vapi".size() );
@@ -4319,12 +4354,18 @@
}
}
- public Package ( Valadoc.Settings settings, Vala.SourceFile vfile, Tree head ) {
+ public Package.with_name ( Valadoc.Settings settings, Vala.SourceFile vfile, string name, Tree head, bool is_package = false ) {
this.settings = settings;
this.head = head;
- this.is_external_package = !( vfile.filename.has_suffix ( ".vala" ) || vfile.filename.has_suffix ( ".gs" ) );
- this.package_name = this.extract_package_name ( vfile );
+ this.is_package = is_package;
+ this.package_name = name;
+
+ this.vfiles.add ( vfile );
+ }
+
+ public Package ( Valadoc.Settings settings, Vala.SourceFile vfile, Tree head, bool is_package = false ) {
+ this.with_name ( settings, vfile, this.extract_package_name ( settings, vfile ), head, is_package );
}
private string package_name;
@@ -4363,14 +4404,28 @@
}
// internal
- public bool is_package ( Vala.SourceFile vfile ) {
- return ( this.extract_package_name ( vfile ) == this.package_name );
+ public bool is_vpackage ( Vala.SourceFile vfile ) {
+ return this.vfiles.contains ( vfile );
+ }
+
+/*
+is_package || with_deps || ergebnis
+0 || 0 || 1
+0 || 1 || 1
+1 || 0 || 0
+1 || 1 || 1
+
+!(is_package == true && with_deps == false)
+*/
+
+ public bool is_visitor_accessible () {
+ return !( this.is_package && this.settings.with_deps == false );
}
public void visit ( Doclet doclet ) {
- if ( !settings.to_doc ( this.name ) )
+ if ( !this.is_visitor_accessible () ) {
return ;
-
+ }
doclet.visit_package ( this );
}
@@ -4404,9 +4459,144 @@
private get;
}
- public Tree (Valadoc.Settings settings, Vala.CodeContext context ) {
+ public Tree ( Valadoc.Settings settings,
+ bool non_null_experimental,
+ bool disable_non_null,
+ bool disable_checking,
+ string basedir,
+ string directory )
+ {
+ this.context = new Vala.CodeContext ( );
this.settings = settings;
- this.context = context;
+
+ if ( basedir != null ) {
+ this.context.basedir = realpath ( basedir );
+ }
+
+ if ( directory != null ) {
+ this.context.directory = realpath ( directory );
+ }
+ else {
+ this.context.directory = context.basedir;
+ }
+
+ this.context.non_null = !disable_non_null || non_null_experimental;
+ this.context.non_null_experimental = non_null_experimental;
+ this.context.checking = !disable_checking;
+
+ this.context.memory_management = false;
+ 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.library = null;
+ this.context.debug = false;
+ this.context.output = null;
+ this.context.optlevel = 0;
+ }
+
+ private Package source_package = null;
+
+ private void add_dependencies_to_source_package () {
+ if ( this.source_package != null ) {
+ Gee.ArrayList<Package> deplst = new Gee.ArrayList<Package> ();
+ foreach ( Package pkg in this.files ) {
+ if ( pkg != this.source_package ) {
+ deplst.add ( pkg );
+ }
+ }
+ this.source_package.set_dependency_list ( deplst );
+ }
+ }
+
+ 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.files.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.files.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 {
+ Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg));
+ }
+ }
+ }
+ vdpkg.set_dependency_list ( deppkglst );
+ }
+ catch (FileError e) {
+ Report.error (null, "Unable to read dependency file: %s".printf (e.message));
+ }
+ }
+
+ return true;
}
public CodeContext context {
@@ -4420,11 +4610,11 @@
}
}
-
+/*
private weak Basic? search_symbol_in_namespace ( Basic element, string[] params ) {
return this.search_symbol_in_symbol ( element.nspace, params );
}
-
+*/
private weak Basic? search_symbol_in_type ( Basic element, string[] params, int params_offset = 0 ) {
if ( !( element.parent is ContainerDataType || element.parent is Enum || element.parent is ErrorDomain ) )
return null;
@@ -4522,7 +4712,7 @@
return ;
Vala.SourceFile vfile = vcl.source_reference.file;
- Package file = this.get_file ( vfile );
+ Package file = this.find_file( vfile );
Namespace ns = file.get_namespace ( vcl );
ns.add_class ( vcl );
}
@@ -4532,7 +4722,7 @@
return ;
Vala.SourceFile vfile = viface.source_reference.file;
- Package file = this.get_file ( vfile );
+ Package file = this.find_file( vfile );
Namespace ns = file.get_namespace ( viface );
ns.add_interface ( viface );
}
@@ -4542,7 +4732,7 @@
return ;
Vala.SourceFile vfile = vstru.source_reference.file;
- Package file = this.get_file ( vfile );
+ Package file = this.find_file( vfile );
Namespace ns = file.get_namespace ( vstru );
ns.add_struct ( vstru );
}
@@ -4552,7 +4742,7 @@
return ;
Vala.SourceFile vfile = vf.source_reference.file;
- Package file = this.get_file ( vfile );
+ Package file = this.find_file( vfile );
Namespace ns = file.get_namespace ( vf );
ns.add_field ( vf );
}
@@ -4562,7 +4752,7 @@
return ;
Vala.SourceFile vfile = vm.source_reference.file;
- Package file = this.get_file ( vfile );
+ Package file = this.find_file( vfile );
Namespace ns = file.get_namespace ( vm );
ns.add_method ( vm );
}
@@ -4572,7 +4762,7 @@
return ;
Vala.SourceFile vfile = vd.source_reference.file;
- Package file = this.get_file ( vfile );
+ Package file = this.find_file( vfile );
Namespace ns = file.get_namespace ( vd );
ns.add_delegate ( vd );
}
@@ -4582,7 +4772,7 @@
return ;
Vala.SourceFile vfile = venum.source_reference.file;
- Package file = this.get_file ( vfile );
+ Package file = this.find_file( vfile );
Namespace ns = file.get_namespace ( venum );
ns.add_enum ( venum );
}
@@ -4592,7 +4782,7 @@
return ;
Vala.SourceFile vfile = vc.source_reference.file;
- Package file = this.get_file ( vfile );
+ Package file = this.find_file( vfile );
Namespace ns = file.get_namespace ( vc );
ns.add_constant ( vc );
}
@@ -4602,22 +4792,50 @@
return ;
Vala.SourceFile vfile = verrdom.source_reference.file;
- Package file = this.get_file ( vfile );
+ Package file = this.find_file( vfile );
Namespace ns = file.get_namespace ( verrdom );
ns.add_error_domain ( verrdom );
}
- public void create_tree ( ) {
+ public bool create_tree ( ) {
+ Vala.Parser parser = new Vala.Parser ();
+ parser.parse ( this.context );
+ if (Report.get_errors () > 0) {
+ return false;
+ }
+
+ Vala.SymbolResolver resolver = new SymbolResolver ();
+ resolver.resolve( this.context );
+ if (Report.get_errors () > 0) {
+ return false;
+ }
+
+ Vala.SemanticAnalyzer analyzer = new SemanticAnalyzer ( );
+ analyzer.analyze( this.context );
+ if (Report.get_errors () > 0) {
+ return false;
+ }
+
+ if ( context.non_null_experimental ) {
+ Vala.NullChecker null_checker = new NullChecker ();
+ null_checker.check ( this.context );
+
+ if (Report.get_errors () > 0) {
+ return false;
+ }
+ }
+
this.context.accept( this );
this.set_type_references ( );
- this.inheritance ( ); // remove
- this.add_dependencies ();
+ this.inheritance ( ); // create a switch!
+ this.add_dependencies_to_source_package ();
+ return true;
}
// internal
public Package? find_file ( Vala.SourceFile vfile ) {
foreach ( Package f in this.files ) {
- if ( f.is_package( vfile ) )
+ if ( f.is_vpackage( vfile ) )
return f;
}
return null;
@@ -4664,11 +4882,12 @@
}
Vala.SourceFile vfile = vnode.source_reference.file;
- Package file = this.get_file ( vfile );
+ Package file = this.find_file( vfile );
return file.search_element_vala ( params, 0 );
}
+ /*/ => add_external_package
private Gee.ArrayList<Package>? load_dependency_list ( string vapi_path ) {
if ( vapi_path.has_suffix ( ".vapi" ) ) {
string deps_filename = vapi_path.ndup ( vapi_path.size() - ".vapi".size() ) + ".deps";
@@ -4690,7 +4909,8 @@
}
}
}
- } catch (FileError e) {
+ }
+ catch (FileError e) {
Report.error (null, "Unable to read dependency file: %s".printf (e.message));
}
}
@@ -4698,10 +4918,10 @@
}
return null;
}
+*/
+// private Gee.ArrayList<weak Vala.SourceFile> vfiles = new Gee.ArrayList<weak Vala.SourceFile> ();
- private Gee.ArrayList<weak Vala.SourceFile> vfiles = new Gee.ArrayList<weak Vala.SourceFile> ();
- private Package source_package;
-
+/*
private void add_dependencies () {
foreach ( weak Vala.SourceFile vfile in this.vfiles ) {
Gee.ArrayList<Package>? deps = this.load_dependency_list ( vfile.filename );
@@ -4724,21 +4944,25 @@
this.source_package = null;
this.vfiles = null;
}
+*/
+ private Package? get_external_package_by_name ( string name ) {
+ foreach ( Package pkg in this.files ) {
+ if ( name == pkg.name ) {
+ return pkg;
+ }
+ }
+ return null;
+ }
- // internal
- public Package get_file ( Vala.SourceFile vfile ) {
+ /*/ internal, deprecated
+ public Package? get_file ( Vala.SourceFile vfile ) {
Package file = this.find_file( vfile );
if ( file != null )
return file;
Package tmp = new Package ( this.settings, vfile, this );
- if ( tmp.is_external_package )
- this.vfiles.add ( vfile );
- else
- this.source_package = tmp;
-
this.files.add ( tmp );
return tmp;
- }
+ } */
}
Modified: trunk/src/libvaladoc/drawer.vala
==============================================================================
--- trunk/src/libvaladoc/drawer.vala (original)
+++ trunk/src/libvaladoc/drawer.vala Thu Nov 20 21:26:41 2008
@@ -16,59 +16,6 @@
return name + type.name;
}
- private static void draw_package_parents ( Package package, Graphviz.Graph g, Graphviz.Node me ) {
- weak Graphviz.Node? node = g.find_node ( package.name );
-
-
- Gee.Collection<Package> packlst = package.get_dependency_list ( );
-
- foreach ( Package pkg in packlst ) {
- weak Graphviz.Node gpkg = draw_package ( g, pkg, me );
- draw_package_parents ( pkg, g, gpkg );
- }
- }
-
- private static weak Graphviz.Node draw_package ( Graph g, Package package, Graphviz.Node? parent ) {
- string name = package.name;
- weak Graphviz.Node? node = g.find_node ( name );
- if ( node == null ) {
- node = g.node ( name );
- node.set_safe ( "shape", "box", "" );
- node.set_safe ( "fontname", "Times", "" );
- }
-
- if ( parent != null ) {
- if ( g.find_edge( parent, node ) == null ) {
- weak Edge edge = g.edge ( node, parent );
- edge.set_safe ( "dir", "back", "" );
- }
- }
-
- return node;
- }
-
- public static void write_dependency_diagram ( Package package, string path ) {
- string[] params2 = new string[5];
- params2[0] = "";
- params2[1] = "-T";
- params2[2] = "png";
- params2[3] = "-o";
- params2[4] = path;
-
- Graphviz.Context cntxt = Context.context( );
- cntxt.parse_args ( params2 );
-
- Graphviz.Graph g = Graph.open ( "g", GraphType.AGRAPH );
- g.set_safe ( "rank", "", "" );
-
- weak Graphviz.Node me = draw_package ( g, package, null );
- draw_package_parents ( package, g, me );
-
- cntxt.layout_jobs ( g );
- cntxt.render_jobs ( g );
- cntxt.free_layout ( g );
- }
-
public static void write_struct_diagram ( Struct stru, string path ) {
string[] params2 = new string[5];
params2[0] = "";
Modified: trunk/src/libvaladoc/parser.vala
==============================================================================
--- trunk/src/libvaladoc/parser.vala (original)
+++ trunk/src/libvaladoc/parser.vala Thu Nov 20 21:26:41 2008
@@ -340,7 +340,7 @@
bool tmp;
int max = this.description.size;
- int i;
+ int i = 0;
foreach ( InlineTaglet tag in this.description ) {
tmp = tag.write ( res, max, i );
@@ -577,7 +577,6 @@
string tagline = linestart;
- string? currtagname = "";
unichar prevprevchr = '\0';
unichar prevchr = '\0';
Modified: trunk/src/libvaladoc/settings.vala
==============================================================================
--- trunk/src/libvaladoc/settings.vala (original)
+++ trunk/src/libvaladoc/settings.vala Thu Nov 20 21:26:41 2008
@@ -44,7 +44,7 @@
return this.rpath;
}
- // wtf?
+ /*/
public bool application {
get {
foreach ( string path in this.files ) {
@@ -54,7 +54,7 @@
return false;
}
}
-
+*/
// remove!
public bool to_doc ( string name ) {
if ( with_deps == true )
Modified: trunk/src/valadoc/valadoc.vala
==============================================================================
--- trunk/src/valadoc/valadoc.vala (original)
+++ trunk/src/valadoc/valadoc.vala Thu Nov 20 21:26:41 2008
@@ -32,7 +32,6 @@
public class ValaDoc : Object {
private static string basedir = null;
private static string directory = null;
- private static string xmlsource = null;
private static string pkg_name = null;
private static string pkg_version = null;
@@ -55,8 +54,6 @@
[NoArrayLength ()]
private static weak string[] tsources;
[NoArrayLength ()]
- private static string library;
- [NoArrayLength ()]
private static weak string[] tpackages;
@@ -64,8 +61,8 @@
private Type doclettype;
- private Gee.ArrayList<string> packages = new Gee.ArrayList<string>();
- private Gee.ArrayList<string> sources = new Gee.ArrayList<string>();
+ private Gee.ArrayList<string> packages = new Gee.ArrayList<string>(); // remove
+ private Gee.ArrayList<string> sources = new Gee.ArrayList<string>(); // remove
private const GLib.OptionEntry[] options = {
@@ -93,7 +90,7 @@
{ null }
};
- private int quit () {
+ private static int quit () {
if (Report.get_errors () == 0) {
stdout.printf ("Succeeded - %d warning(s)\n", Report.get_warnings ());
return 0;
@@ -103,7 +100,7 @@
return 1;
}
}
-
+/*
private bool add_package (CodeContext context, string pkg) {
if (context.has_package (pkg)) {
// ignore multiple occurences of the same package
@@ -140,7 +137,7 @@
return true;
}
-
+*/
/*
private string? get_package_path (string pkg) {
if (FileUtils.test ( pkg, FileTest.EXISTS))
@@ -194,6 +191,7 @@
}
}
+ // remove
private Gee.ArrayList<string> sort_sources ( ) {
var to_doc = new Gee.ArrayList<string>();
@@ -215,12 +213,9 @@
}
}
- this.tpackages = null;
- this.tsources = null;
return to_doc;
}
-
/*
private static Gee.HashMap<string, Valadoc.TagletCreator> get_taglets ( ) {
Gee.HashMap<string, Valadoc.TagletCreator> taglets
@@ -335,7 +330,6 @@
module->symbol( "register_plugin", out function );
Valadoc.TagletRegisterFunction tagletregisterfkt = (Valadoc.TagletRegisterFunction) function;
- string? name;
GLib.Type type = tagletregisterfkt ( taglets2 );
@@ -366,14 +360,14 @@
return (Doclet)GLib.Object.new (doclettype);
}
- private bool check_pkg_name () {
+ private static bool check_pkg_name () {
if ( pkg_name == null )
return true;
if ( pkg_name == "glib-2.0" || pkg_name == "gobject-2.0" )
return false;
- foreach (string package in this.packages ) {
+ foreach (string package in tsources ) {
if ( pkg_name == package )
return false;
}
@@ -392,148 +386,93 @@
}
private int run ( ) {
- if ( !check_pkg_name () ) {
- Report.error (null, "Invalid package name." );
- }
-
var settings = new Valadoc.Settings ( );
settings.pkg_name = this.get_pkg_name ( );
settings.pkg_version = this.pkg_version;
settings.add_inherited = this.add_inherited;
- settings.files = this.sort_sources ( );
+
+ settings.files = this.sort_sources ( ); /// <--- remove!
+
settings._protected = this._protected;
settings.with_deps = this.with_deps;
settings._private = this._private;
settings.path = this.directory;
- var context = new Vala.CodeContext();
- context.library = this.library;
- context.memory_management = false;
- context.assert = false;
- context.checking = false;
- context.ccode_only = false;
- context.compile_only = false;
- context.output = null;
-
- context.checking = !disable_checking;
- context.non_null = !disable_non_null || non_null_experimental;
- context.non_null_experimental = non_null_experimental;
+ Reporter reporter = new Reporter();
- if ( this.basedir != null ) {
- context.basedir = realpath ( this.basedir );
- }
+ string fulldirpath = (pluginpath == null)? Config.plugin_dir : pluginpath;
+ bool tmp = this.check_doclet_structure ( pluginpath );
- if ( this.directory != null ) {
- context.directory = realpath ( this.directory );
- }
- else {
- context.directory = context.basedir;
+ if ( tmp == false ) {
+ Report.error (null, "failed to load plugin" );
+ return quit ();
}
- context.optlevel = 0;
- context.debug = false;
- context.thread = false;
- context.save_temps = false;
- if (!add_package (context, "glib-2.0")) {
- Report.error (null, "glib-2.0 not found in specified Vala API directories");
- }
-
- if (!add_package (context, "gobject-2.0")) {
- Report.error (null, "gobject-2.0 not found in specified Vala API directories");
- }
+ Gee.HashMap<string, Type> taglets;
+ GLib.Type strtag;
- if ( this.packages != null ) {
- foreach (string package in this.packages ) {
- if (!add_package (context, package)) {
- Report.error (null, "%s not found in specified Vala API directories".printf (package));
- }
- }
- this.packages = null;
+ tmp = this.load_taglets ( fulldirpath, out taglets, out strtag );
+ if ( tmp == false ) {
+ Report.error (null, "failed to load plugin" );
+ return quit ();
}
- if (Report.get_errors () > 0) {
+ Valadoc.Doclet doclet = this.load_doclet ( fulldirpath );
+ if ( doclet == null ) {
+ Report.error (null, "failed to load plugin" );
return quit ();
}
+ Valadoc.Parser docparser = new Valadoc.Parser ();
+ docparser.init ( settings, reporter, strtag, taglets );
- if ( this.sources != null ) {
- this.add_files( context );
- this.sources = null;
- if (Report.get_errors () > 0) {
- return quit ();
- }
- }
+ Valadoc.Tree doctree = new Valadoc.Tree ( settings, non_null_experimental, disable_non_null, disable_checking, basedir, directory );
- var parser = new Vala.Parser ();
- parser.parse ( context );
- if (Report.get_errors () > 0) {
+ if (!doctree.add_external_package ( vapi_directories, "glib-2.0" )) {
+ Report.error (null, "glib-2.0 not found in specified Vala API directories" );
return quit ();
}
- var resolver = new SymbolResolver ();
- resolver.resolve( context );
- if (Report.get_errors () > 0) {
+ if (!doctree.add_external_package ( vapi_directories, "gobject-2.0" )) {
+ Report.error (null, "gobject-2.0 not found in specified Vala API directories");
return quit ();
}
- var analyzer = new SemanticAnalyzer ( );
- analyzer.analyze( context );
- if (Report.get_errors () > 0) {
- return quit ();
+ if ( this.tpackages != null ) {
+ foreach (string package in this.tpackages ) {
+ if (!doctree.add_external_package ( vapi_directories, package )) {
+ Report.error (null, "%s not found in specified Vala API directories".printf (package));
+ return quit ();
+ }
+ }
+ this.tpackages = null;
}
- if (context.non_null_experimental) {
- var null_checker = new NullChecker ();
- null_checker.check (context);
+ if ( this.tsources != null ) {
+ foreach ( string src in this.tsources ) {
+ stdout.printf ( ">__>%s\n", src );
+ if ( !doctree.add_file ( src ) ) {
+ Report.error (null, "%s not found".printf (src));
+ return quit ();
+ }
+ }
+ this.tsources = null;
+ }
+/*
+ if ( this.sources != null ) {
+ this.add_files( context );
+ this.sources = null;
if (Report.get_errors () > 0) {
return quit ();
}
}
+*/
- Reporter reporter = new Reporter();
-
-
-
- string fulldirpath = (pluginpath == null)? Config.plugin_dir : pluginpath;
-
-
- bool tmp = this.check_doclet_structure ( pluginpath );
-
-
-
- if ( tmp == false ) {
- stdout.printf ( "Error: failed to load plugin.\n" );
- return 1;
- }
-
-
- Gee.HashMap<string, Type> taglets;
- GLib.Type strtag;
-
-
- tmp = this.load_taglets ( fulldirpath, out taglets, out strtag );
- if ( tmp == false ) {
- stdout.printf ( "Error: failed to load plugin.\n" );
- return 1;
- }
-
- Valadoc.Doclet doclet = this.load_doclet ( fulldirpath );
- if ( doclet == null ) {
- stdout.printf ( "Error: failed to load plugin.\n" );
- return 1;
- }
-
- Valadoc.Parser docparser = new Valadoc.Parser ();
- docparser.init ( settings, reporter, strtag, taglets );
-
-
- Valadoc.Tree doctree = new Valadoc.Tree ( settings, context );
- doctree.create_tree( );
- if ( reporter.errors > 0 )
+ if ( !doctree.create_tree( ) )
return quit ();
doctree.parse_comments ( docparser );
@@ -594,7 +533,7 @@
catch (OptionError e) {
stdout.printf ("%s\n", e.message);
stdout.printf ("Run '%s --help' to see a full list of available command line options.\n", args[0]);
- return 1;
+ return quit ();
}
if ( version ) {
@@ -602,14 +541,9 @@
return 0;
}
- if ( tsources == null ) {
- stderr.printf ("No source file specified.\n");
- return -1;
- }
-
if ( directory == null ) {
- stderr.printf ("No output directory specified.\n");
- return -1;
+ Report.error (null, "No output directory specified." );
+ return quit ();
}
if ( directory[ directory.len() - 1 ] != '/' ) {
@@ -621,8 +555,8 @@
remove_directory ( directory );
}
else {
- stderr.printf ("File already exists.\n");
- return -1;
+ Report.error (null, "File already exists." );
+ return quit ();
}
}
@@ -635,6 +569,11 @@
pluginpath = pluginpath + "/";
}
+ if ( !check_pkg_name () ) {
+ Report.error (null, "Invalid package name." );
+ return quit ();
+ }
+
var valadoc = new ValaDoc( );
valadoc.run();
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]