From: Didier "Ptitjes Date: Tue, 20 Oct 2009 00:15:07 +0000 (+0200) Subject: Html: Refactor BasicDoclet.write_*_content X-Git-Tag: 0.37.1~3^2~547 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd2a69b83fad8deec9074bc36ef1df5d7145d64c;p=thirdparty%2Fvala.git Html: Refactor BasicDoclet.write_*_content --- diff --git a/src/doclets/devhelp/doclet/doclet.vala b/src/doclets/devhelp/doclet/doclet.vala index c3d29b18d..b0415ac90 100755 --- a/src/doclets/devhelp/doclet/doclet.vala +++ b/src/doclets/devhelp/doclet/doclet.vala @@ -220,7 +220,7 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { this.devhelp = new DevhelpFormat ( settings.pkg_name, "" ); - this.write_wiki_pages ( tree, css_path_wiki, Path.build_filename(this.settings.path, this.settings.pkg_name, "content") ); + write_wiki_pages ( tree, css_path_wiki, Path.build_filename(this.settings.path, this.settings.pkg_name, "content") ); Gee.Collection packages = tree.get_package_list (); foreach ( Package pkg in packages ) { @@ -252,9 +252,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( filepath, "w" ); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, pkg_name); - this.write_file_content (package, package, wikipage); - this.write_file_footer (); + write_file_header (this.css_path, pkg_name); + write_package_content (package, package, wikipage); + write_file_footer (); file = null; package.visit_namespaces ( this ); @@ -270,9 +270,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w" ); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, ns.full_name()); - this.write_namespace_content (ns, ns); - this.write_file_footer (); + write_file_header (this.css_path, ns.full_name()); + write_namespace_content (ns, ns); + write_file_footer (); file = null; this.devhelp.add_keyword ( KeywordType.NAMESPACE, ns.name, path ); @@ -319,9 +319,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, iface.full_name()); - this.write_interface_content (iface, iface); - this.write_file_footer (); + write_file_header (this.css_path, iface.full_name()); + write_symbol_content (iface); + write_file_footer (); file = null; } @@ -350,9 +350,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, cl.full_name()); - this.write_class_content (cl, cl); - this.write_file_footer (); + write_file_header (this.css_path, cl.full_name()); + write_symbol_content (cl); + write_file_footer (); file = null; } @@ -375,9 +375,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, stru.full_name()); - this.write_struct_content (stru, stru); - this.write_file_footer (); + write_file_header (this.css_path, stru.full_name()); + write_symbol_content (stru); + write_file_footer (); file = null; } @@ -393,9 +393,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, errdom.full_name()); - this.write_error_domain_content (errdom, errdom); - this.write_file_footer (); + write_file_header (this.css_path, errdom.full_name()); + write_symbol_content (errdom); + write_file_footer (); file = null; } @@ -412,9 +412,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, en.full_name()); - this.write_enum_content (en, en); - this.write_file_footer (); + write_file_header (this.css_path, en.full_name()); + write_symbol_content (en); + write_file_footer (); file = null; } @@ -428,9 +428,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, prop.full_name()); - this.write_property_content (prop); - this.write_file_footer (); + write_file_header (this.css_path, prop.full_name()); + write_symbol_content (prop); + write_file_footer (); file = null; } @@ -444,9 +444,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, constant.full_name()); - this.write_constant_content (constant); - this.write_file_footer (); + write_file_header (this.css_path, constant.full_name()); + write_symbol_content (constant); + write_file_footer (); file = null; } @@ -460,9 +460,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, field.full_name()); - this.write_field_content (field); - this.write_file_footer (); + write_file_header (this.css_path, field.full_name()); + write_symbol_content (field); + write_file_footer (); file = null; } @@ -482,9 +482,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, del.full_name()); - this.write_delegate_content (del); - this.write_file_footer (); + write_file_header (this.css_path, del.full_name()); + write_symbol_content (del); + write_file_footer (); file = null; } @@ -498,9 +498,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, sig.full_name()); - write_signal_content (sig); - this.write_file_footer (); + write_file_header (this.css_path, sig.full_name()); + write_symbol_content (sig); + write_file_footer (); file = null; } @@ -514,9 +514,9 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, m.full_name()); - this.write_method_content (m); - this.write_file_footer (); + write_file_header (this.css_path, m.full_name()); + write_symbol_content (m); + write_file_footer (); file = null; } } diff --git a/src/doclets/htm/doclet/doclet.vala b/src/doclets/htm/doclet/doclet.vala index 28ea47bf0..f4b14193a 100755 --- a/src/doclets/htm/doclet/doclet.vala +++ b/src/doclets/htm/doclet/doclet.vala @@ -119,15 +119,15 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { DirUtils.create ( this.settings.path, 0777 ); copy_directory ( GLib.Path.build_filename ( Config.doclet_path, "deps" ), settings.path ); - this.write_wiki_pages ( tree, css_path_wiki, Path.build_filename(settings.path, "content") ); + write_wiki_pages ( tree, css_path_wiki, Path.build_filename(settings.path, "content") ); GLib.FileStream file = GLib.FileStream.open ( GLib.Path.build_filename ( settings.path, "index.html" ), "w" ); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path_package, settings.pkg_name); - this.write_navi_packages (tree); - this.write_packages_content (tree); - this.write_file_footer (); + write_file_header (this.css_path_package, settings.pkg_name); + write_navi_packages (tree); + write_package_index_content (tree); + write_file_footer (); file = null; Gee.Collection packages = tree.get_package_list (); @@ -146,10 +146,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( GLib.Path.build_filename ( path, "index.htm" ), "w" ); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, pkg_name); - this.write_navi_file (package, package); - this.write_file_content (package, package); - this.write_file_footer (); + write_file_header (this.css_path, pkg_name); + write_navi_file (package, package); + write_package_content (package, package); + write_file_footer (); file = null; package.visit_namespaces ( this ); @@ -162,10 +162,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w" ); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, ns.full_name()); - this.write_navi_namespace (ns); - this.write_namespace_content (ns, ns); - this.write_file_footer (); + write_file_header (this.css_path, ns.full_name()); + write_navi_namespace (ns); + write_namespace_content (ns, ns); + write_file_footer (); file = null; } @@ -198,10 +198,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, iface.full_name()); - this.write_navi_interface (iface, iface); - this.write_interface_content (iface, iface); - this.write_file_footer (); + write_file_header (this.css_path, iface.full_name()); + write_navi_interface (iface, iface); + write_symbol_content (iface); + write_file_footer (); file = null; } @@ -222,10 +222,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, cl.full_name()); - this.write_navi_class (cl, cl); - this.write_class_content (cl, cl); - this.write_file_footer (); + write_file_header (this.css_path, cl.full_name()); + write_navi_class (cl, cl); + write_symbol_content (cl); + write_file_footer (); file = null; } @@ -240,10 +240,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, stru.full_name()); - this.write_navi_struct (stru, stru); - this.write_struct_content (stru, stru); - this.write_file_footer (); + write_file_header (this.css_path, stru.full_name()); + write_navi_struct (stru, stru); + write_symbol_content (stru); + write_file_footer (); file = null; } @@ -255,10 +255,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, errdom.full_name()); - this.write_navi_error_domain (errdom, errdom); - this.write_error_domain_content (errdom, errdom); - this.write_file_footer (); + write_file_header (this.css_path, errdom.full_name()); + write_navi_error_domain (errdom, errdom); + write_symbol_content (errdom); + write_file_footer (); file = null; } @@ -271,10 +271,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, en.full_name()); - this.write_navi_enum (en, en); - this.write_enum_content (en, en); - this.write_file_footer (); + write_file_header (this.css_path, en.full_name()); + write_navi_enum (en, en); + write_symbol_content (en); + write_file_footer (); file = null; } @@ -284,10 +284,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, prop.full_name()); - this.write_navi_property (prop); - this.write_property_content (prop); - this.write_file_footer (); + write_file_header (this.css_path, prop.full_name()); + write_navi_property (prop); + write_symbol_content (prop); + write_file_footer (); file = null; } @@ -297,10 +297,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, constant.full_name()); - this.write_navi_constant (constant); - this.write_constant_content (constant); - this.write_file_footer (); + write_file_header (this.css_path, constant.full_name()); + write_navi_constant (constant); + write_symbol_content (constant); + write_file_footer (); file = null; } @@ -310,10 +310,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, field.full_name()); - this.write_navi_field (field); - this.write_field_content (field); - this.write_file_footer (); + write_file_header (this.css_path, field.full_name()); + write_navi_field (field); + write_symbol_content (field); + write_file_footer (); file = null; } @@ -329,10 +329,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, del.full_name()); - this.write_navi_delegate (del); - this.write_delegate_content (del); - this.write_file_footer (); + write_file_header (this.css_path, del.full_name()); + write_navi_delegate (del); + write_symbol_content (del); + write_file_footer (); file = null; } @@ -342,10 +342,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, sig.full_name()); - this.write_navi_signal (sig); - write_signal_content (sig); - this.write_file_footer (); + write_file_header (this.css_path, sig.full_name()); + write_navi_signal (sig); + write_symbol_content (sig); + write_file_footer (); file = null; } @@ -355,10 +355,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - this.write_file_header (this.css_path, m.full_name()); - this.write_navi_method (m); - this.write_method_content (m); - this.write_file_footer (); + write_file_header (this.css_path, m.full_name()); + write_navi_method (m); + write_symbol_content (m); + write_file_footer (); file = null; } } diff --git a/src/doclets/htmlhelpers/doclet/doclet.vala b/src/doclets/htmlhelpers/doclet/doclet.vala index 4214c0220..f10c5d3f4 100755 --- a/src/doclets/htmlhelpers/doclet/doclet.vala +++ b/src/doclets/htmlhelpers/doclet/doclet.vala @@ -21,7 +21,6 @@ using GLib; using Valadoc.Content; using Valadoc.Api; - public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { protected Settings settings; protected HtmlRenderer _renderer; @@ -723,8 +722,10 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { } private void write_signature (Api.Node element , Api.Node? pos) { + writer.start_tag ("div", css_code_definition); _renderer.set_container (pos); _renderer.render (element.signature); + writer.end_tag ("div"); } public void write_navi_packages_inline (Api.Tree tree) { @@ -751,7 +752,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { writer.end_tag ("div"); } - public void write_packages_content (Api.Tree tree) { + public void write_package_index_content (Api.Tree tree) { writer.start_tag ("div", css_style_content); writer.start_tag ("h1", css_title).text ("Packages:").end_tag ("h1"); writer.simple_tag ("hr", css_headline_hr); @@ -768,194 +769,54 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { writer.end_tag ("div"); } - public void write_method_content (Method m) { - string full_name = m.full_name (); - writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, full_name).text (m.name).end_tag ("h1"); - writer.simple_tag ("hr", css_headline_hr); - writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - writer.start_tag ("div", css_code_definition); - - this.write_signature (m, m); - - writer.end_tag ("div"); - - this.write_documentation (m, m); - - if (m.parent is Namespace) { - writer.simple_tag ("br"); - this.write_namespace_note (m); - this.write_package_note (m); - } - - writer.end_tag ("div"); - } - - public void write_child_error_values (ErrorDomain errdom) { - Gee.Collection error_codes = errdom.get_error_code_list (); - if (error_codes.size > 0) { - writer.start_tag ("h3", css_title).text ("Error Codes:").end_tag ("h3"); - writer.start_tag ("table", css_errordomain_table); - foreach (ErrorCode errcode in error_codes) { - writer.start_tag ("tr"); - - writer.start_tag ("td", css_errordomain_table_name, errcode.name); - writer.text (errcode.name); - writer.end_tag ("td"); - - writer.start_tag ("td", css_errordomain_table_text); - this.write_documentation (errcode, errcode); - writer.end_tag ("td"); - - writer.end_tag ("tr"); - } - writer.end_tag ("table"); - } - } - - public void write_signal_content (Api.Signal sig) { - string full_name = sig.full_name (); - writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, full_name).text (sig.name).end_tag ("h1"); - writer.simple_tag ("hr", css_headline_hr); - writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - writer.start_tag ("div", css_code_definition); - - this.write_signature (sig, sig); - - writer.end_tag ("div"); - this.write_documentation (sig, sig); - writer.end_tag ("div"); - } - - public void write_delegate_content (Delegate del) { - string full_name = del.full_name (); - writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, full_name).text (del.name).end_tag ("h1"); - writer.simple_tag ("hr", css_headline_hr); - writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - writer.start_tag ("div", css_code_definition); - - this.write_signature (del, del); - - writer.end_tag ("div"); - - this.write_documentation (del, del); - - if (del.parent is Namespace) { - writer.simple_tag ("br"); - this.write_namespace_note (del); - this.write_package_note (del); - } - - writer.end_tag ("div"); - } - - public void write_field_content (Field field) { - string full_name = field.full_name (); - writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, full_name).text (field.name).end_tag ("h1"); - writer.simple_tag ("hr", css_headline_hr); - writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - writer.start_tag ("div", css_code_definition); - - this.write_signature (field, field); - - writer.end_tag ("div"); - - this.write_documentation (field, field); - - if (field.parent is Namespace) { - writer.simple_tag ("br"); - this.write_namespace_note (field); - this.write_package_note (field); - } - - writer.end_tag ("div"); - } - - public void write_constant_content (Constant constant) { - string full_name = constant.full_name (); - writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, full_name).text (constant.name).end_tag ("h1"); - writer.simple_tag ("hr", css_headline_hr); - writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - writer.start_tag ("div", css_code_definition); - - this.write_signature (constant, constant); - - writer.end_tag ("div"); - - this.write_documentation (constant, constant); - - if (constant.parent is Namespace) { - writer.simple_tag ("br"); - this.write_namespace_note (constant); - this.write_package_note (constant); - } - - writer.end_tag ("div"); - } - - public void write_property_content (Property prop) { - string full_name = prop.full_name (); + public void write_symbol_content (Api.Node node) { + string full_name = node.full_name (); writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, full_name).text (prop.name).end_tag ("h1"); + writer.start_tag ("h1", css_title, full_name).text (node.name).end_tag ("h1"); writer.simple_tag ("hr", css_headline_hr); + this.write_image_block (node); writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - writer.start_tag ("div", css_code_definition); - - this.write_signature (prop, prop); + this.write_signature (node, node); + this.write_documentation (node, node); - writer.end_tag ("div"); - this.write_documentation (prop, prop); - writer.end_tag ("div"); - } - - public void write_enum_content (Enum en, Api.Node? parent) { - string full_name = en.full_name (); - writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, full_name).text (en.name).end_tag ("h1"); - writer.simple_tag ("hr", css_headline_hr); - writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - - this.write_documentation (en, en); - - if (en.parent is Namespace) { + if (node.parent is Namespace) { writer.simple_tag ("br"); - this.write_namespace_note (en); - this.write_package_note (en); + this.write_namespace_note (node); + this.write_package_note (node); + } + if (node.has_children ({ + Api.NodeType.ERROR_CODE, + Api.NodeType.ENUM_VALUE, + Api.NodeType.CREATION_METHOD, + Api.NodeType.STATIC_METHOD, + Api.NodeType.CLASS, + Api.NodeType.STRUCT, + Api.NodeType.ENUM, + Api.NodeType.DELEGATE, + Api.NodeType.METHOD, + Api.NodeType.SIGNAL, + Api.NodeType.PROPERTY, + Api.NodeType.FIELD, + Api.NodeType.CONSTANT + })) { + writer.start_tag ("h2", css_title).text ("Content:").end_tag ("h2"); + write_children_table (node, Api.NodeType.ERROR_CODE, "Error codes"); + write_children_table (node, Api.NodeType.ENUM_VALUE, "Enum values"); + write_children (node, Api.NodeType.CREATION_METHOD, "Creation methods", node); + write_children (node, Api.NodeType.STATIC_METHOD, "Static methods", node); + write_children (node, Api.NodeType.CLASS, "Classes", node); + write_children (node, Api.NodeType.STRUCT, "Structs", node); + write_children (node, Api.NodeType.ENUM, "Enums", node); + write_children (node, Api.NodeType.CONSTANT, "Constants", node); + write_children (node, Api.NodeType.PROPERTY, "Properties", node); + write_children (node, Api.NodeType.DELEGATE, "Delegates", node); + write_children (node, Api.NodeType.METHOD, "Methods", node); + write_children (node, Api.NodeType.SIGNAL, "Signals", node); + write_children (node, Api.NodeType.FIELD, "Fields", node); } - - writer.start_tag ("h2", css_title).text ("Content:").end_tag ("h2"); - this.write_child_enum_values (en); - this.write_child_static_methods (en, parent); - this.write_child_methods (en, parent); writer.end_tag ("div"); } - private void write_child_enum_values (Enum en) { - Gee.Collection enum_values = en.get_enum_values (); - if (enum_values.size > 0) { - writer.start_tag ("h3", css_title).text ("Enum Values:").end_tag ("h3"); - writer.start_tag ("table", css_enum_table); - foreach (Api.EnumValue enval in enum_values) { - writer.start_tag ("tr"); - - writer.start_tag ("td", css_enum_table_name, enval.name); - writer.text (enval.name); - writer.end_tag ("td"); - - writer.start_tag ("td", css_enum_table_text); - this.write_documentation (enval, en); - writer.end_tag ("td"); - - writer.end_tag ("tr"); - } - writer.end_tag ("table"); - } - } - protected void write_child_namespaces (NamespaceHandler nh, Api.Node? parent) { Gee.ArrayList nsl = new Gee.ArrayList (); this.fetch_subnamespace_names (nh, nsl); @@ -972,49 +833,28 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { writer.start_tag ("h3", css_title).text ("Namespaces:").end_tag ("h3"); writer.start_tag ("ul", css_inline_navigation); - foreach (Namespace ns in nsl) { - if (ns.name != null) { + foreach (Namespace child in nsl) { + if (child.name != null) { writer.start_tag ("li", css_namespace); - writer.link (get_link (ns, parent), ns.name); - this.write_brief_description (ns , parent); + writer.link (get_link (child, parent), child.name); + this.write_brief_description (child, parent); writer.end_tag ("li"); if (with_childs == true) { - this.write_child_classes (ns, parent); - this.write_child_interfaces (ns, parent); - this.write_child_structs (ns, parent); - this.write_child_enums (ns, parent); - this.write_child_errordomains (ns, parent); - this.write_child_delegates (ns, parent); - this.write_child_methods (ns, parent); - this.write_child_fields (ns, parent); - this.write_child_constants (ns, parent); + write_children (child, Api.NodeType.INTERFACE, "Interfaces", parent); + write_children (child, Api.NodeType.CLASS, "Classes", parent); + write_children (child, Api.NodeType.STRUCT, "Structs", parent); + write_children (child, Api.NodeType.ENUM, "Enums", parent); + write_children (child, Api.NodeType.ERROR_DOMAIN, "Error domains", parent); + write_children (child, Api.NodeType.DELEGATE, "Delegates", parent); + write_children (child, Api.NodeType.METHOD, "Methods", parent); + write_children (child, Api.NodeType.FIELD, "Fields", parent); + write_children (child, Api.NodeType.CONSTANT, "Constants", parent); } } } writer.end_tag ("ul"); } - protected void write_child_methods (MethodHandler mh, Api.Node? parent) { - Gee.Collection methods = mh.get_method_list (); - Gee.ArrayList imethods = new Gee.ArrayList (); - foreach (Method m in methods) { - if (!m.is_static) - imethods.add (m); - } - - if (imethods.size > 0) { - writer.start_tag ("h3", css_title).text ("Methods:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (Method m in imethods) { - writer.start_tag ("li", get_html_css_class (m)); - writer.link (get_link (m, parent), m.name); - this.write_brief_description (m , parent); - writer.end_tag ("li"); - } - writer.end_tag ("ul"); - } - } - protected void write_child_dependencies (Package package, Api.Node? parent) { Gee.Collection deps = package.get_full_dependency_list (); if (deps.size == 0) @@ -1035,148 +875,6 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { writer.end_tag ("ul"); } - protected void write_child_static_methods (MethodHandler mh, Api.Node? parent) { - Gee.Collection methods = mh.get_method_list (); - - Gee.ArrayList static_methods = new Gee.ArrayList (); - foreach (Method m in methods) { - if (m.is_static) - static_methods.add (m); - } - - if (static_methods.size > 0) { - writer.start_tag ("h3", css_title).text ("Static Methods:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (Method m in static_methods) { - writer.start_tag ("li", get_html_css_class (m)); - writer.link (get_link (m, parent), m.name); - this.write_brief_description (m , parent); - writer.end_tag ("li"); - } - writer.end_tag ("ul"); - } - } - - public void write_class_content (Class cl, Api.Node? parent) { - string full_name = cl.full_name (); - writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, full_name).text (cl.name).end_tag ("h1"); - writer.simple_tag ("hr", css_headline_hr); - this.write_image_block (cl); - writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - writer.start_tag ("div", css_code_definition); - - this.write_signature (cl, cl); - - writer.end_tag ("div"); - - this.write_documentation (cl, cl); - - if (cl.parent is Namespace) { - writer.simple_tag ("br"); - this.write_namespace_note (cl); - this.write_package_note (cl); - } - writer.start_tag ("h2", css_title).text ("Content:").end_tag ("h2"); - this.write_child_construction_methods (cl, parent); - this.write_child_static_methods (cl, parent); - this.write_child_classes (cl, parent); - this.write_child_structs (cl, parent); - this.write_child_enums (cl, parent); - this.write_child_delegates (cl, parent); - this.write_child_methods (cl, parent); - this.write_child_signals (cl, parent); - this.write_child_properties (cl, parent); - this.write_child_fields (cl, parent); - this.write_child_constants (cl, parent); - writer.end_tag ("div"); - } - - public void write_interface_content (Interface iface, Api.Node? parent) { - string full_name = iface.full_name (); - writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, full_name).text (iface.name).end_tag ("h1"); - writer.simple_tag ("hr", css_headline_hr); - this.write_image_block (iface); - writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - writer.start_tag ("div", css_code_definition); - - this.write_signature (iface, iface); - - writer.end_tag ("div"); - - this.write_documentation (iface, iface); - - if (iface.parent is Namespace) { - writer.simple_tag ("br"); - this.write_namespace_note (iface); - this.write_package_note (iface); - } - writer.start_tag ("h2", css_title).text ("Content:").end_tag ("h2"); - this.write_child_static_methods (iface, parent); - this.write_child_classes (iface, parent); - this.write_child_structs (iface, parent); - this.write_child_enums (iface, parent); - this.write_child_delegates (iface, parent); - this.write_child_methods (iface, parent); - this.write_child_signals (iface, parent); - this.write_child_properties (iface, parent); - this.write_child_fields (iface, parent); - this.write_child_constants (iface, parent); - writer.end_tag ("div"); - } - - public void write_error_domain_content (ErrorDomain errdom, Api.Node? parent) { - string full_name = errdom.full_name (); - writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, full_name).text (errdom.name).end_tag ("h1"); - writer.simple_tag ("hr", css_headline_hr); - writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - - this.write_documentation (errdom, errdom); - - if (errdom.parent is Namespace) { - writer.simple_tag ("br"); - this.write_namespace_note (errdom); - this.write_package_note (errdom); - } - writer.start_tag ("h2", css_title).text ("Content:").end_tag ("h2"); - this.write_child_error_values (errdom); - this.write_child_static_methods (errdom, parent); - this.write_child_methods (errdom, parent); - writer.end_tag ("div"); - } - - public void write_struct_content (Struct stru, Api.Node? parent) { - string full_name = stru.full_name (); - writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, full_name).text (stru.name).end_tag ("h1"); - writer.simple_tag ("hr", css_headline_hr); - this.write_image_block (stru); - writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - - writer.start_tag ("div", css_code_definition); - - this.write_signature (stru, stru); - - writer.end_tag ("div"); - - this.write_documentation (stru, stru); - - if (stru.parent is Namespace) { - writer.simple_tag ("br"); - this.write_namespace_note (stru); - this.write_package_note (stru); - } - writer.start_tag ("h2", css_title).text ("Content:").end_tag ("h2"); - this.write_child_construction_methods (stru, parent); - this.write_child_static_methods (stru, parent); - this.write_child_methods (stru, parent); - this.write_child_fields (stru, parent); - this.write_child_constants (stru, parent); - writer.end_tag ("div"); - } - protected string get_img_path (Api.Node element) { return "img/" + element.full_name () + ".png"; } @@ -1185,67 +883,48 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { return this.settings.path + "/" + element.package.name + "/" + "img/" + element.full_name () + ".png"; } - protected void write_child_constants (ConstantHandler ch, Api.Node? parent) { - Gee.Collection constants = ch.get_constant_list (); - if (constants.size > 0) { - writer.start_tag ("h3", css_title).text ("Constants:").end_tag ("h3"); + protected void write_children (Api.Node node, Api.NodeType type, string type_string, Api.Node? container) { + var children = node.get_children_by_type (type); + if (children.size > 0) { + writer.start_tag ("h3", css_title).text (type_string).text (":").end_tag ("h3"); writer.start_tag ("ul", css_inline_navigation); - foreach (Constant c in constants) { - writer.start_tag ("li", get_html_css_class (c)); - writer.link (get_link (c, parent), c.name); - this.write_brief_description (c, parent); + foreach (Api.Node child in children) { + writer.start_tag ("li", get_html_css_class (child)); + writer.link (get_link (child, container), child.name); + this.write_brief_description (child, container); writer.end_tag ("li"); } writer.end_tag ("ul"); } } - protected void write_child_enums (EnumHandler eh, Api.Node? parent) { - Gee.Collection enums = eh.get_enum_list (); - if (enums.size > 0) { - writer.start_tag ("h3", css_title).text ("Enums:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (Enum en in enums) { - writer.start_tag ("li", get_html_css_class (en)); - writer.link (get_link (en, parent), en.name); - this.write_brief_description (en, parent); - writer.end_tag ("li"); - } - writer.end_tag ("ul"); - } - } + private void write_children_table (Api.Node node, Api.NodeType type, string type_string) { + Gee.Collection children = node.get_children_by_type (Api.NodeType.ENUM_VALUE); + if (children.size > 0) { + writer.start_tag ("h3", css_title).text (type_string).text (":").end_tag ("h3"); + writer.start_tag ("table", get_html_css_class (node)); + foreach (Api.Node child in children) { + writer.start_tag ("tr"); - protected void write_child_errordomains (ErrorDomainHandler eh, Api.Node? parent) { - Gee.Collection errdoms = eh.get_error_domain_list (); - if (errdoms.size > 0) { - writer.start_tag ("h3", css_title).text ("Errordomains:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (ErrorDomain err in errdoms) { - writer.start_tag ("li", get_html_css_class (err)); - writer.link (get_link (err, parent), err.name); - this.write_brief_description (err, parent); - writer.end_tag ("li"); - } - writer.end_tag ("ul"); - } - } + writer.start_tag ("td", get_html_css_class (child), child.name); + writer.text (child.name); + writer.end_tag ("td"); - protected void write_child_construction_methods (ConstructionMethodHandler cmh, Api.Node? parent) { - Gee.Collection methods = cmh.get_construction_method_list (); - if (methods.size > 0) { - writer.start_tag ("h3", css_title).text ("Construction Methods:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (Method m in methods) { - writer.start_tag ("li", get_html_css_class (m)); - writer.link (get_link (m, parent), m.name); - this.write_brief_description (m, parent); - writer.end_tag ("li"); + writer.start_tag ("td"); + this.write_documentation (child, node); + writer.end_tag ("td"); + + writer.end_tag ("tr"); } - writer.end_tag ("ul"); + writer.end_tag ("table"); } } protected void write_image_block (Api.Node element) { + if (!(element is Class || element is Interface || element is Struct)) { + return; + } + string realimgpath = this.get_img_real_path (element); string imgpath = this.get_img_path (element); @@ -1263,141 +942,36 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { writer.image (imgpath, "Object hierarchy for %s".printf (element.name), css_diagram); } - protected void write_child_fields (FieldHandler fh, Api.Node? parent) { - Gee.Collection fields = fh.get_field_list (); - if (fields.size > 0) { - writer.start_tag ("h3", css_title).text ("Fields:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (Field f in fields) { - writer.start_tag ("li", get_html_css_class(f)); - writer.link (get_link (f, parent), f.name); - this.write_brief_description (f, parent); - writer.end_tag ("li"); - } - writer.end_tag ("ul"); - } - } - - protected void write_child_properties (PropertyHandler ph, Api.Node? parent) { - Gee.Collection properties = ph.get_property_list (); - if (properties.size > 0) { - writer.start_tag ("h3", css_title).text ("Properties:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (Property prop in properties) { - writer.start_tag ("li", get_html_css_class (prop)); - writer.link (get_link (prop, parent), prop.name); - this.write_brief_description (prop, parent); - writer.end_tag ("li"); - } - writer.end_tag ("ul"); - } - } - - protected void write_child_signals (Api.SignalHandler sh, Api.Node? parent) { - Gee.Collection signals = sh.get_signal_list (); - if (signals.size > 0) { - writer.start_tag ("h3", css_title).text ("Api.Signals:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (Api.Signal sig in signals) { - writer.start_tag ("li", get_html_css_class (sig)); - writer.link (get_link (sig, parent), sig.name); - this.write_brief_description (sig, parent); - writer.end_tag ("li"); - } - writer.end_tag ("ul"); - } - } - - protected void write_child_classes (ClassHandler clh, Api.Node? parent) { - Gee.Collection classes = clh.get_class_list (); - if (classes.size > 0) { - writer.start_tag ("h3", css_title).text ("Classes:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (Class subcl in classes) { - writer.start_tag ("li", get_html_css_class (subcl)); - writer.link (get_link (subcl, parent), subcl.name); - this.write_brief_description (subcl, parent); - writer.end_tag ("li"); - } - writer.end_tag ("ul"); - } - } - - protected void write_child_interfaces (InterfaceHandler ih, Api.Node? parent) { - Gee.Collection ifaces = ih.get_interface_list (); - if (ifaces.size > 0) { - writer.start_tag ("h3", css_title).text ("Interfaces:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (Interface iface in ifaces) { - writer.start_tag ("li", get_html_css_class (iface)); - writer.link (get_link (iface, parent), iface.name); - this.write_brief_description (iface, parent); - writer.end_tag ("li"); - } - writer.end_tag ("ul"); - } - } - - protected void write_child_delegates (DelegateHandler dh, Api.Node? parent) { - Gee.Collection delegates = dh.get_delegate_list (); - if (delegates.size > 0) { - writer.start_tag ("h3", css_title).text ("Delegates:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (Delegate d in delegates) { - writer.start_tag ("li", get_html_css_class (d)); - writer.link (get_link (d, parent), d.name); - this.write_brief_description (d, parent); - writer.end_tag ("li"); - } - writer.end_tag ("ul"); - } - } - - protected void write_child_structs (StructHandler struh, Api.Node? parent) { - Gee.Collection structs = struh.get_struct_list (); - if (structs.size > 0) { - writer.start_tag ("h3", css_title).text ("Structs:").end_tag ("h3"); - writer.start_tag ("ul", css_inline_navigation); - foreach (Struct stru in structs) { - writer.start_tag ("li", get_html_css_class (stru)); - writer.link (get_link (stru, parent), stru.name); - this.write_brief_description (stru, parent); - writer.end_tag ("li"); - } - writer.end_tag ("ul"); - } - } - - public void write_namespace_content (Namespace ns, Api.Node? parent) { + public void write_namespace_content (Namespace node, Api.Node? parent) { writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title).text (ns.name == null ? "Global Namespace" : ns.full_name ()).end_tag ("h1"); + writer.start_tag ("h1", css_title).text (node.name == null ? "Global Namespace" : node.full_name ()).end_tag ("h1"); writer.simple_tag ("hr", css_hr); writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); - this.write_documentation (ns, ns); + this.write_documentation (node, parent); writer.start_tag ("h2", css_title).text ("Content:").end_tag ("h2"); - if (ns.name == null) - this.write_child_namespaces ((Package)ns.parent, parent); + if (node.name == null) + this.write_child_namespaces ((Package) node.parent, parent); else - this.write_child_namespaces (ns, parent); - - this.write_child_classes (ns, parent); - this.write_child_interfaces (ns, parent); - this.write_child_structs (ns, parent); - this.write_child_enums (ns, parent); - this.write_child_errordomains (ns, parent); - this.write_child_delegates (ns, parent); - this.write_child_methods (ns, parent); - this.write_child_fields (ns, parent); - this.write_child_constants (ns, parent); + this.write_child_namespaces (node, parent); + + write_children (node, Api.NodeType.INTERFACE, "Interfaces", parent); + write_children (node, Api.NodeType.CLASS, "Classes", parent); + write_children (node, Api.NodeType.STRUCT, "Structs", parent); + write_children (node, Api.NodeType.ENUM, "Enums", parent); + write_children (node, Api.NodeType.ERROR_DOMAIN, "Error domains", parent); + write_children (node, Api.NodeType.DELEGATE, "Delegates", parent); + write_children (node, Api.NodeType.METHOD, "Methods", parent); + write_children (node, Api.NodeType.FIELD, "Fields", parent); + write_children (node, Api.NodeType.CONSTANT, "Constants", parent); writer.end_tag ("div"); } - protected void write_file_content (Package f, Api.Node? parent, WikiPage? wikipage = null) { + protected void write_package_content (Package node, Api.Node? parent, WikiPage? wikipage = null) { writer.start_tag ("div", css_style_content); - writer.start_tag ("h1", css_title, f.name).text (f.name).end_tag ("h1"); + writer.start_tag ("h1", css_title, node.name).text (node.name).end_tag ("h1"); writer.simple_tag ("hr", css_headline_hr); writer.start_tag ("h2", css_title).text ("Description:").end_tag ("h2"); @@ -1408,23 +982,23 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { writer.start_tag ("h2", css_title).text ("Content:").end_tag ("h2"); - this.write_child_namespaces (f, parent); - - foreach (Namespace ns in f.get_namespace_list()) { - if (ns.name == null) { - this.write_child_classes (ns, parent); - this.write_child_interfaces (ns, parent); - this.write_child_structs (ns, parent); - this.write_child_enums (ns, parent); - this.write_child_errordomains (ns, parent); - this.write_child_delegates (ns, parent); - this.write_child_methods (ns, parent); - this.write_child_fields (ns, parent); - this.write_child_constants (ns, parent); + this.write_child_namespaces (node, parent); + + foreach (Api.Node child in node.get_children_by_type (Api.NodeType.NAMESPACE)) { + if (child.name == null) { + write_children (child, Api.NodeType.INTERFACE, "Interfaces", parent); + write_children (child, Api.NodeType.CLASS, "Classes", parent); + write_children (child, Api.NodeType.STRUCT, "Structs", parent); + write_children (child, Api.NodeType.ENUM, "Enums", parent); + write_children (child, Api.NodeType.ERROR_DOMAIN, "Error domains", parent); + write_children (child, Api.NodeType.DELEGATE, "Delegates", parent); + write_children (child, Api.NodeType.METHOD, "Methods", parent); + write_children (child, Api.NodeType.FIELD, "Fields", parent); + write_children (child, Api.NodeType.CONSTANT, "Constants", parent); } } - this.write_child_dependencies (f, parent); + this.write_child_dependencies (node, parent); writer.end_tag ("div"); } diff --git a/src/libvaladoc/api/method.vala b/src/libvaladoc/api/method.vala index 377c89d30..3e02aeb82 100644 --- a/src/libvaladoc/api/method.vala +++ b/src/libvaladoc/api/method.vala @@ -195,7 +195,8 @@ public class Valadoc.Api.Method : Member, ParameterListHandler, ExceptionHandler public override NodeType node_type { get { - return is_constructor ? NodeType.CREATION_METHOD : NodeType.METHOD; + return is_constructor ? NodeType.CREATION_METHOD : + is_static ? NodeType.STATIC_METHOD : NodeType.METHOD; } } @@ -203,3 +204,4 @@ public class Valadoc.Api.Method : Member, ParameterListHandler, ExceptionHandler visitor.visit_method (this); } } + diff --git a/src/libvaladoc/api/node.vala b/src/libvaladoc/api/node.vala index 9b458a68f..99efbf8de 100644 --- a/src/libvaladoc/api/node.vala +++ b/src/libvaladoc/api/node.vala @@ -41,6 +41,7 @@ public enum Valadoc.Api.NodeType { PROPERTY, PROPERTY_ACCESSOR, SIGNAL, + STATIC_METHOD, STRUCT, TYPE_PARAMETER } @@ -107,6 +108,20 @@ public abstract class Valadoc.Api.Node : Item, Visitable, Documentation { } } + public bool has_children_by_type (NodeType type) { + Gee.List all_children = per_type_children.get (type); + return all_children != null && !all_children.is_empty; + } + + public bool has_children (NodeType[] types) { + foreach (NodeType type in types) { + if (has_children_by_type (type)) { + return true; + } + } + return false; + } + public Gee.List get_children_by_type (NodeType type, bool filtered = true) { var children = new ArrayList (); @@ -210,3 +225,4 @@ public abstract class Valadoc.Api.Node : Item, Visitable, Documentation { return this._full_name; } } +