]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
drop libxml2 dependency
authorFlorian Brosch <flo.brosch@gmail.com>
Sun, 25 Oct 2009 21:14:00 +0000 (22:14 +0100)
committerFlorian Brosch <flo.brosch@gmail.com>
Sun, 25 Oct 2009 21:14:00 +0000 (22:14 +0100)
configure.in
src/doclets/devhelp/Makefile.am
src/doclets/devhelp/doclet.vala
src/libvaladoc/Makefile.am
src/libvaladoc/devhelp-markupwriter.vala [new file with mode: 0644]

index 8f37d37e46ad7acb06b29bc2428b6848597e9815..54c888483c2d3c13328f52d2b2dd3a6cef963d33 100644 (file)
@@ -27,13 +27,9 @@ LIBGEE_REQUIRED=0.5
 LIBGVC_REQUIRED=2.16
 GLIB_REQUIRED=2.12.0
 GTK_REQUIRED=2.10.0
-LIBXML2_REQUIRED=2.0
 LIBGDKPIXBUF_REQUIRED=2.0
 
 
-PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED )
-AC_SUBST(LIBXML2_CFLAGS)
-AC_SUBST(LIBXML2_LIBS)
 
 PKG_CHECK_MODULES(LIBGVC, libgvc >= $LIBGVC_REQUIRED )
 AC_SUBST(LIBGVC_CFLAGS)
index 9f3a90ef8ecdc2a24e30c6028b62eeb45c1f63ca..aacd5bf54782f4c95a8c6a6776103b67c4c4ea1a 100644 (file)
@@ -6,7 +6,6 @@ AM_CFLAGS =  -g \
        -I ../../libvaladoc/ \
        $(GLIB_CFLAGS) \
        $(LIBGEE_CFLAGS) \
-       $(LIBXML2_CFLAGS) \
        $(LIBVALA_CFLAGS) \
        $(NULL)
 
@@ -35,14 +34,13 @@ libdoclet_la_SOURCES =      \
 
 
 libdoclet.vala.stamp: $(libdoclet_la_VALASOURCES)
-       $(VALAC) -C --vapidir ../../vapi --vapidir ../../libvaladoc --pkg valadoc-1.0 --pkg libxml-2.0 --pkg gee-1.0 --basedir . $^
+       $(VALAC) -C --vapidir ../../vapi --vapidir ../../libvaladoc --pkg valadoc-1.0 --pkg gee-1.0 --basedir . $^
        touch $@
 
 
 libdoclet_la_LIBADD = \
        ../../libvaladoc/libvaladoc.la \
        $(GLIB_LIBS) \
-       $(LIBXML2_LIBS) \
        $(LIBVALA_LIBS) \
        $(LIBGEE_LIBS) \
        $(NULL)
index 03919e1249de02ca99534a9f2dad9e589ee87ab3..66227da9425aa755a1448c935c593073265d9d42 100755 (executable)
@@ -21,7 +21,6 @@
 using Valadoc;
 using Valadoc.Api;
 using Valadoc.Html;
-using Xml;
 using Gee;
 
 
