[valadoc] Add initial support for valadoc.org



commit 535b8665ff9cfd95b209fef28bb886d7b10ddfc1
Author: Florian Brosch <flo brosch gmail com>
Date:   Sat Oct 17 04:18:07 2009 +0200

    Add initial support for valadoc.org

 configure.in                                       |    4 +-
 src/doclets/Makefile.am                            |    8 +-
 src/doclets/htmlhelpers/doclet/htmlrenderer.vala   |    2 +-
 src/doclets/valadoc.org/Makefile.am                |   56 ++-
 src/doclets/valadoc.org/{doclet => }/doclet.vala   |  477 +++------------
 src/doclets/valadoc.org/doclet/Makefile.am         |   54 --
 .../valadoc.org/html-apiwriter/apiwriter-vala.vala |  631 --------------------
 .../valadoc.org/html-apiwriter/apiwriter.vala      |   97 ---
 src/doclets/valadoc.org/html/attribute.vala        |   36 --
 src/doclets/valadoc.org/html/block.vala            |  141 -----
 src/doclets/valadoc.org/html/htmlwriter.vala       |  105 ----
 src/doclets/valadoc.org/html/inline.vala           |  100 ---
 src/doclets/valadoc.org/taglets/Makefile.am        |   78 ---
 src/doclets/valadoc.org/taglets/bold.vala          |   50 --
 src/doclets/valadoc.org/taglets/center.vala        |   50 --
 src/doclets/valadoc.org/taglets/constant.vala      |   40 --
 src/doclets/valadoc.org/taglets/headline.vala      |   43 --
 src/doclets/valadoc.org/taglets/image.vala         |   56 --
 src/doclets/valadoc.org/taglets/italic.vala        |   50 --
 src/doclets/valadoc.org/taglets/link.vala          |   58 --
 src/doclets/valadoc.org/taglets/list.vala          |   50 --
 src/doclets/valadoc.org/taglets/listelement.vala   |   55 --
 src/doclets/valadoc.org/taglets/notification.vala  |   51 --
 src/doclets/valadoc.org/taglets/nparagraph.vala    |   55 --
 src/doclets/valadoc.org/taglets/paragraph.vala     |   49 --
 src/doclets/valadoc.org/taglets/parameter.vala     |  130 ----
 .../valadoc.org/taglets/registerfunction.vala      |   51 --
 src/doclets/valadoc.org/taglets/return.vala        |   65 --
 src/doclets/valadoc.org/taglets/right.vala         |   51 --
 src/doclets/valadoc.org/taglets/see.vala           |   72 ---
 src/doclets/valadoc.org/taglets/since.vala         |   67 --
 src/doclets/valadoc.org/taglets/source.vala        |   50 --
 src/doclets/valadoc.org/taglets/string.vala        |   39 --
 src/doclets/valadoc.org/taglets/table.vala         |   53 --
 src/doclets/valadoc.org/taglets/tablecell.vala     |   88 ---
 src/doclets/valadoc.org/taglets/throws.vala        |  129 ----
 src/doclets/valadoc.org/taglets/typelink.vala      |   50 --
 src/doclets/valadoc.org/taglets/underline.vala     |   51 --
 src/doclets/valadoc.org/wikirenderer.vala          |  211 +++++++
 39 files changed, 361 insertions(+), 3142 deletions(-)
---
diff --git a/configure.in b/configure.in
index edbf8aa..482fd65 100644
--- a/configure.in
+++ b/configure.in
@@ -4,7 +4,7 @@ AC_INIT(Valadoc, 0.2, flo brosch gmail com)
 AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([src/valadoc/valadoc.vala])
 AC_CONFIG_HEADER([config.h])
-
+AM_MAINTAINER_MODE
 
 AC_PROG_CC
 AC_PROG_LIBTOOL
@@ -72,8 +72,6 @@ AC_CONFIG_FILES([Makefile
                  src/doclets/htm/Makefile
                  src/doclets/htm/doclet/Makefile
                  src/doclets/valadoc.org/Makefile
-                 src/doclets/valadoc.org/doclet/Makefile
-                 src/doclets/valadoc.org/taglets/Makefile
                  src/doclets/devhelp/Makefile
                  src/doclets/devhelp/doclet/Makefile
                  src/valadoc/Makefile])
