[valadoc] doclets/devhelp: Add full wiki-support
- From: Florian Brosch <flobrosch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] doclets/devhelp: Add full wiki-support
- Date: Fri, 27 Jan 2012 16:46:42 +0000 (UTC)
commit 117bd32510ed29f46d2fc5c69fa0d2aeed80abe2
Author: Florian Brosch <flo brosch gmail com>
Date: Fri Jan 27 03:05:32 2012 +0100
doclets/devhelp: Add full wiki-support
src/doclets/devhelp/doclet.vala | 15 ++++--------
src/doclets/htm/doclet.vala | 37 ++++++++++++++++++++++++++++-
src/libvaladoc/html/basicdoclet.vala | 8 ++++--
src/libvaladoc/html/linkhelper.vala | 42 +++++++++++++--------------------
4 files changed, 62 insertions(+), 40 deletions(-)
---
diff --git a/src/doclets/devhelp/doclet.vala b/src/doclets/devhelp/doclet.vala
index 4d523f8..2fa91f8 100755
--- a/src/doclets/devhelp/doclet.vala
+++ b/src/doclets/devhelp/doclet.vala
@@ -1,6 +1,6 @@
/* doclet.vala
*
- * Copyright (C) 2008-2009 Florian Brosch
+ * Copyright (C) 2008-2012 Florian Brosch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -28,10 +28,10 @@ using Gee;
public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
- private const string css_path_wiki = "../devhelpstyle.css";
+ private const string css_path_wiki = "devhelpstyle.css";
private const string css_path = "devhelpstyle.css";
- private const string js_path_wiki = "../scripts.js";
+ private const string js_path_wiki = "scripts.js";
private const string js_path = "scripts.js";
@@ -56,7 +56,7 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
public override void process (Settings settings, Api.Tree tree, ErrorReporter reporter) {
base.process (settings, tree, reporter);
DirUtils.create_with_parents (this.settings.path, 0777);
- write_wiki_pages (tree, css_path_wiki, js_path_wiki, Path.build_filename (this.settings.path, this.settings.pkg_name, "content"));
+ write_wiki_pages (tree, css_path_wiki, js_path_wiki, Path.build_filename (this.settings.path, this.settings.pkg_name));
tree.accept (this);
}
@@ -76,11 +76,6 @@ 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 == package.name && this.tree.wikitree != null) {
- wikipage = this.tree.wikitree.search ("index.valadoc");
- }
-
this.package_dir_name = pkg_name;
var rt = DirUtils.create (path, 0777);
@@ -97,7 +92,7 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
writer = new Html.MarkupWriter (file);
_renderer.set_writer (writer);
write_file_header (this.css_path, this.js_path, pkg_name);
- write_package_content (package, package, wikipage);
+ write_package_content (package, package);
write_file_footer ();
file = null;
diff --git a/src/doclets/htm/doclet.vala b/src/doclets/htm/doclet.vala
index 7613f17..ba6f7fe 100755
--- a/src/doclets/htm/doclet.vala
+++ b/src/doclets/htm/doclet.vala
@@ -1,6 +1,6 @@
/* doclet.vala
*
- * Copyright (C) 2008-2009 Florian Brosch
+ * Copyright (C) 2008-2012 Florian Brosch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -37,6 +37,36 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet {
private const string js_path_wiki = "../scripts.js";
private const string js_path = "../scripts.js";
+ private class IndexLinkHelper : LinkHelper {
+ protected override string? from_wiki_to_package (WikiPage from, Api.Package to) {
+ if (from.name != "index.valadoc") {
+ return base.from_wiki_to_package (from, to);;
+ }
+
+ return Path.build_filename (to.name, to.name + ".htm");
+ }
+
+ protected override string? from_wiki_to_wiki (WikiPage from, WikiPage to) {
+ if (from.name != "index.valadoc") {
+ return base.from_wiki_to_wiki (from, to);
+ }
+
+ return Path.build_filename (_settings.pkg_name, translate_wiki_name (to));
+ }
+
+ protected override string? from_wiki_to_node (WikiPage from, Api.Node to) {
+ if (from.name != "index.valadoc") {
+ return base.from_wiki_to_node (from, to);
+ }
+
+ if (enable_browsable_check && (!to.is_browsable(_settings) || !to.package.is_browsable (_settings))) {
+ return null;
+ }
+
+ return Path.build_filename (to.package.name, to.get_full_name () + ".html");
+ }
+ }
+
private string get_real_path ( Api.Node element ) {
return GLib.Path.build_filename ( this.settings.path, element.package.name, element.get_full_name () + ".html" );
}
@@ -47,8 +77,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet {
DirUtils.create_with_parents (this.settings.path, 0777);
copy_directory (icons_dir, settings.path);
- write_wiki_pages (tree, css_path_wiki, js_path_wiki, Path.build_filename(settings.path, "content"));
+ write_wiki_pages (tree, css_path_wiki, js_path_wiki, Path.build_filename(settings.path, settings.pkg_name));
+ var tmp = _renderer;
+ _renderer = new HtmlRenderer (settings, new IndexLinkHelper (), this.cssresolver);
GLib.FileStream file = GLib.FileStream.open (GLib.Path.build_filename (settings.path, "index.html"), "w");
writer = new Html.MarkupWriter (file);
_renderer.set_writer (writer);
@@ -56,6 +88,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet {
write_navi_packages (tree);
write_package_index_content (tree);
write_file_footer ();
+ _renderer = tmp;
file = null;
tree.accept (this);
diff --git a/src/libvaladoc/html/basicdoclet.vala b/src/libvaladoc/html/basicdoclet.vala
index 04e0f59..d2ab882 100755
--- a/src/libvaladoc/html/basicdoclet.vala
+++ b/src/libvaladoc/html/basicdoclet.vala
@@ -1,6 +1,6 @@
/* basicdoclet.vala
*
- * Copyright (C) 2008-2009 Florian Brosch
+ * Copyright (C) 2008-2012 Florian Brosch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -203,7 +203,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
}
protected virtual void write_wiki_page (WikiPage page, string contentp, string css_path, string js_path, string pkg_name) {
- GLib.FileStream file = GLib.FileStream.open (Path.build_filename(contentp, page.name.substring (0, page.name.length-7).replace ("/", ".")+"html"), "w");
+ GLib.FileStream file = GLib.FileStream.open (Path.build_filename(contentp, page.name.substring (0, page.name.length-7).replace ("/", ".")+"htm"), "w");
writer = new MarkupWriter (file);
_renderer.set_writer (writer);
this.write_file_header (css_path, js_path, pkg_name);
@@ -792,12 +792,14 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
writer.end_tag ("div");
}
- protected void write_package_content (Package node, Api.Node? parent, WikiPage? wikipage = null) {
+ protected void write_package_content (Package node, Api.Node? parent) {
writer.start_tag ("div", {"class", css_style_content});
writer.start_tag ("h1", {"class", css_title, "id", node.name}).text (node.name).end_tag ("h1");
writer.simple_tag ("hr", {"class", css_headline_hr});
writer.start_tag ("h2", {"class", css_title}).text ("Description:").end_tag ("h2");
+
+ WikiPage? wikipage = (tree.wikitree == null)? null : tree.wikitree.search ("index.valadoc");
if (wikipage != null) {
_renderer.set_container (parent);
_renderer.render (wikipage.documentation);
diff --git a/src/libvaladoc/html/linkhelper.vala b/src/libvaladoc/html/linkhelper.vala
index 2d29686..f9a6903 100755
--- a/src/libvaladoc/html/linkhelper.vala
+++ b/src/libvaladoc/html/linkhelper.vala
@@ -1,6 +1,6 @@
/* linkhelper.vala
*
- * Copyright (C) 2008-2009 Florian Brosch
+ * Copyright (C) 2008-2012 Florian Brosch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -25,7 +25,7 @@ using Gee;
public class Valadoc.Html.LinkHelper : Object {
- private Settings _settings = null;
+ protected Settings _settings = null;
public bool enable_browsable_check {
default = true;
@@ -82,9 +82,9 @@ public class Valadoc.Html.LinkHelper : Object {
return null;
}
- private string translate_wiki_name (WikiPage page) {
+ protected string translate_wiki_name (WikiPage page) {
var name = page.name;
- return name.substring (0, name.last_index_of_char ('.')).replace ("/", ".") + ".html";
+ return name.substring (0, name.last_index_of_char ('.')).replace ("/", ".") + ".htm";
}
@@ -103,10 +103,10 @@ public class Valadoc.Html.LinkHelper : Object {
}
protected virtual string? from_package_to_wiki (Api.Package from, WikiPage to) {
- if (from.name == "index.valadoc") {
- return Path.build_filename ("..", "index.html");
+ if (from.is_package) {
+ return Path.build_filename ("..", _settings.pkg_name, translate_wiki_name (to));
} else {
- return Path.build_filename ("..", "content", translate_wiki_name (to));
+ return translate_wiki_name (to);
}
}
@@ -129,23 +129,15 @@ public class Valadoc.Html.LinkHelper : Object {
return null;
}
- if (from.name == "index.valadoc") {
- return Path.build_filename (to.name, "index.htm");
- } else {
+ if (to.is_package) {
return Path.build_filename ("..", to.name, "index.htm");
+ } else {
+ return "index.htm";
}
}
protected virtual string? from_wiki_to_wiki (WikiPage from, WikiPage to) {
- if (from == to) {
- return "#";
- } else if (from.name == "index.valadoc") {
- return Path.build_filename ("content", translate_wiki_name (to));
- } else if (to.name == "index.valadoc") {
- return Path.build_filename ("..", "index.html");
- } else {
- return translate_wiki_name (to);
- }
+ return translate_wiki_name (to);
}
protected virtual string? from_wiki_to_node (WikiPage from, Api.Node to) {
@@ -153,10 +145,10 @@ public class Valadoc.Html.LinkHelper : Object {
return null;
}
- if (from.name == "index.valadoc") {
- return Path.build_filename (to.package.name, to.get_full_name() + ".html");
+ if (to.package.is_package) {
+ return Path.build_filename ("..", to.package.name, to.get_full_name () + ".html");
} else {
- return Path.build_filename ("..", to.package.name, to.get_full_name() + ".html");
+ return to.get_full_name () + ".html";
}
}
@@ -175,10 +167,10 @@ public class Valadoc.Html.LinkHelper : Object {
}
protected virtual string? from_node_to_wiki (Api.Node from, WikiPage to) {
- if (to.name == "index.valadoc") {
- return Path.build_filename ("..", "index.html");
+ if (from.package.is_package) {
+ return Path.build_filename ("..", _settings.pkg_name, translate_wiki_name (to));
} else {
- return Path.build_filename ("..", "content", translate_wiki_name (to));
+ return translate_wiki_name (to);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]