@@ -103,108 +102,16 @@ namespace Valadoc.Devhelp {
 
 
 
-public enum Valadoc.Devhelp.KeywordType {
-       NAMESPACE = 0,
-       CLASS = 1,
-       DELEGATE = 2,
-       INTERFACE = 3,
-       ERRORDOMAIN = 4,
-
-       CONSTANT = 5,
-       ENUM = 6,
-       FUNCTION = 7,
-       MACRO = 8,
-       PROPERTY = 9,
-       SIGNAL = 10,
-       STRUCT = 11,
-       TYPEDEF = 12,
-       UNION = 13,
-       VARIABLE = 14,
-       UNSET = 15
-}
-
-public class Valadoc.Devhelp.DevhelpFormat : Object {
-       private Xml.Doc* devhelp = null;
-       private Xml.Node* functions = null;
-       private Xml.Node* chapters = null;
-       private Xml.Node* current = null;
-/*
-       ~DevhelpFormat ( ) {
-               delete this.devhelp;
-       }
-*/
-       public void save_file ( string path ) {
-               Xml.Doc.save_format_file ( path, this.devhelp, 1 );
-       }
-
-       public DevhelpFormat ( string name, string version ) {
-               this.devhelp = new Xml.Doc ( "1.0" );
-               Xml.Node* root = new Xml.Node ( null, "book" );
-               this.devhelp->set_root_element( root );
-               root->new_prop ( "xmlns", "http://www.devhelp.net/book" );
-               root->new_prop ( "title", name + " Reference Manual" );
-               root->new_prop ( "language", "vala" );
-               root->new_prop ( "link", "index.htm" );
-               root->new_prop ( "name", version );
-               root->new_prop ( "version", "2" );
-               root->new_prop ( "author", "" );
-
-               this.current = root->new_child ( null, "chapters" );
-               this.functions = root->new_child ( null, "functions" );
-               this.chapters = this.current;
-       }
-
-       private const string[] keyword_type_strings = {
-               "", // namespace
-               "", // class
-               "", // delegate
-               "", // interface
-               "", // errordomain
-               "constant",
-               "enum",
-               "function",
-               "macro",
-               "property",
-               "signal",
-               "struct",
-               "typedef",
-               "union",
-               "variable",
-               ""
-       };
-
-       public void add_chapter_start ( string name, string link ) {
-               this.current = this.current->new_child ( null, "sub" );
-               this.current->new_prop ( "name", name );
-               this.current->new_prop ( "link", link );
-       }
-
-       public void add_chapter_end () {
-               this.current = this.current->parent;
-       }
-
-       public void add_chapter ( string name, string link ) {
-               this.add_chapter_start ( name, link );
-               this.add_chapter_end ();
-       }
-
-       public void add_keyword ( KeywordType type, string name, string link ) {
-               Xml.Node* keyword = this.functions->new_child ( null, "keyword" );
-               keyword->new_prop ( "type", keyword_type_strings[(int)type] );
-               keyword->new_prop ( "name", name );
-               keyword->new_prop ( "link", link );
-       }
-}
-
-
-
 public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
        private const string css_path_wiki = "../wikistyle.css";
        private const string css_path = "wikistyle.css";
+
+       private ArrayList<Api.Node> nodes = new ArrayList<Api.Node> ();
        private string package_dir_name = ""; // remove
-       private DevhelpFormat devhelp;
        private Api.Tree tree;
 
+       private Devhelp.MarkupWriter _devhelpwriter;
+
        construct {
                _renderer = new HtmlRenderer (this);
        }
@@ -223,10 +130,7 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
 
                DirUtils.create (this.settings.path, 0777);
 
-               this.devhelp = new DevhelpFormat (settings.pkg_name, "");
-
                write_wiki_pages (tree, css_path_wiki, Path.build_filename (this.settings.path, this.settings.pkg_name, "content"));
-
                tree.accept (this);
        }
 
@@ -242,6 +146,7 @@ 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");
@@ -253,7 +158,11 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
                rt = DirUtils.create (imgpath, 0777);
                copy_directory (icons_dir, path);
 
-               this.devhelp = new DevhelpFormat (pkg_name, "");
+               var devfile = FileStream.open (devpath, "w");
+               _devhelpwriter = new Devhelp.MarkupWriter (devfile);
+               _devhelpwriter.xml_declaration ();
+
+               _devhelpwriter.start_book (pkg_name+" Reference Manual", "vala", "index.htm", "", "", "");
 
                GLib.FileStream file = GLib.FileStream.open (filepath, "w");
                writer = new Html.MarkupWriter (file);
@@ -264,18 +173,43 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
                write_file_footer ();
                file = null;
 
+
+               _devhelpwriter.start_chapters ();
                package.accept_all_children (this);