diff --git a/src/doclets/Makefile.am b/src/doclets/Makefile.am
index 8f261c9..126e927 100644
--- a/src/doclets/Makefile.am
+++ b/src/doclets/Makefile.am
@@ -3,10 +3,10 @@
 NULL =
 
 
-SUBDIRS = \
-          htmlhelpers \
-          htm    \
-          devhelp    \
+SUBDIRS = htmlhelpers \
+          htm \
+          devhelp \
+          valadoc.org \
           $(NULL)
 
 
diff --git a/src/doclets/htmlhelpers/doclet/htmlrenderer.vala b/src/doclets/htmlhelpers/doclet/htmlrenderer.vala
index 8178062..0d0cd17 100755
--- a/src/doclets/htmlhelpers/doclet/htmlrenderer.vala
+++ b/src/doclets/htmlhelpers/doclet/htmlrenderer.vala
@@ -161,7 +161,7 @@ public class Valadoc.Html.HtmlRenderer : ContentRenderer {
 	public override void visit_embedded (Embedded element) {
 		var caption = element.caption;
 		if (caption == null) {
-			_stream.printf ("<img src=\"%s\" alt=\"%s\" />", element.url);
+			_stream.printf ("<img src=\"%s\" />", element.url);
 		} else {
 			_stream.printf ("<img src=\"%s\" alt=\"%s\" />", element.url, caption);
 		}
diff --git a/src/doclets/valadoc.org/Makefile.am b/src/doclets/valadoc.org/Makefile.am
index 5861f4c..08c0086 100755
--- a/src/doclets/valadoc.org/Makefile.am
+++ b/src/doclets/valadoc.org/Makefile.am
@@ -1,18 +1,58 @@
-# src/Makefile.am
+#src/Makefile.am
 
 
+libdoclet_VALASOURCES = \
+	doclet.vala \
+	wikirenderer.vala \
+	$(NULL)
 
 
+BUILT_SOURCES = libdoclet.vala.stamp
 
-if ENABLE_VALADOCORG
 
-NULL =
+libdoclet.vala.stamp: $(libdoclet_VALASOURCES)
+	$(VALAC) -C --vapidir ../../libvaladoc/ --vapidir ../../vapi/ --pkg valadoc-1.0 --pkg gee-1.0 --basedir . --save-temps $^
+	touch $@
 
 
-SUBDIRS = \
-          doclet      \
-          taglets     \
-          $(NULL)
+docletdir = $(libdir)/valadoc/plugins/valadoc.org/
 
 
-endif
+doclet_LTLIBRARIES = libdoclet.la
+
+
+libdoclet_la_SOURCES = \
+	libdoclet.vala.stamp \
+	$(libdoclet_VALASOURCES:.vala=.c) \
+	$(libdoclet_VALASOURCES:.vala=.h) \
+	$(NULL)
+
+
+
+AM_CFLAGS =  -g \
+	-I ../../libvaladoc/ \
+	$(GLIB_CFLAGS) \
+	$(LIBGEE_CFLAGS) \
+	$(LIBVALA_CFLAGS) \
+	$(NULL)
+
+
+libdoclet_la_LDFLAGS = -module -avoid-version \
+	$(NULL)
+
+
+libdoclet_la_LIBADD = \
+	../../libvaladoc/libvaladoc.la \
+	$(GLIB_LIBS)  \
+	$(LIBGEE_LIBS) \
+	$(LIBVALA_LIBS) \
+	$(NULL)
+
+
+EXTRA_DIST = $(libdoclet_VALASOURCES)  libdoclet.vala.stamp 
+
+
+MAINTAINERCLEANFILES = \
+	$(libdoclet_la_SOURCES) \
+	$(NULL)
+
diff --git a/src/doclets/valadoc.org/doclet/doclet.vala b/src/doclets/valadoc.org/doclet.vala
similarity index 59%
rename from src/doclets/valadoc.org/doclet/doclet.vala
rename to src/doclets/valadoc.org/doclet.vala
index ea00e20..aba527f 100755
--- a/src/doclets/valadoc.org/doclet/doclet.vala
+++ b/src/doclets/valadoc.org/doclet.vala
@@ -18,15 +18,13 @@
  */
 
 using Valadoc.Diagrams;
-using Valadoc.Html;
-using Valadoc;
-using GLib;
+using Valadoc.Content;
+using Valadoc.Api;
 using Gee;
 
 
-
-public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet {
-	private Valadoc.Html.ValaApiWriter langwriter = new Valadoc.Html.ValaApiWriter ();
+public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet, Api.Visitor {
+	private ValadocOrg.WikiRenderer _renderer = new ValadocOrg.WikiRenderer ();
 	private Settings settings;
 	private FileStream types;
 	private FileStream file;
@@ -34,32 +32,29 @@ public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet {
 
 	private void write_documentation (Api.Node element) {
 		if(element.documentation == null) {
-			return ;
+			return;
 		}
 
 		string path = Path.build_filename (this.settings.path, element.package.name, "documentation", element.full_name ());
 		FileStream file = FileStream.open (path, "w");
 		if (file == null) {
 			this.run = false;
-			return ;
+			return;
 		}
 
-		element.documentation.write_brief (file);
-		element.documentation.write_content (file);
+		_renderer.set_container (element);
+		_renderer.set_filestream (file);
+		_renderer.render (element.documentation);
 	}
 
-	public override void initialisation (Settings settings, Tree tree) {
+	public void process (Settings settings, Api.Tree tree) {
 		this.settings = settings;
 		this.run = true;
 
 		DirUtils.create (this.settings.path, 0777);
-
-		foreach (Package pkg in tree.get_package_list ()) {
-			pkg.visit (this);
-
-			if (this.run == false) {
-				break;
-			}
+		Gee.Collection<Package> packages = tree.get_package_list ();
+		foreach ( Package pkg in packages ) {
+			pkg.accept (this);
 		}
 	}
 
@@ -102,6 +97,7 @@ public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet {
 
 	// get_type_path()
 	private void write_insert_into_code_element (Api.Node element) {
+/*
 		string api = this.langwriter.from_documented_element (element).to_string (0, "");
 		string parentnodepkgname;
 		string parentnodename;
@@ -120,6 +116,7 @@ public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet {
 		}
 
 		this.write_insert_into_code_element_str(element.full_name(), element.package.name, api, parentnodepkgname, parentnodename);
+*/
 	}
 
 
@@ -127,333 +124,117 @@ public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet {
 		string path = Path.build_filename(this.settings.path, pkg.name);
 		if (GLib.DirUtils.create (path, 0777) == -1) {
 			this.run = false;
-			return ;
+			return;
 		}
 
 		if (GLib.DirUtils.create (Path.build_filename(path, pkg.name), 0777) == -1) {
 			this.run = false;
-			return ;
+			return;
 		}
 
 		if (GLib.DirUtils.create (Path.build_filename(path, "documentation"), 0777) == -1) {
 			this.run = false;
-			return ;
+			return;
 		}
 
 		string fpath = Path.build_filename(path, "dump.sql");
 		this.file = FileStream.open (fpath , "w");
 		if (this.file == null) {
 			this.run = false;
-			return ;
-		}
-
-
-		string tpath = Path.build_filename(path, "typenames.types");
-		this.types = FileStream.open (tpath , "w");
-		if (this.file == null) {
-			this.run = false;
-			return ;
+			return;
 		}
 
 		this.write_insert_into_valadoc_element_str (pkg.name, pkg.name, pkg.name);
-		if ( this.run == false ) {
-			return ;
+		if (this.run == false) {
+			return;
 		}
 
 		this.write_insert_into_valadoc_package (pkg);
-		if ( this.run == false ) {
-			return ;
+		if (this.run == false) {
+			return;
 		}
 
-		foreach (Namespace ns in pkg.get_namespace_list()) {
-			ns.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}
-		}
+		pkg.visit_namespaces (this);
 	}
 
 	public override void visit_namespace (Namespace ns) {
 		if (ns.name != null) {
 			this.write_insert_into_valadoc_element (ns);
 			if (this.run == false) {
-				return ;
+				return;
 			}
 
 			this.write_insert_into_code_element (ns);
 			if (this.run == false) {
-				return ;
+				return;
 			}
 		}
 
-		foreach (Namespace sns in ns.get_namespace_list()) {
-			sns.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Interface iface in ns.get_interface_list()) {
-			iface.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Class cl in ns.get_class_list()) {
-			cl.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Struct stru in ns.get_struct_list()) {
-			stru.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Enum en in ns.get_enum_list()) {
-			en.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (ErrorDomain err in ns.get_error_domain_list()) {
-			err.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Delegate del in ns.get_delegate_list()) {
-			del.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Method m in ns.get_method_list()) {
-			m.visit(this, ns);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Field f in ns.get_field_list()) {
-			f.visit(this, ns);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Constant c in ns.get_constant_list()) {
-			c.visit(this, ns);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
+		ns.visit_namespaces ( this );
+		ns.visit_classes ( this );
+		ns.visit_interfaces ( this );
+		ns.visit_structs ( this );
+		ns.visit_enums ( this );
+		ns.visit_error_domains ( this );
+		ns.visit_delegates ( this );
+		ns.visit_methods ( this );
+		ns.visit_fields ( this );
+		ns.visit_constants (this);
 
 		this.file.printf ("INSERT INTO `ValadocNamespaces` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(ns));
 		this.write_documentation (ns);
 	}
 
 	public override void visit_interface ( Interface iface ) {
-		this.types.printf ("%s|%s/%s|%s\n", iface.get_cname (), iface.package.name, iface.full_name(), "interface");
 		write_interface_diagram (iface, this.get_image_path (iface));
 
 		this.write_insert_into_valadoc_element (iface);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (iface);
 		if (this.run == false) {
-			return ;
-		}
-
-		foreach (Delegate del in iface.get_delegate_list()) {
-			del.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Struct stru in iface.get_struct_list()) {
-			stru.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Method m in iface.get_method_list()) {
-			m.visit(this, iface);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Field f in iface.get_field_list()) {
-			f.visit(this, iface);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Enum en in iface.get_enum_list()) {
-			en.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Class cl in iface.get_class_list()) {
-			cl.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
+			return;
 		}
 
-		foreach (Property prop in iface.get_property_list()) {
-			prop.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Signal sig in iface.get_signal_list()) {
-			sig.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Constant c in iface.get_constant_list()) {
-			c.visit(this, iface);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
+		iface.visit_classes ( this );
+		iface.visit_structs ( this );
+		iface.visit_enums ( this );
+		iface.visit_delegates ( this );
+		iface.visit_methods ( this );
+		iface.visit_signals ( this );
+		iface.visit_properties ( this );
+		iface.visit_fields ( this );
+		iface.visit_constants ( this );
 
 		this.file.printf ("INSERT INTO `ValadocInterfaces` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(iface));
 		this.write_documentation (iface);
 	}
 
 	public override void visit_class ( Class cl ) {
-		this.types.printf ("%s|%s/%s|%s\n", cl.get_cname (), cl.package.name, cl.full_name(), "class");
 		write_class_diagram (cl, this.get_image_path (cl));
 
 		this.write_insert_into_valadoc_element (cl);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (cl);
 		if (this.run == false) {
-			return ;
-		}
-
-		foreach (Method m in cl.get_construction_method_list ()) {
-			m.visit(this, cl);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Delegate del in cl.get_delegate_list()) {
-			del.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Struct stru in cl.get_struct_list()) {
-			stru.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Method m in cl.get_method_list()) {
-			m.visit(this, cl);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Field f in cl.get_field_list()) {
-			f.visit(this, cl);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Enum en in cl.get_enum_list()) {
-			en.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
+			return;
 		}
 
-		foreach (Class scl in cl.get_class_list()) {
-			scl.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Property prop in cl.get_property_list()) {
-			prop.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Signal sig in cl.get_signal_list()) {
-			sig.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Constant c in cl.get_constant_list()) {
-			c.visit(this, cl);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
+		cl.visit_construction_methods ( this );
+		cl.visit_classes ( this );
+		cl.visit_structs ( this );
+		cl.visit_enums ( this );
+		cl.visit_delegates ( this );
+		cl.visit_methods ( this );
+		cl.visit_signals ( this );
+		cl.visit_properties ( this );
+		cl.visit_fields ( this );
+		cl.visit_constants ( this );
 
 		string modifier;
 		if (cl.is_abstract) {
@@ -467,131 +248,73 @@ public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet {
 		this.write_documentation (cl);
 	}
 
-	public override void visit_struct ( Struct stru ) {
-		this.types.printf ("%s|%s/%s|%s\n", stru.get_cname (), stru.package.name, stru.full_name (), "struct");
+	public override void visit_struct (Struct stru) {
 		write_struct_diagram (stru, this.get_image_path (stru));
 
 		this.write_insert_into_valadoc_element (stru);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (stru);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
-		foreach (Method m in stru.get_construction_method_list ()) {
-			m.visit(this, stru);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Method m in stru.get_method_list()) {
-			m.visit(this, stru);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Field f in stru.get_field_list()) {
-			f.visit(this, stru);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (Constant c in stru.get_constant_list()) {
-			c.visit(this, stru);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
+		stru.visit_construction_methods ( this );
+		stru.visit_methods ( this );
+		stru.visit_fields ( this );
+		stru.visit_constants ( this );
 
 		this.file.printf ("INSERT INTO `ValadocStructs` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(stru));
 		this.write_documentation (stru);
 	}
 
 	public override void visit_error_domain ( ErrorDomain errdom ) {
-		this.types.printf ("%s|%s/%s|%s\n", errdom.get_cname (), errdom.package.name, errdom.full_name (), "errordomain");
 		this.write_insert_into_valadoc_element (errdom);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (errdom);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
-		foreach (Method m in errdom.get_method_list()) {
-			m.visit(this, errdom);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (ErrorCode errc in errdom.get_error_code_list()) {
-			errc.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
+		errdom.visit_error_codes ( this );
+		errdom.visit_methods ( this );
 
 		this.file.printf ("INSERT INTO `ValadocErrordomains` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(errdom));
 		this.write_documentation (errdom);
 	}
 
 	public override void visit_enum ( Enum en ) {
-		this.types.printf ("%s|%s/%s|%s\n", en.get_cname (), en.package.name, en.full_name (), "enum");
 		this.write_insert_into_valadoc_element (en);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (en);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
-		foreach (Method m in en.get_method_list()) {
-			m.visit(this, en);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
-
-		foreach (EnumValue enval in en.get_enum_values()) {
-			enval.visit(this);
-
-			if (this.run == false) {
-				return ;
-			}			
-		}
+		en.visit_enum_values ( this );
+		en.visit_methods ( this );
 
 		this.file.printf ("INSERT INTO `ValadocEnum` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(en));
 		this.write_documentation (en);
 	}
 
 	public override void visit_property ( Property prop ) {
-		string pcname = (prop.parent is Class)? ((Class)prop.parent).get_cname() : ((Interface)prop.parent).get_cname ();
-		this.types.printf ("%s:%s|%s/%s|%s\n", pcname, prop.name, prop.package.name, prop.full_name (), "property");
 		this.write_insert_into_valadoc_element (prop);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (prop);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		string modifier;
@@ -612,32 +335,30 @@ public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet {
 		this.write_documentation (prop);
 	}
 
-	public override void visit_constant ( Constant constant, ConstantHandler parent ) {
-		this.types.printf ("%s|%s/%s|%s\n", constant.get_cname (), constant.package.name, constant.full_name (), "const");
+	public override void visit_constant (Constant constant) {
 		this.write_insert_into_valadoc_element (constant);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (constant);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.file.printf ("INSERT INTO `ValadocConstants` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(constant));
 		this.write_documentation (constant);
 	}
 
-	public override void visit_field ( Field field, FieldHandler parent ) {
-		this.types.printf ("%s|%s/%s|%s\n", field.get_cname (), field.package.name, field.full_name (), "field");
+	public override void visit_field (Field field) {
 		this.write_insert_into_valadoc_element (field);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (field);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		string modifier;
@@ -653,31 +374,29 @@ public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet {
 	}
 
 	public override void visit_error_code ( ErrorCode errcode ) {
-		this.types.printf ("%s|%s/%s|%s\n", errcode.get_cname (), errcode.package.name, errcode.full_name (), "errorcode");
 		this.write_insert_into_valadoc_element (errcode);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (errcode);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.file.printf ("INSERT INTO `ValadocErrorcodes` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n" , this.get_type_path(errcode));
 		this.write_documentation (errcode);
 	}
 
-	public override void visit_enum_value ( EnumValue enval ) {
-		this.types.printf ("%s|%s/%s|%s\n", enval.get_cname (), enval.package.name, enval.full_name (), "enumvalue");
+	public override void visit_enum_value (Api.EnumValue enval) {
 		this.write_insert_into_valadoc_element (enval);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (enval);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.file.printf ("INSERT INTO `ValadocEnumvalues` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(enval));
@@ -685,15 +404,14 @@ public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet {
 	}
 
 	public override void visit_delegate ( Delegate del ) {
-		this.types.printf ("%s|%s/%s|%s\n", del.get_cname (), del.package.name, del.full_name (), "delegate");
 		this.write_insert_into_valadoc_element (del);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (del);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		string modifier;
@@ -708,33 +426,30 @@ public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet {
 		this.write_documentation (del);
 	}
 
-	public override void visit_signal ( Signal sig ) {
-		string pcname = (sig.parent is Class)? ((Class)sig.parent).get_cname() : ((Interface)sig.parent).get_cname ();
-		this.types.printf ("%s::%s|%s/%s|%s\n", pcname, sig.name, sig.package.name, sig.full_name (), "signal");
+	public override void visit_signal (Api.Signal sig) {
 		this.write_insert_into_valadoc_element (sig);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (sig);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.file.printf ("INSERT INTO `ValadocSignals` (`id`) VALUES ((SELECT `id` FROM `ValadocApiElement` WHERE BINARY `fullname`='%s' LIMIT 1));\n", this.get_type_path(sig));
 		this.write_documentation (sig);
 	}
 
-	public override void visit_method ( Method m, Valadoc.MethodHandler parent ) {
-		this.types.printf ("%s|%s/%s|%s\n", m.get_cname (), m.package.name, m.full_name (), "method");
+	public override void visit_method (Method m) {
 		this.write_insert_into_valadoc_element (m);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 		this.write_insert_into_code_element (m);
 		if (this.run == false) {
-			return ;
+			return;
 		}
 
 
@@ -774,6 +489,6 @@ public class Valadoc.ValdocOrg.Doclet : Valadoc.Doclet {
 
 [ModuleInit]
 public Type register_plugin ( ) {
-	return typeof ( Valadoc.ValdocOrg.Doclet );
+	return typeof (Valadoc.ValdocOrg.Doclet);
 }
 
diff --git a/src/doclets/valadoc.org/wikirenderer.vala b/src/doclets/valadoc.org/wikirenderer.vala
new file mode 100755
index 0000000..716134e
--- /dev/null
+++ b/src/doclets/valadoc.org/wikirenderer.vala
@@ -0,0 +1,211 @@
+/* wikirenderer.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:
+ * 	Florian Brosch <flo brosch gmail com>
+ */
+
+using Valadoc.Content;
+
+
+public class Valadoc.ValadocOrg.WikiRenderer : ContentRenderer {
+	private Documentation? _container;
+	private unowned FileStream _stream;
+
+	public void set_container (Documentation? container) {
+		_container = container;
+	}
+
+	public void set_filestream (FileStream stream) {
+		_stream = stream;
+	}
+
+	public override void render (ContentElement element) {
+		element.accept (this);
+	}
+
+	public override void render_children (ContentElement element) {
+		element.accept_children (this);
+	}
+
+	private delegate void TagletWrite (Taglet taglet);
+
+	private void write_taglets (Gee.List<Taglet> taglets, TagletWrite write) {
+		foreach (var taglet in taglets) {
+			write (taglet);
+		}
+	}
+
+	public override void visit_comment (Comment element) {
+		Gee.List<Taglet> taglets;
+
+		taglets = element.find_taglets ((Api.Node) _container, typeof (Taglets.Since));
+		write_taglets (
+			taglets,
+			(taglet) => {
+				var since = taglet as Taglets.Since;
+				_stream.printf ("\n\nSince %s.\n", since.version);
+			});
+
+		taglets = element.find_taglets ((Api.Node) _container, typeof (Taglets.Deprecated));
+		write_taglets (
+			taglets,
+			(taglet) => {
+				_stream.puts ("\n\nDeprecated.\n\n");
+			});
+
+		// Write description
+		element.accept_children (this);
+
+		taglets = element.find_taglets ((Api.Node) _container, typeof (Taglets.Param));
+		write_taglets (
+			taglets,
+			(taglet) => {
+				var param = taglet as Taglets.Param;
+				_stream.printf ("@param %s ", param.parameter_name);
+				param.accept_children (this);
+				_stream.putc ('\n');
+			});
+
+		taglets = element.find_taglets ((Api.Node) _container, typeof (Taglets.Return));
+		write_taglets (
+			taglets,
+			(taglet) => {
+				var param = taglet as Taglets.Return;
+				_stream.puts ("@return ");
+				param.accept_children (this);
+				_stream.putc ('\n');
+			});
+
+		taglets = element.find_taglets ((Api.Node) _container, typeof (Taglets.Throws));
+		write_taglets (
+			taglets,
+			(taglet) => {
+				var exception = taglet as Taglets.Throws;
+				_stream.printf ("@throws %s ", exception.error_domain_name);
+				exception.accept_children (this);
+				_stream.putc ('\n');
+			});
+
+		taglets = element.find_taglets ((Api.Node) _container, typeof (Taglets.See));
+		write_taglets (
+			taglets,
+			(taglet) => {
+				var see = taglet as Taglets.See;
+				_stream.printf ("@see %s/%s\n", see.symbol.package.name, see.symbol.full_name ());
+			});
+	}
+
+	public override void visit_embedded (Embedded element) {
+		var caption = element.caption;
+		if (caption == null) {
+			_stream.printf ("{{{%s}}}", element.url);
+		} else {
+			_stream.printf ("{{{%s|%s}}}", element.url, caption);
+		}
+	}
+
+	public override void visit_headline (Headline element) {
+		_stream.puts (string.nfill (element.level+1, '='));
+		element.accept_children (this);
+		_stream.putc ('\n');
+	}
+
+	public override void visit_link (Link element) {
+		var label = element.label;
+		_stream.printf ("[[%s|%s]]",
+		                element.url,
+		                (label == null || label == "") ? element.url : label);
+	}
+
+	public override void visit_symbol_link (SymbolLink element) {
+		_stream.printf ("{ @link %s/%s }", element.symbol.package.name, element.symbol.full_name ());
+	}
+
+	public override void visit_list (Content.List element) {
+	}
+
+	public override void visit_list_item (ListItem element) {
+	}
+
+	public override void visit_page (Page element) {
+		element.accept_children (this);
+	}
+
+	public override void visit_paragraph (Paragraph element) {
+		_stream.printf ("\n\n");
+		element.accept_children (this);
+	}
+
+	public override void visit_run (Run element) {
+		string tag = null;
+		switch (element.style) {
+		case Run.Style.BOLD:
+			tag = "++";
+			break;
+		case Run.Style.ITALIC:
+			tag = "//";
+			break;
+		case Run.Style.UNDERLINED:
+			tag = "__";
+			break;
+/*		case Run.Style.MONOSPACED:
+			break;
+		case Run.Style.STROKE:
+			break;
+*/		}
+		if (tag != null) {
+			_stream.puts (tag);
+		}
+		element.accept_children (this);
+		if (tag != null) {
+			_stream.puts (tag);
+		}
+	}
+
+	public override void visit_source_code (SourceCode element) {
+		_stream.printf ("\n{{{\n");
+		_stream.printf (element.code);
+		_stream.printf ("\n}}}\n");
+	}
+
+	public override void visit_table (Table element) {
+		_stream.putc ('\n');
+		element.accept_children (this);
+		_stream.putc ('\n');
+	}
+
+	public override void visit_table_cell (TableCell element) {
+		_stream.putc (' ');
+		element.accept_children (this);
+		_stream.puts (" ||");
+	}
+
+	public override void visit_table_row (TableRow element) {
+		element.accept_children (this);
+		_stream.putc ('\n');
+	}
+
+	public override void visit_taglet (Taglet element) {
+	}
+
+	public override void visit_text (Text element) {
+		_stream.puts (element.content);
+	}
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]