]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
libvaladoc: new chart infrastructure
authorFlorian Brosch <flo.brosch@gmail.com>
Fri, 26 Feb 2010 22:59:29 +0000 (23:59 +0100)
committerFlorian Brosch <flo.brosch@gmail.com>
Fri, 26 Feb 2010 22:59:29 +0000 (23:59 +0100)
16 files changed:
icons/devhelpstyle.css
icons/style.css
icons/wikistyle.css
src/doclets/devhelp/doclet.vala
src/libvaladoc/Makefile.am
src/libvaladoc/charts/chart.vala [new file with mode: 0644]
src/libvaladoc/charts/chartfactory.vala [new file with mode: 0644]
src/libvaladoc/charts/hierarchychart.vala [new file with mode: 0644]
src/libvaladoc/charts/simplechartfactory.vala [new file with mode: 0644]
src/libvaladoc/drawer.vala [deleted file]
src/libvaladoc/html/basicdoclet.vala
src/libvaladoc/html/htmlchartfactory.vala [new file with mode: 0644]
src/libvaladoc/html/htmlmarkupwriter.vala
src/libvaladoc/html/linkhelper.vala
src/libvaladoc/markupwriter.vala
src/vapi/libgvc.vapi [deleted file]

index fe69453c25e2d8f56806e7404aafa3e7a1b7c50b..10d940fe9f1fb85b4e63a88bc19fe65e6fdbaa94 100644 (file)
@@ -10,6 +10,7 @@ ul.external_link {
 }
 
 .main_diagram {
+       border-style: none;
        display: block;
        margin: 0px auto;
 }
index f0248a84d2fd35fd14da1c28314eb33ebb8bc2cd..c5af325b1a3cc724aa829979b574e8e99d9ca9a5 100644 (file)
@@ -10,6 +10,7 @@ ul.external_link {
 }
 
 .main_diagram {
+       border-style: none;
        display: block;
        margin: 0px auto;
 }