+               _devhelpwriter.end_chapters ();
+
+
+               _devhelpwriter.start_functions ();
+               foreach (Api.Node node in this.nodes) {
+                       string typekeyword = "";
+                       if (node is Enum) {
+                               typekeyword = "enum";
+                       } else if (node is Constant) {
+                               typekeyword = "constant";
+                       } else if (node is Method) {
+                               typekeyword = "function";
+                       } else if (node is Field) {
+                               typekeyword = "variable";
+                       } else if (node is Property) {
+                               typekeyword = "property";
+                       } else if (node is Api.Signal) {
+                               typekeyword = "signal";
+                       } else if (node is Struct) {
+                               typekeyword = "struct";
+                       }
+
+                       _devhelpwriter.simple_tag ("keyword", {"type", typekeyword, "name", node.name, "link", get_html_link_imp (settings, node, null)});
+               }
+               _devhelpwriter.end_functions ();
 
-               this.devhelp.save_file (devpath);
+               _devhelpwriter.end_book ();
        }
 
-       private void process_compound_node (Api.Node node, KeywordType type) {
+       private void process_compound_node (Api.Node node) {
                string rpath = this.get_real_path (node);
                string path = this.get_path (node);
 
                if (node.name != null) {
-                       this.devhelp.add_chapter_start (node.name, path);
-       
                        GLib.FileStream file = GLib.FileStream.open (rpath, "w");
                        writer = new Html.MarkupWriter (file);
                        writer.xml_declaration ();
@@ -286,15 +220,17 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
                        file = null;
                }
 
-               node.accept_all_children (this);
-
                if (node.name != null) {
-                       this.devhelp.add_chapter_end ();
-                       this.devhelp.add_keyword (type, node.name, path);
+                       _devhelpwriter.start_sub (node.name, path);
+                       node.accept_all_children (this);
+                       _devhelpwriter.end_sub ();
+                       this.nodes.add (node);
+               } else {
+                       node.accept_all_children (this);
                }
        }
 
-       private void process_node (Api.Node node, KeywordType type) {
+       private void process_node (Api.Node node) {
                string rpath = this.get_real_path (node);
                string path = this.get_path (node);
 
@@ -307,46 +243,45 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
                write_file_footer ();
                file = null;
 
+               _devhelpwriter.start_sub (node.name, path);
                node.accept_all_children (this);
-
-               this.devhelp.add_keyword (type, node.name, path);
-               this.devhelp.add_chapter (node.name, path);
+               _devhelpwriter.end_sub ();
        }
 
        public override void visit_namespace (Namespace item) {
-               process_compound_node (item, KeywordType.NAMESPACE);
+               process_compound_node (item);
        }
 
        public override void visit_interface (Interface item) {
-               process_compound_node (item, KeywordType.INTERFACE);
+               process_compound_node (item);
        }
 
        public override void visit_class (Class item) {
-               process_compound_node (item, KeywordType.CLASS);
+               process_compound_node (item);
        }
 
        public override void visit_struct (Struct item) {
-               process_compound_node (item, KeywordType.STRUCT);
+               process_compound_node (item);
        }
 
        public override void visit_error_domain (ErrorDomain item) {
-               process_node (item, KeywordType.ERRORDOMAIN);
+               process_node (item);
        }
 
        public override void visit_enum ( Enum item) {
-               process_node (item, KeywordType.ENUM);
+               process_node (item);
        }
 
        public override void visit_property (Property item) {
-               process_node (item, KeywordType.PROPERTY);
+               process_node (item);
        }
 
        public override void visit_constant (Constant item) {
-               process_node (item, KeywordType.VARIABLE);
+               process_node (item);
        }
 
        public override void visit_field (Field item) {
-               process_node (item, KeywordType.VARIABLE);
+               process_node (item);
        }
 
        public override void visit_error_code (ErrorCode item) {
@@ -356,15 +291,15 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet {
        }
 
        public override void visit_delegate (Delegate item) {
-               process_node (item, KeywordType.DELEGATE);
+               process_node (item);
        }
 
        public override void visit_signal (Api.Signal item) {
-               process_node (item, KeywordType.SIGNAL);
+               process_node (item);
        }
 
        public override void visit_method (Method item) {
-               process_node (item, KeywordType.FUNCTION);
+               process_node (item);
        }
 }
 
index f05470da2dc041529ba17ad071cd1f3664015718..78b5580e436a2b66b19d35b028d5961a69f42aec 100644 (file)
@@ -4,7 +4,6 @@ NULL =
 AM_CFLAGS = \
        -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \
        $(LIBGVC_CFLAGS) \
-       $(LIBXML2_CFLAGS) \
        $(GLIB_CFLAGS) \
        $(LIBGEE_CFLAGS) \
        $(LIBVALA_CFLAGS) \
@@ -30,6 +29,7 @@ libvaladoc_la_VALASOURCES = \
        moduleloader.vala \
        settings.vala \
        markupwriter.vala \
+       devhelp-markupwriter.vala \
        documentation/commentscanner.vala \
        documentation/documentation.vala \
        documentation/documentationparser.vala \
@@ -137,13 +137,12 @@ 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 gmodule-2.0 --vapidir ../vapi --pkg libxml-2.0 --pkg libgvc --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 gmodule-2.0 --vapidir ../vapi --pkg libgvc --library valadoc-1.0 --basedir $(top_srcdir)/src/libvaladoc/ --save-temps $^
        touch $@
 
 
 libvaladoc_la_LIBADD = \
        $(LIBGVC_LIBS)     \
-       $(LIBXML2_LIBS)    \
        $(LIBGEE_LIBS)     \
        $(GLIB_LIBS)       \
        $(LIBVALA_LIBS)    \
diff --git a/src/libvaladoc/devhelp-markupwriter.vala b/src/libvaladoc/devhelp-markupwriter.vala
new file mode 100644 (file)
index 0000000..76ef87c
--- /dev/null
@@ -0,0 +1,87 @@
+/* markupwriter.vala
+ *
+ * Valadoc - a documentation tool for vala.
+ * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Author:
+ *     Didier 'Brosch Florian <flo.brosch@gmail.com>
+ */
+
+
+
+
+public class Valadoc.Devhelp.MarkupWriter : Valadoc.MarkupWriter {
+       public MarkupWriter (FileStream stream) {
+               base (stream);
+       }
+
+       protected override bool inline_element (string name) {
+               return name != "book";
+       }
+
+       protected override bool content_inline_element (string name) {
+               return name == "keyword"
+                       || name == "sub";
+       }
+
+       public MarkupWriter start_book (string title, string lang, string link, string name, string version, string author) {
+               this.start_tag ("book", {"xmlns", "http://www.devhelp.net/book", "title", title, "language", lang, "name", name, "version", version, "author", author, "link", link});
+               return this;
+       }
+
+       public MarkupWriter end_book () {
+               this.end_tag ("book");
+               return this;
+       }
+
+       public MarkupWriter start_functions () {
+               this.start_tag ("functions");
+               return this;
+       }
+
+       public MarkupWriter end_functions () {
+               this.end_tag ("functions");
+               return this;
+       }
+
+       public MarkupWriter start_chapters () {
+               this.start_tag ("chapters");
+               return this;
+       }
+
+       public MarkupWriter end_chapters () {
+               this.end_tag ("chapters");
+               return this;
+       }
+
+       public MarkupWriter start_sub (string name, string link) {
+               this.start_tag ("sub", {"name", name, "link", link});
+               return this;
+       }
+
+       public MarkupWriter end_sub () {
+               this.end_tag ("sub");
+               return this;
+       }
+
+       public MarkupWriter keyword (string name, string type, string link) {
+               this.start_tag ("keyword", {"type", type, "name", name, "link", link});
+               this.end_tag ("keyword");
+               return this;
+       }
+}
+