/* 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
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";
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);
}
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);
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;
/* 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
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" );
}
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);
write_navi_packages (tree);
write_package_index_content (tree);
write_file_footer ();
+ _renderer = tmp;
file = null;
tree.accept (this);
/* 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
}
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);
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);
/* 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
public class Valadoc.Html.LinkHelper : Object {
- private Settings _settings = null;
+ protected Settings _settings = null;
public bool enable_browsable_check {
default = true;
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";
}
}
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);
}
}
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) {
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";
}
}
}
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);
}
}