index ab128be8a59510da3a483e163f5dea1f9fb3c7c7..a80bd8135f504c134cebef24af81f4ac3f4f1021 100644 (file)
@@ -6,6 +6,7 @@ ul.external_link {
 }
 
 .main_diagram {
+       border-style: none;
        display: block;
        margin: 0px auto;
        width: 100px;
index da38805b50915eb7a51b020560fcb06b0851fa76..07280c3bd8c7dd93f79e30e6c9492a54b39b2e81 100755 (executable)
@@ -42,7 +42,6 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
 
        construct {
                _renderer = new HtmlRenderer (this);
-               icon_directory = "";
        }
 
        private string get_path (Api.Node element) {
@@ -53,6 +52,11 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
                return GLib.Path.build_filename (this.settings.path, this.package_dir_name, element.full_name () + ".html");
        }
 
+       protected override string get_icon_directory () {
+               return "";
+       }
+
+
        public override void process (Settings settings, Api.Tree tree) {
                base.process (settings, tree);
                DirUtils.create (this.settings.path, 0777);
index 6e2bd19e9ee5ca30c9ac328b1a4cda84336d9602..63afa96d9278f2a7fa67db39b373f127d704bead 100644 (file)
@@ -24,7 +24,6 @@ lib_LTLIBRARIES = \
 
 libvaladoc_la_VALASOURCES = \
        doclet.vala \
-       drawer.vala \
        errorreporter.vala \
        filehelper.vala \
        moduleloader.vala \
@@ -97,6 +96,10 @@ libvaladoc_la_VALASOURCES = \
        content/tablerow.vala \
        content/taglet.vala \
        content/text.vala \
+       charts/chart.vala \
+       charts/chartfactory.vala \
+       charts/hierarchychart.vala \
+       charts/simplechartfactory.vala \
        parser/manyrule.vala \
        parser/oneofrule.vala \
        parser/optionalrule.vala \
@@ -119,6 +122,7 @@ libvaladoc_la_VALASOURCES = \
        taglets/tagletsince.vala \
        taglets/tagletthrows.vala \
        html/basicdoclet.vala \
+       html/htmlchartfactory.vala \
        html/linkhelper.vala \
        html/cssclassresolver.vala \
        html/htmlmarkupwriter.vala \
@@ -141,7 +145,7 @@ libvaladocincludedir = $(includedir)/
 
 
 libvaladoc.vala.stamp: $(libvaladoc_la_VALASOURCES)
-       $(VALAC) $(VALAFLAGS) -C -H valadoc-1.0.h --pkg gee-1.0 --pkg vala-1.0 --pkg libgvc --pkg gmodule-2.0 --vapidir $(top_srcdir)/src/vapi --pkg libgvc --pkg config --library valadoc-1.0 --basedir $(top_srcdir)/src/libvaladoc/ --save-temps $^
+       $(VALAC) $(VALAFLAGS) -C -H valadoc-1.0.h --pkg gee-1.0 --pkg vala-1.0 --pkg libgvc --pkg gmodule-2.0 --pkg libgvc --vapidir $(top_srcdir)/src/vapi --pkg config --library valadoc-1.0 --basedir $(top_srcdir)/src/libvaladoc/ --save-temps $^
        touch $@
 
 
diff --git a/src/libvaladoc/charts/chart.vala b/src/libvaladoc/charts/chart.vala
new file mode 100644 (file)
index 0000000..caedfd3
--- /dev/null
@@ -0,0 +1,59 @@
+/* chart.vala
+ *
+ * Copyright (C) 2008  Florian Brosch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Florian Brosch <flo.brosch@gmail.com>
+ */
+
+
+public class Valadoc.Charts.Chart : Api.Visitor {
+       protected Gvc.Context context;
+       protected Gvc.Graph graph;
+       protected Factory factory;
+
+       static construct {
+               Gvc.init ();
+       }
+
+       public Chart (Factory factory, Api.Node node) {
+               graph = factory.create_graph (node);
+               this.factory = factory;
+               node.accept (this);
+       }
+
+       public void save (string file_name, string file_type = "png") {
+               if (context == null) {
+                       context = factory.create_context (graph);
+               }
+               context.render_filename (graph, file_type, file_name);
+       }
+
+       public void write (GLib.FileStream file, string file_type) {
+               if (context == null) {
+                       context = factory.create_context (graph);
+               }
+               context.render (graph, file_type, file);
+       }
+
+       ~Chart () {
+               if (context != null) {
+                       context.free_layout (graph);
+               }
+       }
+}
+
diff --git a/src/libvaladoc/charts/chartfactory.vala b/src/libvaladoc/charts/chartfactory.vala
new file mode 100644 (file)
index 0000000..66c1cb4
--- /dev/null
@@ -0,0 +1,49 @@
+/* chartfactory.vala
+ *
+ * Copyright (C) 2008  Florian Brosch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Florian Brosch <flo.brosch@gmail.com>
+ */
+
+
+public abstract class Valadoc.Charts.Factory : Object {
+       protected Gvc.Node create_type (Gvc.Graph graph, Api.Node item) {
+               return graph.create_node (item.full_name ());
+       }
+
+       public abstract Gvc.Graph create_graph (Api.Node item);
+
+       public abstract Gvc.Context create_context (Gvc.Graph graph);
+
+       public abstract Gvc.Node create_class (Gvc.Graph graph, Api.Class item);
+
+       public abstract Gvc.Node create_struct (Gvc.Graph graph, Api.Struct item);
+
+       public abstract Gvc.Node create_interface (Gvc.Graph graph, Api.Interface item);
+
+       public abstract Gvc.Node create_enum (Gvc.Graph graph, Api.Enum item);
+
+       public abstract Gvc.Node create_delegate (Gvc.Graph graph, Api.Delegate item);
+
+       public abstract Gvc.Node create_errordomain (Gvc.Graph graph, Api.ErrorDomain item);
+
+       public abstract Gvc.Node create_namespace (Gvc.Graph graph, Api.Namespace item);
+
+       public abstract Gvc.Edge add_children (Gvc.Graph graph, Gvc.Node parent, Gvc.Node child);
+}
+
diff --git a/src/libvaladoc/charts/hierarchychart.vala b/src/libvaladoc/charts/hierarchychart.vala
new file mode 100644 (file)
index 0000000..ce36134
--- /dev/null
@@ -0,0 +1,82 @@
+/* hierarchychart.vala
+ *
+ * Copyright (C) 2008  Florian Brosch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Florian Brosch <flo.brosch@gmail.com>
+ */
+
+using Gee;
+
+
+public class Valadoc.Charts.Hierarchy : Charts.Chart {
+       public Hierarchy (Factory factory, Api.Node node) {
+               base (factory, node);
+       }
+
+       private void draw_implemented_interfaces (Gvc.Node child, Collection<Api.TypeReference> interfaces) {
+               foreach (Api.TypeReference typeref in interfaces) {
+                       var parent = factory.create_interface (graph, (Api.Interface) typeref.data_type);
+                       factory.add_children (graph, parent, child);
+               }
+       }
+
+       private void draw_parent_classes (Api.Class item, Gvc.Node? child = null) {
+               var parent = factory.create_class (graph, item);
+
+               if (child != null) {
+                       factory.add_children (graph, parent, child);
+               }
+
+               if (item.base_type != null) {
+                       draw_parent_classes ((Api.Class) item.base_type.data_type, parent);
+               }
+
+               draw_implemented_interfaces (parent, item.get_implemented_interface_list ());
+       }
+
+       private void draw_parent_structs (Api.Struct item, Gvc.Node? child = null) {
+               var parent = factory.create_struct (graph, item);
+
+               if (child != null) {
+                       factory.add_children (graph, parent, child);
+               }
+
+               if (item.base_type != null) {
+                       draw_parent_structs ((Api.Struct) item.base_type.data_type, parent);
+               }
+       }
+
+       public override void visit_interface (Api.Interface item) {
+               var iface = factory.create_interface (graph, item);
+
+               if (item.base_type != null) {
+                       draw_parent_classes ((Api.Class) item.base_type.data_type, iface);
+               }
+
+               draw_implemented_interfaces (iface, item.get_implemented_interface_list ());
+       }
+
+       public override void visit_class (Api.Class item) {
+               draw_parent_classes (item);
+       }
+
+       public override void visit_struct (Api.Struct item) {
+               draw_parent_structs (item);
+       }
+}
+
diff --git a/src/libvaladoc/charts/simplechartfactory.vala b/src/libvaladoc/charts/simplechartfactory.vala
new file mode 100644 (file)
index 0000000..867e454
--- /dev/null
@@ -0,0 +1,83 @@
+/* simplechartfactory.vala
+ *
+ * Copyright (C) 2008  Florian Brosch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Florian Brosch <flo.brosch@gmail.com>
+ */
+
+
+
+public class Valadoc.Charts.SimpleFactory : Charts.Factory {
+       protected virtual Gvc.Node configure_type (Gvc.Node node, Api.Node item) {
+               node.safe_set ("shape", "box", "");
+               node.safe_set ("fontname", "Times", "");
+               node.safe_set ("label", item.full_name (), "");
+               return node;
+       }
+
+       public override Gvc.Graph create_graph (Api.Node item) {
+               var graph = new Gvc.Graph (item.full_name (), Gvc.GraphKind.AGDIGRAPH);
+               return graph;
+       }
+
+       public override Gvc.Context create_context (Gvc.Graph graph) {
+               var context = new Gvc.Context ();
+               context.layout_jobs (graph);
+               context.layout (graph, "dot");
+               return context;
+       }
+
+       public override Gvc.Node create_class (Gvc.Graph graph, Api.Class item) {
+               var node = configure_type (create_type (graph, item), item);
+               node.safe_set ("style", "bold", "");
+               return node;
+       }
+
+       public override Gvc.Node create_struct (Gvc.Graph graph, Api.Struct item) {
+               var node = configure_type (create_type (graph, item), item);
+               node.safe_set ("style", "bold", "");
+               return node;
+       }
+
+       public override Gvc.Node create_interface (Gvc.Graph graph, Api.Interface item) {
+               return configure_type (create_type (graph, item), item);
+       }
+
+       public override Gvc.Node create_enum (Gvc.Graph graph, Api.Enum item) {
+               return configure_type (create_type (graph, item), item);
+       }
+
+       public override Gvc.Node create_delegate (Gvc.Graph graph, Api.Delegate item) {
+               return configure_type (create_type (graph, item), item);
+       }
+
+       public override Gvc.Node create_errordomain (Gvc.Graph graph, Api.ErrorDomain item) {
+               return configure_type (create_type (graph, item), item);
+       }
+
+       public override Gvc.Node create_namespace (Gvc.Graph graph, Api.Namespace item) {
+               return configure_type (create_type (graph, item), item);
+       }
+
+       public override Gvc.Edge add_children (Gvc.Graph graph, Gvc.Node parent, Gvc.Node child) {
+               var edge = graph.create_edge (parent, child);
+               edge.safe_set ("dir", "back", "");
+               return edge;
+       }
+}
+
diff --git a/src/libvaladoc/drawer.vala b/src/libvaladoc/drawer.vala
deleted file mode 100755 (executable)
index 297a867..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/* drawer.vala
- *
- * Copyright (C) 2008-2009 Florian Brosch
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
- *
- * Author:
- *     Brosch Florian <flo.brosch@gmail.com>
- */
-
-using Graphviz;
-using Gee;
-using Valadoc.Api;
-
-namespace Valadoc.Diagrams {
-       // replace with .full_name
-       private static inline string get_diagram_node_name (Api.Node type) {
-               string name = "";
-               if (type.nspace.full_name() != null) {
-                       name = type.nspace.full_name () + ".";
-               }
-               return name + type.name;
-       }
-
-       public static void write_struct_diagram (Struct stru, string path) {
-               string[] params2 = new string[5];
-               params2[0] = "";
-               params2[1] = "-T";
-               params2[2] = "png";
-               params2[3] = "-o";
-               params2[4] = path;
-
-               Graphviz.Context cntxt = Context.context ();
-               cntxt.parse_args (params2);
-
-               Graphviz.Graph g = Graph.open ("g", GraphType.AGDIGRAPH);
-               g.set_safe ("rank", "", "");
-
-               weak Graphviz.Node me = draw_struct (g, stru, null);
-               draw_struct_parents (stru, g, me);
-
-               cntxt.layout_jobs (g);
-               cntxt.render_jobs (g);
-               cntxt.free_layout (g);
-       }
-
-       private static void draw_struct_parents (Struct stru, Graphviz.Graph g, Graphviz.Node me) {
-               Struct? parent = stru.base_type != null ? (Struct) stru.base_type.data_type : null;
-               if (parent != null) {
-                       weak Graphviz.Node stru2 = draw_struct (g, parent, me);
-                       draw_struct_parents (parent, g, stru2);
-               }
-       }
-
-       public static void write_interface_diagram (Interface iface, string path) {
-               string[] params2 = new string[5];
-               params2[0] = "";
-               params2[1] = "-T";
-               params2[2] = "png";
-               params2[3] = "-o";
-               params2[4] = path;
-
-               Graphviz.Context cntxt = Context.context ();
-               cntxt.parse_args (params2);
-
-               Graphviz.Graph g = Graph.open ("g", GraphType.AGDIGRAPH);
-               g.set_safe ("rank", "", "");
-
-               weak Graphviz.Node me = draw_interface (g, iface, null);
-               draw_interface_parents (iface, g, me);
-
-               cntxt.layout_jobs (g);
-               cntxt.render_jobs (g);
-               cntxt.free_layout (g);
-       }
-
-       private static void draw_interface_parents (Interface iface, Graphviz.Graph g, Graphviz.Node me) {
-               Collection<TypeReference> parentlst = iface.get_implemented_interface_list ();
-               Class? cl = iface.base_type != null ? (Class) iface.base_type.data_type : null;
-               if (cl != null) {
-                       weak Graphviz.Node cln = draw_class (g, cl, me);
-                       draw_class_parents (cl, g, cln);
-               }
-
-               foreach (TypeReference type in parentlst) {
-                       draw_interface (g, (Interface) type.data_type, me);
-               }
-       }
-
-       public static void write_class_diagram (Class cl, string path) {
-               string[] params2 = new string[5];
-               params2[0] = "";
-               params2[1] = "-T";
-               params2[2] = "png";
-               params2[3] = "-o";
-               params2[4] = path;
-
-               Graphviz.Context cntxt = Context.context ();
-               cntxt.parse_args (params2);
-
-               Graphviz.Graph g = Graph.open ("g", GraphType.AGDIGRAPH);
-               g.set_safe ("rank", "", "");
-
-               weak Graphviz.Node me = draw_class (g, cl, null);
-               draw_class_parents (cl, g, me);
-
-               cntxt.layout_jobs (g);
-               cntxt.render_jobs (g);
-               cntxt.free_layout (g);
-       }
-
-       private static weak Graphviz.Node draw_struct (Graph g, Struct stru, Graphviz.Node? parent) {
-               string name = get_diagram_node_name (stru);
-               weak Graphviz.Node? node = g.find_node (name);
-               if (node == null) {
-                       node = g.node (name);
-                       node.set_safe ("shape", "box", "");
-                       node.set_safe ("fontname", "Times", "");
-               }
-
-               if (parent != null) {
-                       weak Edge edge = g.edge (node, parent);
-                       edge.set_safe ("dir", "back", "");
-               }
-
-               return node;
-       }
-
-       private static weak Graphviz.Node draw_interface (Graph g, Interface iface, Graphviz.Node? parent) {
-               string name = get_diagram_node_name (iface);
-               weak Graphviz.Node? node = g.find_node (name);
-               if (node == null) {
-                       node = g.node (name);
-                       node.set_safe ("shape", "box", "");
-                       node.set_safe ("fontname", "Times", "");
-               }
-
-               if (parent != null) {
-                       weak Edge edge = g.edge (node, parent);
-                       edge.set_safe ("dir", "back", "");
-               }
-
-               return node;
-       }
-
-       private static weak Graphviz.Node draw_class (Graph g, Class cl, Graphviz.Node? parent) {
-               string name = get_diagram_node_name (cl);
-               weak Graphviz.Node? node = g.find_node (name);
-               if (node == null) {
-                       node = g.node (name);
-                       node.set_safe ("style", "bold", "");
-                       node.set_safe ("shape", "box", "");
-
-                       if (cl.is_abstract) {
-                               node.set_safe ("fontname", "Times-Italic", "");
-                       } else {
-                               node.set_safe ("fontname", "Times", "");
-                       }
-               }
-
-               if (parent != null) {
-                       weak Edge edge = g.edge (node, parent);
-                       edge.set_safe ("dir", "back", "");
-               }
-
-               return node;
-       }
-
-       private static void draw_class_parents (Class cl, Graphviz.Graph g, Graphviz.Node me) {
-               Collection<TypeReference> parents = cl.get_implemented_interface_list ();
-               Class? pcl = cl.base_type != null ? (Class) cl.base_type.data_type : null;
-
-               if (pcl != null) {
-                       weak Graphviz.Node node = draw_class (g, pcl, me);
-                       draw_class_parents (pcl, g, node);
-               }
-
-               foreach (TypeReference type in parents) {
-                       draw_interface (g, (Interface) type.data_type, me);
-               }
-       }
-}
-
index 9479f8019beea1edf09811ee0fc2f0597d02cdad..28d6fb2b70e858eb5844c94f93a44cd97220f372 100755 (executable)
@@ -32,11 +32,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
        protected Html.MarkupWriter writer;
        protected Html.LinkHelper linker;
        protected Html.CssClassResolver cssresolver;
-
-
-       // paths:
-       protected string chart_directory = "img";
-       protected string icon_directory = "..";
+       protected Charts.Factory image_factory;
 
 
        // CSS:
@@ -105,14 +101,31 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
        }
 
        public virtual void process (Settings settings, Api.Tree tree) {
+               this.image_factory = new SimpleChartFactory (settings);
                this.settings = settings;
                this.tree = tree;
        }
 
+
+       // paths:
        protected string? get_link (Api.Node to, Api.Node from) {
                return linker.get_relative_link (from, to, settings);
        }
 
+       protected virtual string get_img_path_html (Api.Node element, string type) {
+               return Path.build_filename ("img", element.full_name () + "." + type);
+       }
+
+       protected virtual string get_img_path (Api.Node element, string type) {
+               return Path.build_filename (settings.path, element.package.name, "img", element.full_name () + "." + type);
+       }
+
+       protected virtual string get_icon_directory () {
+               return "..";
+       }
+
+
+
        protected void write_navi_entry_html_template (string style, string content) {
                writer.start_tag ("li", {"class", style});
                writer.text (content);
@@ -138,8 +151,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
 
                if (link == true) {
                        this.write_navi_entry_html_template_with_link (style, this.get_link (element, pos), name);
-               }
-               else {
+               } else {
                        this.write_navi_entry_html_template (style, name);
                }
        }
@@ -444,7 +456,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
                        writer.start_tag ("div", {"class", css_box_headline});
                        writer.start_tag ("div", {"class", css_box_headline_text}).text (headline).end_tag ("div");
                        writer.start_tag ("div", {"class", css_box_headline_toggle});
-                       writer.start_tag ("img", {"onclick", "toggle_box  (this, '" + html_id + "')", "src", Path.build_filename (icon_directory, "coll_open.png")});
+                       writer.start_tag ("img", {"onclick", "toggle_box  (this, '" + html_id + "')", "src", Path.build_filename (get_icon_directory (), "coll_open.png")});
                        writer.raw_text ("&nbsp;");
                        writer.end_tag ("div");
                        writer.end_tag ("div");
@@ -606,14 +618,6 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
                writer.end_tag ("ul");
        }
 
