]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
doclets/devhelp: Add full wiki-support
authorFlorian Brosch <flo.brosch@gmail.com>
Fri, 27 Jan 2012 02:05:32 +0000 (03:05 +0100)
committerFlorian Brosch <flo.brosch@gmail.com>
Fri, 27 Jan 2012 02:19:42 +0000 (03:19 +0100)
src/doclets/devhelp/doclet.vala
src/doclets/htm/doclet.vala
src/libvaladoc/html/basicdoclet.vala
src/libvaladoc/html/linkhelper.vala

index 4d523f8ede89db01447f878757becbb72aeaf711..2fa91f8cb87b64633d8926fee1fbbf225259cb74 100755 (executable)
@@ -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;
 
index 7613f17bb0ad505d180dd5625eea485b281c7139..ba6f7fe74a925508ec0b551f3f9c56ded36f7bfb 100755 (executable)
@@ -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);
index 04e0f598738ec90b4d677f3dc535926929737e9f..d2ab882ee958eb94a2b1a971f5a805e504589966 100755 (executable)
@@ -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);
index 2d2968668739560c24cbc062da94edbecf97f398..f9a69034f00e4f73ae4b8990175ec424c7c73229 100755 (executable)
@@ -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);
                }
        }