[valadoc] - devhelp-doclet: package documentation support
- From: Florian Brosch <flobrosch src gnome org>
- To: svn-commits-list gnome org
- Subject: [valadoc] - devhelp-doclet: package documentation support
- Date: Mon, 22 Jun 2009 18:08:52 -0400 (EDT)
commit ed35d60421f209c1d9452edc10aa7d21010aa608
Author: Florian Brosch <flo brosch gmail com>
Date: Mon Jun 22 01:42:57 2009 +0200
- devhelp-doclet: package documentation support
src/doclets/devhelp/doclet/doclet.vala | 92 ++++++++++++++++++++++++++-
src/doclets/htm/doclet/doclet.vala | 86 +++++++++++++++++++++++--
src/doclets/htmlhelpers/doclet/doclet.vala | 10 ++-
src/doclets/htmlhelpers/doclet/globals.vala | 76 ++--------------------
4 files changed, 184 insertions(+), 80 deletions(-)
---
diff --git a/src/doclets/devhelp/doclet/doclet.vala b/src/doclets/devhelp/doclet/doclet.vala
index 6713508..8a4a593 100644
--- a/src/doclets/devhelp/doclet/doclet.vala
+++ b/src/doclets/devhelp/doclet/doclet.vala
@@ -24,6 +24,83 @@ using Xml;
using Gee;
+namespace Valadoc.Devhelp {
+ public string? get_html_link ( Settings settings, Documented element, Documented? pos ) {
+ if ( element is Visitable ) {
+ if ( ((Visitable)element).is_visitor_accessible () == false ) {
+ return null;
+ }
+ }
+
+ if ( element is DocumentedElement ) {
+ if ( ((DocumentedElement)element).package.is_visitor_accessible () == false ) {
+ return null;
+ }
+ }
+
+ if ( pos == null || ((pos!=null)?(pos is WikiPage)? ((WikiPage)pos).name=="index.valadoc": false : false) ) {
+ if ( element is Package ) {
+ return Path.build_filename(((Package)element).name, "index.htm");
+ }
+ else if ( element is DocumentedElement ) {
+ return Path.build_filename("..", ((DocumentedElement)element).package.name, ((DocumentedElement)element).full_name()+".html" );
+ }
+ else if ( element is WikiPage ) {
+ if ( pos == element ) {
+ return "#";
+ }
+ else {
+ string wikiname = ((WikiPage)element).name;
+ wikiname = wikiname.ndup ( wikiname.len()-8 );
+ wikiname = wikiname.replace("/", ".") + ".html";
+ return Path.build_filename( "content", wikiname );
+ }
+ }
+ }
+ else if ( pos is DocumentedElement ) {
+ if ( element is Package ) {
+ return Path.build_filename("..", ((Package)element).name, "index.htm");
+ }
+ else if ( element is DocumentedElement ) {
+ return Path.build_filename( "..", ((DocumentedElement)element).package.name, ((DocumentedElement)element).full_name()+".html" );
+ }
+ else if ( element is WikiPage ) {
+ string wikiname = ((WikiPage)element).name;
+ wikiname = wikiname.ndup ( wikiname.len()-8 );
+ wikiname = wikiname.replace("/", ".")+".html";
+ if ( wikiname == "index.html" ) {
+ return Path.build_filename( "..", wikiname );
+ }
+ else {
+ return Path.build_filename( "..", "content", wikiname );
+ }
+ }
+ }
+ else if ( pos is WikiPage ) {
+ if ( element is Package ) {
+ return Path.build_filename("..", ((Package)element).name, "index.htm");
+ }
+ else if ( element is DocumentedElement ) {
+ return Path.build_filename( "..", ((DocumentedElement)element).package.name, ((DocumentedElement)element).full_name()+".html" );
+ }
+ else if ( element is WikiPage ) {
+ string wikiname = ((WikiPage)element).name;
+ wikiname = wikiname.ndup ( wikiname.len()-8 );
+ wikiname = wikiname.replace("/", ".")+".html";
+
+ if ( wikiname == "index.html" ) {
+ return Path.build_filename("..", wikiname);
+ }
+ else {
+ return wikiname;
+ }
+ }
+ }
+ return null;
+ }
+}
+
+
public enum Valadoc.Devhelp.KeywordType {
NAMESPACE = 0,
@@ -121,9 +198,11 @@ public class Valadoc.Devhelp.DevhelpFormat : Object {
public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
- private const string css_path = "style.css";
+ private const string css_path_wiki = "../wikistyle.css";
+ private const string css_path = "wikistyle.css";
private string package_dir_name = ""; // remove
private DevhelpFormat devhelp;
+ private Tree tree;
private string get_path ( DocumentedElement element ) {
return element.full_name () + ".html";
@@ -135,12 +214,15 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
public override void initialisation ( Settings settings, Tree tree ) {
this.settings = settings;
+ this.tree = tree;
DirUtils.create ( this.settings.path, 0777 );
this.langlet = new Valadoc.Html.BasicLanglet ( settings );
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") );
+
Gee.ReadOnlyCollection<Package> packages = tree.get_package_list ();
foreach ( Package pkg in packages ) {
pkg.visit ( this );
@@ -155,6 +237,11 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
string imgpath = GLib.Path.build_filename ( path, "img" );
string devpath = GLib.Path.build_filename ( path, pkg_name + ".devhelp2" );
+ WikiPage wikipage = null;
+ if ( this.settings.pkg_name == file.name && this.tree.wikitree != null ) {
+ wikipage = this.tree.wikitree.search ("index.valadoc");
+ }
+
this.package_dir_name = pkg_name;
@@ -166,7 +253,7 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
GLib.FileStream ifile = GLib.FileStream.open ( filepath, "w" );
this.write_file_header ( ifile, this.css_path, pkg_name );
- this.write_file_content ( ifile, file, file );
+ this.write_file_content ( ifile, file, file, wikipage );
this.write_file_footer ( ifile );
ifile = null;
@@ -416,6 +503,7 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
[ModuleInit]
public Type register_plugin ( ) {
+ Valadoc.Html.get_html_link_imp = Valadoc.Devhelp.get_html_link;
return typeof ( Valadoc.Devhelp.Doclet );
}
diff --git a/src/doclets/htm/doclet/doclet.vala b/src/doclets/htm/doclet/doclet.vala
index 48b5385..83dea1a 100644
--- a/src/doclets/htm/doclet/doclet.vala
+++ b/src/doclets/htm/doclet/doclet.vala
@@ -23,11 +23,86 @@ using GLib;
using Gee;
+namespace Valadoc {
+ public string? get_html_link ( Settings settings, Documented element, Documented? pos ) {
+ if ( element is Visitable ) {
+ if ( ((Visitable)element).is_visitor_accessible () == false ) {
+ return null;
+ }
+ }
+
+ if ( element is DocumentedElement ) {
+ if ( ((DocumentedElement)element).package.is_visitor_accessible () == false ) {
+ return null;
+ }
+ }
+
+ if ( pos == null || ((pos!=null)?(pos is WikiPage)? ((WikiPage)pos).name=="index.valadoc": false : false) ) {
+ if ( element is Package ) {
+ return Path.build_filename(((Package)element).name, "index.htm");
+ }
+ else if ( element is DocumentedElement ) {
+ return Path.build_filename( ((DocumentedElement)element).package.name, ((DocumentedElement)element).full_name()+".html" );
+ }
+ else if ( element is WikiPage ) {
+ if ( pos == element ) {
+ return "#";
+ }
+ else {
+ string wikiname = ((WikiPage)element).name;
+ wikiname = wikiname.ndup ( wikiname.len()-8 );
+ wikiname = wikiname.replace("/", ".") + ".html";
+ return Path.build_filename( "content", wikiname );
+ }
+ }
+ }
+ else if ( pos is DocumentedElement ) {
+ if ( element is Package ) {
+ return Path.build_filename("..", ((Package)element).name, "index.htm");
+ }
+ else if ( element is DocumentedElement ) {
+ return Path.build_filename( "..", ((DocumentedElement)element).package.name, ((DocumentedElement)element).full_name()+".html" );
+ }
+ else if ( element is WikiPage ) {
+ string wikiname = ((WikiPage)element).name;
+ wikiname = wikiname.ndup ( wikiname.len()-8 );
+ wikiname = wikiname.replace("/", ".")+".html";
+ if ( wikiname == "index.html" ) {
+ return Path.build_filename( "..", wikiname );
+ }
+ else {
+ return Path.build_filename( "..", "content", wikiname );
+ }
+ }
+ }
+ else if ( pos is WikiPage ) {
+ if ( element is Package ) {
+ return Path.build_filename("..", ((Package)element).name, "index.htm");
+ }
+ else if ( element is DocumentedElement ) {
+ return Path.build_filename( "..", ((DocumentedElement)element).package.name, ((DocumentedElement)element).full_name()+".html" );
+ }
+ else if ( element is WikiPage ) {
+ string wikiname = ((WikiPage)element).name;
+ wikiname = wikiname.ndup ( wikiname.len()-8 );
+ wikiname = wikiname.replace("/", ".")+".html";
+
+ if ( wikiname == "index.html" ) {
+ return Path.build_filename("..", wikiname);
+ }
+ else {
+ return wikiname;
+ }
+ }
+ }
+ return null;
+ }
+}
public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet {
private const string css_path_package = "style.css";
- private const string css_path_wiki = "../wikistyle.css";
+ private const string css_path_wiki = "../style.css";
private const string css_path = "../style.css";
private string get_real_path ( DocumentedElement element ) {
@@ -38,12 +113,12 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet {
this.settings = settings;
DirUtils.create ( this.settings.path, 0777 );
- copy_directory ( GLib.Path.build_filename ( Config.doclet_path, "deps" ), this.settings.path );
+ copy_directory ( GLib.Path.build_filename ( Config.doclet_path, "deps" ), settings.path );
- this.write_wiki_pages ( tree, css_path_wiki );
+ this.write_wiki_pages ( tree, css_path_wiki, Path.build_filename(settings.path, "content") );
- GLib.FileStream file = GLib.FileStream.open ( GLib.Path.build_filename ( this.settings.path, "index.html" ), "w" );
- this.write_file_header ( file, this.css_path_package, this.settings.pkg_name );
+ GLib.FileStream file = GLib.FileStream.open ( GLib.Path.build_filename ( settings.path, "index.html" ), "w" );
+ this.write_file_header ( file, this.css_path_package, settings.pkg_name );
this.write_navi_packages ( file, tree );
this.write_packages_content ( file, tree );
this.write_file_footer ( file );
@@ -264,6 +339,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet {
[ModuleInit]
public Type register_plugin ( ) {
+ Valadoc.Html.get_html_link_imp = Valadoc.get_html_link;
return typeof ( Valadoc.HtmlDoclet );
}
diff --git a/src/doclets/htmlhelpers/doclet/doclet.vala b/src/doclets/htmlhelpers/doclet/doclet.vala
index 318d6c0..0981756 100644
--- a/src/doclets/htmlhelpers/doclet/doclet.vala
+++ b/src/doclets/htmlhelpers/doclet/doclet.vala
@@ -64,7 +64,7 @@ public abstract class Valadoc.Html.BasicDoclet : Valadoc.Doclet {
this.write_navi_entry_html_template ( file, style, name );
}
- protected void write_wiki_pages (Tree tree, string css_path_wiki) {
+ protected void write_wiki_pages (Tree tree, string css_path_wiki, string contentp) {
if ( tree.wikitree == null ) {
return ;
}
@@ -78,7 +78,6 @@ public abstract class Valadoc.Html.BasicDoclet : Valadoc.Doclet {
return ;
}
- string contentp = Path.build_filename (this.settings.path, "content");
DirUtils.create (contentp, 0777);
DirUtils.create (Path.build_filename (contentp, "img"), 0777);
@@ -1348,11 +1347,16 @@ public abstract class Valadoc.Html.BasicDoclet : Valadoc.Doclet {
file.puts ( "\t\t\t</div>\n" );
}
- protected void write_file_content ( GLib.FileStream file, Package f, DocumentedElement? mself ) {
+ protected void write_file_content ( GLib.FileStream file, Package f, DocumentedElement? mself, WikiPage? wikipage = null) {
file.printf ( "\t\t\t<div class=\"%s\">\n", css_style_content );
file.printf ( "\t\t\t\t<h1 class=\"%s\">%s:</h1>\n", css_title, f.name );
file.printf ( "\t\t\t\t<hr class=\"%s\" />\n", css_headline_hr );
file.printf ( "\t\t\t\t<h2 class=\"%s\">Description:</h2>\n", css_title );
+
+ if (wikipage != null) {
+ wikipage.write (file);
+ }
+
file.printf ( "\n\t\t\t\t<h2 class=\"%s\">Content:</h2>\n", css_title );
this.write_child_namespaces ( file, f, mself );
diff --git a/src/doclets/htmlhelpers/doclet/globals.vala b/src/doclets/htmlhelpers/doclet/globals.vala
index 5b02575..72ecb30 100644
--- a/src/doclets/htmlhelpers/doclet/globals.vala
+++ b/src/doclets/htmlhelpers/doclet/globals.vala
@@ -134,78 +134,14 @@ namespace Valadoc.Html {
public const string css_content_link_construction_method = "css_content_link_construction_method";
- public string? get_html_link ( Settings settings, Documented element, Documented? pos ) {
- if ( element is Visitable ) {
- if ( ((Visitable)element).is_visitor_accessible () == false ) {
- return null;
- }
- }
+ public delegate string? HtmlLink (Settings settings, Documented element, Documented? pos);
+ public HtmlLink get_html_link_imp;
- if ( element is DocumentedElement ) {
- if ( ((DocumentedElement)element).package.is_visitor_accessible () == false ) {
- return null;
- }
+ public string? get_html_link ( Settings settings, Documented element, Documented? pos ) {
+ if (get_html_link_imp == null) {
+ return null;
}
-
- if ( pos == null || ((pos!=null)?(pos is WikiPage)? ((WikiPage)pos).name=="index.valadoc": false : false) ) {
- if ( element is Package ) {
- return Path.build_filename(((Package)element).name, "index.htm");
- }
- else if ( element is DocumentedElement ) {
- return Path.build_filename( ((DocumentedElement)element).package.name, ((DocumentedElement)element).full_name()+".html" );
- }
- else if ( element is WikiPage ) {
- if ( pos == element ) {
- return "#";
- }
- else {
- string wikiname = ((WikiPage)element).name;
- wikiname = wikiname.ndup ( wikiname.len()-8 );
- wikiname = wikiname.replace("/", ".") + ".html";
- return Path.build_filename( "content", wikiname );
- }
- }
- }
- else if ( pos is DocumentedElement ) {
- if ( element is Package ) {
- return Path.build_filename("..", ((Package)element).name, "index.htm");
- }
- else if ( element is DocumentedElement ) {
- return Path.build_filename( "..", ((DocumentedElement)element).package.name, ((DocumentedElement)element).full_name()+".html" );
- }
- else if ( element is WikiPage ) {
- string wikiname = ((WikiPage)element).name;
- wikiname = wikiname.ndup ( wikiname.len()-8 );
- wikiname = wikiname.replace("/", ".")+".html";
- if ( wikiname == "index.html" ) {
- return Path.build_filename( "..", wikiname );
- }
- else {
- return Path.build_filename( "..", "content", wikiname );
- }
- }
- }
- else if ( pos is WikiPage ) {
- if ( element is Package ) {
- return Path.build_filename("..", ((Package)element).name, "index.htm");
- }
- else if ( element is DocumentedElement ) {
- return Path.build_filename( "..", ((DocumentedElement)element).package.name, ((DocumentedElement)element).full_name()+".html" );
- }
- else if ( element is WikiPage ) {
- string wikiname = ((WikiPage)element).name;
- wikiname = wikiname.ndup ( wikiname.len()-8 );
- wikiname = wikiname.replace("/", ".")+".html";
-
- if ( wikiname == "index.html" ) {
- return Path.build_filename("..", wikiname);
- }
- else {
- return wikiname;
- }
- }
- }
- return null;
+ return get_html_link_imp(settings, element, pos);
}
public string get_html_type_link (Settings settings, Documented element, Documented? pos) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]