-       protected string get_img_path (Api.Node element) {
-               return Path.build_filename (chart_directory, element.full_name () + ".png");
-       }
-
-       protected string get_img_real_path (Api.Node element) {
-               return Path.build_filename (settings.path, element.package.name, chart_directory, element.full_name () + ".png");
-       }
-
        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) {
@@ -641,25 +645,15 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
        }
 
        protected void write_image_block (Api.Node element) {
-               if (!(element is Class || element is Interface || element is Struct)) {
-                       return;
-               }
+               if (element is Class || element is Interface || element is Struct) {
+                       var chart = new Charts.Hierarchy (image_factory, element);
+                       chart.save (this.get_img_path (element, "png"), "png");
 
-               string realimgpath = this.get_img_real_path (element);
-               string imgpath = this.get_img_path (element);
+                       writer.start_tag ("h2", {"class", css_title}).text ("Object Hierarchy:").end_tag ("h2");
 
-               if (element is Class) {
-                       Diagrams.write_class_diagram ((Class)element, realimgpath);
+                       writer.simple_tag ("img", {"class", css_diagram, "usemap", "#"+element.full_name (),"alt", "Object hierarchy for %s".printf (element.name), "src", this.get_img_path_html (element, "png")});
+                       writer.add_usemap (chart);
                }
-               else if (element is Interface) {
-                       Diagrams.write_interface_diagram ((Interface)element, realimgpath);
-               }
-               else if (element is Struct) {
-                       Diagrams.write_struct_diagram ((Struct)element, realimgpath);
-               }
-
-               writer.start_tag ("h2", {"class", css_title}).text ("Object Hierarchy:").end_tag ("h2");
-               writer.image (imgpath, "Object hierarchy for %s".printf (element.name), css_diagram);
        }
 
        public void write_namespace_content (Namespace node, Api.Node? parent) {
diff --git a/src/libvaladoc/html/htmlchartfactory.vala b/src/libvaladoc/html/htmlchartfactory.vala
new file mode 100644 (file)
index 0000000..998f516
--- /dev/null
@@ -0,0 +1,53 @@
+/* simplechartfactory.vala
+ *
+ * Copyright (C) 2008  Florian Brosch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Florian Brosch <flo.brosch@gmail.com>
+ */
+
+
+
+public class Valadoc.Html.SimpleChartFactory : Charts.SimpleFactory {
+       private Settings _settings;
+       private Api.Node _container;
+
+       public SimpleChartFactory (Settings settings) {
+               _settings = settings;
+       }
+
+       public override Gvc.Graph create_graph (Api.Node item) {
+               var graph = base.create_graph (item);
+               _container = item;
+               return graph;
+       }
+
+       protected override Gvc.Node configure_type (Gvc.Node node, Api.Node item) {
+               base.configure_type (node, item);
+
+               if (_container != null) {
+                       var linker = LinkHelper.get_instance ();
+                       var link = linker.get_relative_link (_container, item, _settings);
+                       if (link != null) {
+                               node.safe_set ("URL", link, "");
+                       }
+               }
+
+               return node;
+       }
+}
+
index cb007e67d69c0611071b064a04267b1a87bf7809..7fbf6e16f1aa9cf173cea7002bde579827820884 100755 (executable)
@@ -28,6 +28,12 @@ public class Valadoc.Html.MarkupWriter : Valadoc.MarkupWriter {
                base (stream, xml_declaration);
        }
 
+       public MarkupWriter add_usemap (Charts.Chart chart) {
+               stream.putc ('\n');
+               chart.write (stream, "cmapx");
+               return this;
+       }
+
        // edit
        public MarkupWriter link (string url, string label, string? css_class = null) {
                if (css_class == null) {
index 91a03c207340bb184db6677a6b1c8ff7f2a5c5b1..c6c4b4e6b80b5611c4da2e112e7e7f922bb88e5e 100644 (file)
@@ -39,7 +39,6 @@ public class Valadoc.Html.LinkHelper : Object {
                return _singleton;
        }
 
-       // done
        public string? get_package_link (Api.Package package, Settings settings) {
                if (!package.is_visitor_accessible (settings)) {
                        return null;
index 43638e0f74d9070e1b3f72a97bb6366a2ae2dba9..85db4250f6c7303c00cc2f32a88a6149e459e72b 100644 (file)
@@ -23,7 +23,7 @@
 
 
 public class Valadoc.MarkupWriter {
-       private unowned FileStream stream;
+       protected unowned FileStream stream;
        protected int indent;
        private long current_column = 0;
        private bool last_was_tag;
diff --git a/src/vapi/libgvc.vapi b/src/vapi/libgvc.vapi
deleted file mode 100755 (executable)
index e581f31..0000000
+++ /dev/null
@@ -1,395 +0,0 @@
-
-
-[CCode (cprefix = "")]
-namespace Graphviz {
-
-
-//check the headerfile,        // rename
-[CCode (cprefix = "", cheader_filename="gvc.h")]
-public enum GraphType { // => GraphKind
-       AGDIGRAPHSTRICT,
-       AGRAPHSTRICT,
-       AGDIGRAPH,
-       AGRAPH
-}
-
-
-
-[CCode (cname = "aginitlib", cheader_filename="gvc.h")]
-public void init ( size_t graphinfo, size_t nodeinfo, size_t  edgeinfo);
-
-
-// rename enum values
-[CCode (cname = "agerrlevel_t", cheader_filename = "gvc.h", cprefix = "")]
-public enum ErrorLevel {
-       AGWARN,
-       AGERR,
-       AGMAX,
-       AGPREV
-}
-
-[CCode(cprefix = "ag")]
-namespace Error {
-       [CCode (cname = "agerrno")]
-       public static ErrorLevel errno;
-
-       [CCode (cname = "agerr")]
-       public static int error( ErrorLevel level, string fmt, ...);
-
-       [CCode (cname = "agerrors")]
-       public static int errors( );
-
-       [CCode (cname = "agseterr")]
-       public static void set_error( ErrorLevel err );
-
-       [CCode (cname = "aglasterr")]
-       public static string? last_error( );
-
-       // rename
-       [CCode (cname = "agerrorf")] // name?
-       public static void errorf( string format, ...);
-
-       // rename
-       [CCode (cname = "agwarningf")]
-       void warningf( string fmt, ...);
-}
-
-
-// -> parser: static class
-//     [CCode (cname = "agreadline")]
-//     public void read_line(int);
-
-//     [CCode (cname = "agsetfile")]
-//     public void set_file( string filename );
-
-
-//     char *gvUsername(void);
-
-
-
-
-//
-//-> class string: (I think we don't need that for the api.)
-//[CCode (cname = "agstrdup")]
-//extern char *agstrdup(char *);
-//[CCode (cname = "agstrfree")]
-//extern void agstrfree(char *);
-//[CCode (cname = "agcanon")]
-//char *       agcanon (char *)
-//[CCode (cname = "agstrcanon")]
-//char *agstrcanon(char *, char *);
-//[CCode (cname = "agcanonical")]
-//char *agcanonical(char *);
-//[CCode (cname = "aghtmlstr")]
-//int aghtmlstr(char *s);
-//[CCode (cname = "agstrdup_html")]
-//char *agstrdup_html(char *s);
-
-
-
-
-
-[Compact]
-[CCode (cname = "rank_t", cheader_filename = "gvc.h", free_function = "", cprefix = "")]
-public class Rank {
-
-}
-
-[Compact]
-[CCode (cname = "Agraph_t", cheader_filename = "gvc.h", free_function = "agclose", cprefix = "")]
-// AGraph
-public class Graph {
-       //[CCode (cname = "agmemread")]
-       //public static Graph? mem_read( char[] mem ); // some internal cast-magic caused damage to my brain
-       //public void attach_attrs( );
-
-       [CCode (cname = "agread")]
-       public static Graph read (GLib.FileStream file );
-
-       [CCode (cname = "AG_IS_DIRECTED")]
-       public bool is_directed ( );
-
-       [CCode (cname = "AG_IS_STRICT")]
-       public bool is_strict ( );
-
-       //
-       [CCode (cname = "agraphattr")]
-       public Sym attribute ( string name, string val );
-
-       [CCode (cname = "agfstattr")]
-       public weak Sym first_attribute ( );
-
-       [CCode (cname = "aglstattr")]
-       public weak Sym last_attribute ( );
-
-       [CCode (cname = "agnxtattr")]
-       public weak Sym next_attribute ( Sym sym );
-
-       [CCode (cname = "agprvattr")]
-       public weak Sym previous_attribute ( Sym sym );
-
-       //
-       [CCode (cname = "agget")]
-       public string get( string name );
-
-       //
-       [CCode (cname = "agxget")]
-       public string get_index( int index );
-
-       [CCode (cname = "agset")]
-       public int set(string attr, string val);
-
-       [CCode (cname = "agxset")]
-       public int set_index( int index, char[] buf );
-
-       [CCode (cname = "agindex")]
-       public int index ( string name );
-
-       [CCode (cname = "agsafeset")]
-       public int set_safe( string name, string val, string def );
-
-       [CCode (cname = "agopen")]
-       public static Graph open ( string name, GraphType kind );
-
-       //
-       [CCode (cname = "agsubg")]
-       public weak Graph subgraph( string name );
-
-       [CCode (cname = "agfindsubg")]
-       public weak Graph find_sub_graph ( string name );
-
-       [CCode (cname = "agwrite")]
-       public int write( GLib.FileStream file );
-
-       [CCode (cname = "agprotograph")]
-       public static Graph proto_graph ( );
-
-       [CCode (cname = "agusergraph")]
-       public static Graph user_graph( Node n );
-
-       [CCode (cname = "agnnodes")]
-       public int n_nodes( );
-
-       [CCode (cname = "agnedges")]
-       public int n_edges( );
-
-       [CCode (cname = "aginsert")]
-       public void insert( void* obj );
-
-       [CCode (cname = "agdelete")]
-       public void delete( void* obj );
-
-       [CCode (cname = "agcontains")]
-       public int contains( void* obj );
-
-       // make sure that the returned note is really freed by this class
-       [CCode (cname = "agnode")]
-       public weak Node node ( string str );
-
-       //
-       [CCode (cname = "agnodeattr")]
-       Sym node_attribute ( string name, string val );
-
-       [CCode (cname = "agfindnode")]
-       public weak Node find_node( string name );
-
-       [CCode (cname = "agfstnode")]
-       public weak Node first_node( );
-
-       [CCode (cname = "agnxtnode")]
-       public weak Node next_node( Node n );
-
-       [CCode (cname = "aglstnode")]
-       public weak Node last_node( );
-
-       [CCode (cname = "agprvnode")]
-       public weak Node prev_node( Node n );
-
-       [CCode (cname = "agedge")]
-       public weak Edge edge( Node tail, Node head );
-
-       [CCode (cname = "agedgeattr")]
-       public weak Sym edge_attribute( string name, string val );
-
-       [CCode (cname = "agfindedge")]
-       public weak Edge find_edge( Node tail, Node head );
-
-       [CCode (cname = "agfstedge")]
-       public weak Edge first_edge(Graph g, Node n);
-
-       [CCode (cname = "agnxtedge")]
-       public weak Edge next_edge( Edge e, Node n);
-
-       [CCode (cname = "agfstin")]
-       public weak Edge first_in( Node n );
-
-       [CCode (cname = "agnxtin")]
-       public weak Edge next_in ( Edge e );
-
-       [CCode (cname = "agfstout")]
-       public weak Edge first_out( Node n );
-
-       [CCode (cname = "agnxtout")]
-       public weak Edge next_out( Edge edge );
-
-       //?
-       [CCode (cname = "agraphattr")]
-       public Sym graph_attribute ( string name, string val );
-
-       [CCode (cname = "agfindattr")]
-       public weak Sym find_attribute ( string name );
-
-       [CCode (cname = "agcopyattr")]
-       public int copy_attribute( void* newobj );
-
-       //
-       [CCode (cname = "agprotonode")]
-       public Node proto_node ( );
-
-       //
-       [CCode (cname = "agprotoedge")]
-       public Edge proto_edge ( );
-}
-
-
-
-// Fill in!
-[Compact]
-[CCode (cname = "Agnode_t", cheader_filename = "gvc.h", free_function = "agFREEnode", cprefix = "")]
-public class Node {
-       [CCode (cname = "agsafeset")]
-       public int set_safe( string name, string val, string def );
-
-       [CCode (cname = "agfindattr")]
-       public weak Sym find_attribute ( string name );
-
-       [CCode (cname = "agcopyattr")]
-       public int copy_attribute( void* newobj );
-
-       //
-       [CCode (cname = "agget")]
-       public string get( string name );
-
-       //
-       [CCode (cname = "agxget")]
-       public string get_index( int index );
-
-       //
-       [CCode (cname = "agset")]
-       public int set(string attr, string val);
-
-       [CCode (cname = "agxset")]
-       public int set_index( int index, char[] buf );
-
-       [CCode (cname = "agindex")]
-       public int index ( string name );
-
-       // same as cname="agnode" -> i just tink it is weak
-       [CCode (cname = "agattr")]
-       public weak Sym attribute ( string name, string val );
-
-       [CCode (cname = "agfstattr")]
-       public weak Sym first_attribute ( );
-
-       [CCode (cname = "aglstattr")]
-       public weak Sym last_attribute ( );
-
-       [CCode (cname = "agnxtattr")]
-       public weak Sym next_attribute ( Sym sym );
-
-       [CCode (cname = "agprvattr")]
-       public weak Sym previous_attribute ( Sym sym );
-}
-
-
-
-// FILL IN! - free function?
-[Compact]
-[CCode (cname = "Agedge_t", cheader_filename = "gvc.h", cprefix = "")]
-public class Edge {
-       // 
-       [CCode (cname = "agattr")]
-       public weak Sym attribute ( string name, string val );
-
-       [CCode (cname = "agfstattr")]
-       public weak Sym first_attribute ( );
-
-       [CCode (cname = "aglstattr")]
-       public weak Sym last_attribute ( );
-
-       [CCode (cname = "agnxtattr")]
-       public weak Sym next_attribute ( Sym sym );
-
-       [CCode (cname = "agprvattr")]
-       public weak Sym previous_attribute ( Sym sym );
-
-       [CCode (cname = "agsafeset")]
-       public int set_safe( string name, string val, string def );
-
-       [CCode (cname = "agfindattr")]
-       public weak Sym find_attribute ( string name );
-
-       //
-       [CCode (cname = "agcopyattr")]
-       public int copy_attribute( void* newobj );
-
-       //
-       [CCode (cname = "agget")]
-       public string get( string name );
-
-       //
-       [CCode (cname = "agxget")]
-       public string get_index( int index );
-
-       [CCode (cname = "agset")]
-       public int set(string attr, string val);
-
-       [CCode (cname = "agxset")]
-       public int set_index( int index, char[] buf );
-
-       [CCode (cname = "agindex")]
-       public int index ( string name );
-}
-
-
-
-// free function?
-[Compact]
-[CCode (cname = "Agsym_t", cheader_filename = "gvc.h", cprefix = "")]
-public class Sym {
-}
-
-
-[Compact]
-[CCode (cname = "GVC_t", cheader_filename = "gvc.h", free_function = "gvFreeContext", cprefix = "")]
-public class Context {
-       //??
-       //GVC_t *gvNEWcontext(char **info, char *user);
-       [CCode (cname = "gvParseArgs")]
-       public int parse_args ( [CCode (array_length_pos = 0.9)] string[] argv );
-
-       [CCode (cname = "gvContext")]
-       public static Context context ( ); // => GraphKind
-
-       [CCode (cname = "gvLayout")]
-       public int layout ( Graph g, string engine );
-
-       [CCode (cname = "gvLayoutJobs")]
-       public int layout_jobs ( Graph g );     
-
-       [CCode (cname = "gvRender")]
-       public int render( Graph g, string format, GLib.FileStream file );
-
-       [CCode (cname = "gvRenderFilename")]
-       public int render_filename ( Graph g, string format, string filename);
-
-       [CCode (cname = "gvRenderJobs")]
-       public int render_jobs ( Graph g );
-
-       [CCode (cname = "gvFreeLayout")]
-       public int free_layout ( Graph g );
-}
-
-
-}
-