[valadoc] libvaladoc: drop dependency on libvala



commit ddb688bf16af9eccbaf7201acdb917ad1e0e0fc7
Author: Florian Brosch <flo brosch gmail com>
Date:   Thu Jul 21 20:04:32 2011 +0200

    libvaladoc: drop dependency on libvala

 src/driver/0.13.x/treebuilder.vala                 |    6 +-
 src/libvaladoc/Makefile.am                         |   12 +-
 src/libvaladoc/api/package.vala                    |    2 +-
 src/libvaladoc/api/sourcefile.vala                 |    6 +-
 src/libvaladoc/api/tree.vala                       |    7 +-
 .../documentation/documentationparser.vala         |    8 +-
 src/libvaladoc/errorreporter.vala                  |    9 +-
 src/libvaladoc/filehelper.vala                     |   77 +++++-
 src/libvaladoc/importer/gircomment.vala            |   56 ++++
 .../importer/girdocumentationbuilder.vala          |   21 +-
 .../importer/girdocumentationimporter.vala         |  223 ++++++++-------
 src/libvaladoc/markupreader.vala                   |  306 ++++++++++++++++++++
 src/libvaladoc/markupsourcelocation.vala           |   39 +++
 src/libvaladoc/markuptokentype.vala                |   50 ++++
 src/libvaladoc/valadoc-1.0.deps.in                 |    1 -
 src/libvaladoc/valadoc-1.0.pc.in                   |    2 +-
 src/valadoc/valadoc.vala                           |    2 +-
 17 files changed, 683 insertions(+), 144 deletions(-)
---
diff --git a/src/driver/0.13.x/treebuilder.vala b/src/driver/0.13.x/treebuilder.vala
index a4a05ec..9a10c1b 100644
--- a/src/driver/0.13.x/treebuilder.vala
+++ b/src/driver/0.13.x/treebuilder.vala
@@ -445,7 +445,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 
 		var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path);
 		context.add_source_file (vfile);
-		Package vdpkg = new Package (vfile, pkg, true, null);
+		Package vdpkg = new Package (pkg, true, null);
 		register_source_file (register_package (vdpkg), vfile);
 
 		add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg);
@@ -502,7 +502,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 					var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath);
 
 					if (source_package == null) {
-						source_package = register_package (new Package (source_file, settings.pkg_name, false, null));
+						source_package = register_package (new Package (settings.pkg_name, false, null));
 					}
 
 					register_source_file (source_package, source_file);
@@ -525,7 +525,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 					file_name = file_name.substring (0, file_name.length - ".vapi".length);
 
 					var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath);
-					Package vdpkg = new Package (vfile, file_name, true, null);
+					Package vdpkg = new Package (file_name, true, null);
 					context.add_source_file (vfile);
 
 					register_source_file (register_package (vdpkg), vfile);
diff --git a/src/libvaladoc/Makefile.am b/src/libvaladoc/Makefile.am
index 64c277b..affc2e6 100755
--- a/src/libvaladoc/Makefile.am
+++ b/src/libvaladoc/Makefile.am
@@ -9,7 +9,6 @@ AM_CFLAGS = \
 	$(LIBGVC_CFLAGS) \
 	$(GLIB_CFLAGS) \
 	$(LIBGEE_CFLAGS) \
-	$(LIBVALA_CFLAGS) \
 	$(GMODULE_CFLAGS) \
 	$(NULL)
 
@@ -31,6 +30,9 @@ libvaladoc_la_VALASOURCES = \
 	markupwriter.vala \
 	devhelp-markupwriter.vala \
 	ctyperesolver.vala \
+	markupsourcelocation.vala \
+	markuptokentype.vala \
+	markupreader.vala \
 	documentation/girdocumentationscanner.vala \
 	documentation/commentscanner.vala \
 	documentation/documentation.vala \
@@ -39,7 +41,7 @@ libvaladoc_la_VALASOURCES = \
 	documentation/wikiscanner.vala \
 	importer/girdocumentationimporter.vala \
 	importer/documentationimporter.vala \
-	importer/girdocumentationbuilder.vala \
+	importer/gircomment.vala \
 	importer/valadocdocumentationimporter.vala \
 	importer/valadocdocumentationimporterscanner.vala \
 	api/symbolaccessibility.vala \
@@ -158,7 +160,7 @@ libvaladocincludedir = $(includedir)/
 
 
 libvaladoc.vala.stamp: $(libvaladoc_la_VALASOURCES)
-	$(VALAC) $(VALAFLAGS) -C -H valadoc-1.0.h --pkg gee-1.0 --pkg $(VALA_PACKAGE) --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 $^
+	$(VALAC) $(VALAFLAGS) -C -H valadoc-1.0.h --pkg gee-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 $@
 
 
@@ -169,7 +171,6 @@ libvaladoc_la_LIBADD = \
 	$(LIBGVC_LIBS)     \
 	$(LIBGEE_LIBS)     \
 	$(GLIB_LIBS)       \
-	$(LIBVALA_LIBS)    \
 	$(GMODULE_LIBS)    \
 	$(NULL)
 
@@ -192,9 +193,6 @@ MAINTAINERCLEANFILES =                        \
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = valadoc-1.0.pc
 
-valadoc-1.0.deps: valadoc-1.0.deps.in
-	cat $^ > $@
-	echo $(VALA_PACKAGE) >> $@
 
 vapidir = $(datadir)/vala/vapi
 vapi_DATA =     \
diff --git a/src/libvaladoc/api/package.vala b/src/libvaladoc/api/package.vala
index f89e152..6656b48 100755
--- a/src/libvaladoc/api/package.vala
+++ b/src/libvaladoc/api/package.vala
@@ -72,7 +72,7 @@ public class Valadoc.Api.Package : Node {
 		return this._dependencies.read_only_view;
 	}
 
-	public Package (Vala.SourceFile vfile, string name, bool is_package, void* data) {
+	public Package (string name, bool is_package, void* data) {
 		base (null, null, name, data);
 
 		this.is_package = is_package;
diff --git a/src/libvaladoc/api/sourcefile.vala b/src/libvaladoc/api/sourcefile.vala
index f0e6721..6ac6720 100644
--- a/src/libvaladoc/api/sourcefile.vala
+++ b/src/libvaladoc/api/sourcefile.vala
@@ -23,13 +23,13 @@
 /**
  * Represents a source file
  */
-public class SourceFile : Object {
+public class Valadoc.Api.SourceFile : Object {
 	public string relative_path {
 		private set;
 		get;
 	}
 
-	public string relative_c_path {
+	public string? relative_c_path {
 		private set;
 		get;
 	}
@@ -38,7 +38,7 @@ public class SourceFile : Object {
 		return Path.get_basename (relative_path);
 	}
 
-	public SourceFile (string relative_path, string relative_c_path) {
+	public SourceFile (string relative_path, string? relative_c_path) {
 		this.relative_c_path = relative_c_path;
 		this.relative_path = relative_path;
 	}
diff --git a/src/libvaladoc/api/tree.vala b/src/libvaladoc/api/tree.vala
index c662058..bddb1bf 100755
--- a/src/libvaladoc/api/tree.vala
+++ b/src/libvaladoc/api/tree.vala
@@ -44,11 +44,6 @@ public class Valadoc.Api.Tree {
 		this.packages.add (package);
 	}
 
-	internal Vala.CodeContext context {
-		private set;
-		get;
-	}
-
 	/**
 	 * The root of the wiki tree.
 	 */
@@ -276,7 +271,7 @@ public class Valadoc.Api.Tree {
 			}
 
 			if (imported == false) {
-				Vala.Report.error (null, "%s not found in specified import directories".printf (pkg_name));
+				reporter.simple_error ("%s not found in specified import directories", pkg_name);
 			}
 		}
 	}
diff --git a/src/libvaladoc/documentation/documentationparser.vala b/src/libvaladoc/documentation/documentationparser.vala
index f2b2ae7..eee9f01 100755
--- a/src/libvaladoc/documentation/documentationparser.vala
+++ b/src/libvaladoc/documentation/documentationparser.vala
@@ -87,14 +87,14 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
 		}
 	}
 
-	public Comment? parse_gir_comment (Api.Node element, GirDocumentationBuilder doc) {
+	public Comment? parse_gir_comment (Api.Node element, GirComment doc) {
 		try {
 			_stack.clear ();
 
 			if (doc.content != null) {
 				_parser = _gir_parser;
 				_scanner = _gir_scanner;
-				_gir_parser.parse (doc.content, doc.source_reference.file.filename, doc.source_reference.first_line, doc.source_reference.first_column);
+				_gir_parser.parse (doc.content, doc.file.get_name (), doc.first_line, doc.first_column);
 			} else {
 				push (_factory.create_comment ());
 			}
@@ -105,7 +105,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
 
 			if (doc.return_value != null && !(element is Api.Method && ((Api.Method) element).is_constructor)) {
 				push (_factory.create_taglet ("return"));
-				_gir_taglet_parser.parse (doc.return_value.content, doc.return_value.source_reference.file.filename, doc.return_value.source_reference.first_line, doc.return_value.source_reference.first_column);
+				_gir_taglet_parser.parse (doc.return_value.content, doc.return_value.file.get_name (), doc.return_value.first_line, doc.return_value.first_column);
 			}
 
 			var iter = doc.parameters.map_iterator ();
@@ -116,7 +116,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
 					var param = _factory.create_taglet ("param") as Taglets.Param;
 					param.parameter_name = key;
 					push (param);
-					_gir_taglet_parser.parse (val.content, val.source_reference.file.filename, val.source_reference.first_line, val.source_reference.first_column);
+					_gir_taglet_parser.parse (val.content, val.file.get_name (), val.first_line, val.first_column);
 				}
 			}
 
diff --git a/src/libvaladoc/errorreporter.vala b/src/libvaladoc/errorreporter.vala
index 48e2a6c..0ff4923 100755
--- a/src/libvaladoc/errorreporter.vala
+++ b/src/libvaladoc/errorreporter.vala
@@ -38,11 +38,8 @@ public class Valadoc.ErrorReporter : Object {
 	}
 
 	public unowned GLib.FileStream stream {
-		get; set;
-	}
-
-	public Vala.Report? vreporter {
-		get; set;
+		get;
+		set;
 	}
 
 	public ErrorReporter () {
@@ -112,14 +109,12 @@ public class Valadoc.ErrorReporter : Object {
 		this._errors++;
 	}
 
-	//TODO
 	public void error (string file, long line, long startpos, long endpos, string errline, string msg_format, ...) {
 		var args = va_list();
 		this.msg (ErrorType.ERROR, file, line, startpos, endpos, errline, msg_format, args);
 		this._errors++;
 	}
 
-	//TODO
 	public void warning (string file, long line, long startpos, long endpos, string errline, string msg_format, ...) {
 		var args = va_list();
 		this.msg (ErrorType.WARNING, file, line, startpos, endpos, errline, msg_format, args);
diff --git a/src/libvaladoc/filehelper.vala b/src/libvaladoc/filehelper.vala
index d8b2ef6..137aff1 100755
--- a/src/libvaladoc/filehelper.vala
+++ b/src/libvaladoc/filehelper.vala
@@ -108,14 +108,87 @@ namespace Valadoc {
 		return true;
 	}
 
+
+	private inline bool ends_with_dir_separator (string s) {
+		// --- ported from libvala ---
+		return Path.is_dir_separator (s.get_char (s.length - 1));
+	}
+
 	/**
 	 * Returns canonicalized absolute pathname
 	 *
 	 * @param basedir the path being checked
 	 * @return a canonicalized absolute pathname
 	 */
-	public string realpath (string basedir) {
-		return Vala.CodeContext.realpath (basedir);
+	public string realpath (string name) {
+		// --- ported from libvala ---
+
+		string rpath;
+
+		// start of path component
+		weak string start;
+		// end of path component
+		weak string end;
+
+		if (!Path.is_absolute (name)) {
+			// relative path
+			rpath = Environment.get_current_dir ();
+
+			start = end = name;
+		} else {
+			// set start after root
+			start = end = Path.skip_root (name);
+
+			// extract root
+			rpath = name.substring (0, (int) ((char*) start - (char*) name));
+		}
+
+		long root_len = (long) ((char*) Path.skip_root (rpath) - (char*) rpath);
+
+		for (; start.get_char () != 0; start = end) {
+			// skip sequence of multiple path-separators
+			while (Path.is_dir_separator (start.get_char ())) {
+				start = start.next_char ();
+			}
+
+			// find end of path component
+			long len = 0;
+			for (end = start; end.get_char () != 0 && !Path.is_dir_separator (end.get_char ()); end = end.next_char ()) {
+				len++;
+			}
+
+			if (len == 0) {
+				break;
+			} else if (len == 1 && start.get_char () == '.') {
+				// do nothing
+			} else if (len == 2 && start.has_prefix ("..")) {
+				// back up to previous component, ignore if at root already
+				if (rpath.length > root_len) {
+					do {
+						rpath = rpath.substring (0, rpath.length - 1);
+					} while (!ends_with_dir_separator (rpath));
+				}
+			} else {
+				if (!ends_with_dir_separator (rpath)) {
+					rpath += Path.DIR_SEPARATOR_S;
+				}
+
+				rpath += start.substring (0, len);
+			}
+		}
+
+		if (rpath.length > root_len && ends_with_dir_separator (rpath)) {
+			rpath = rpath.substring (0, rpath.length - 1);
+		}
+
+		if (Path.DIR_SEPARATOR != '/') {
+			// don't use backslashes internally,
+			// to avoid problems in #include directives
+			string[] components = rpath.split ("\\");
+			rpath = string.joinv ("/", components);
+		}
+
+		return rpath;
 	}
 }
 
diff --git a/src/libvaladoc/importer/gircomment.vala b/src/libvaladoc/importer/gircomment.vala
new file mode 100755
index 0000000..7caa679
--- /dev/null
+++ b/src/libvaladoc/importer/gircomment.vala
@@ -0,0 +1,56 @@
+/* DocumentationBuilderimporter.vala
+ *
+ * Copyright (C) 2010-2011 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 Valadoc;
+using Gee;
+
+
+/**
+ * A documentation comment used by valadoc
+ */
+public class Valadoc.Importer.GirComment : Valadoc.Api.SourceComment {
+	private HashMap<string, Api.SourceComment> _parameters = new HashMap<string, Api.SourceComment> ();
+
+	public Map<string, Api.SourceComment> parameters {
+		owned get { return _parameters.read_only_view; }
+	}
+
+	public Api.SourceComment? return_value {
+		internal set;
+		get;
+	}
+
+	public GirComment (string content, Api.SourceFile file, int first_line, int first_column, int last_line, int last_column) {
+		base (content, file, first_line, first_column, last_line, last_column);
+		return_value = null;
+	}
+
+	internal void add_parameter (string name, Api.SourceComment comment) {
+		_parameters.set (name, comment);
+	}
+
+	public bool is_empty () {
+		return return_value == null && (content == null || content == "") && parameters.is_empty;
+	}
+}
+
diff --git a/src/libvaladoc/importer/girdocumentationbuilder.vala b/src/libvaladoc/importer/girdocumentationbuilder.vala
old mode 100755
new mode 100644
index d502cf3..7c4bc0f
--- a/src/libvaladoc/importer/girdocumentationbuilder.vala
+++ b/src/libvaladoc/importer/girdocumentationbuilder.vala
@@ -28,24 +28,31 @@ using Gee;
 /**
  * A documentation comment used by valadoc
  */
-public class Valadoc.Importer.GirDocumentationBuilder : Vala.Comment {
-	private HashMap<string, Vala.Comment> _parameters = new HashMap<string, Vala.Comment> ();
+public class Valadoc.Importer.GirComment : Valadoc.Api.Comment {
+	private HashMap<string, Api.Comment> _parameters = new HashMap<string, APi.Comment> ();
 
-	public Map<string, Vala.Comment> parameters { owned get { return _parameters.read_only_view; } }
+	public Map<string, Api.Comment> parameters {
+		owned get { return _parameters.read_only_view; }
+	}
 
-	public Vala.Comment? return_value { get; internal set; }
+	public Api.Comment? return_value {
+		internal set;
+		get;
+	}
 	
-	public GirDocumentationBuilder.empty (Vala.SourceReference _source_reference) {
+	//TODO
+	public GirComment.empty (Api.SourceReference _source_reference) {
 		base ("", _source_reference);
 		return_value = null;
 	}
 
-	public GirDocumentationBuilder (Vala.Comment comment) {
+	//TODO
+	public GirComment (Api.Comment comment) {
 		base (comment.content, comment.source_reference);
 		return_value = null;
 	}
 
-	internal void add_parameter (string name, Vala.Comment comment) {
+	internal void add_parameter (string name, Api.Comment comment) {
 		_parameters.set (name, comment);
 	}
 
diff --git a/src/libvaladoc/importer/girdocumentationimporter.vala b/src/libvaladoc/importer/girdocumentationimporter.vala
index 19c5999..d83bc2d 100755
--- a/src/libvaladoc/importer/girdocumentationimporter.vala
+++ b/src/libvaladoc/importer/girdocumentationimporter.vala
@@ -1,6 +1,6 @@
 /* DocumentationBuilderimporter.vala
  *
- * Copyright (C) 2010 Florian Brosch
+ * Copyright (C) 2010-2011 Florian Brosch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,25 +26,52 @@ using Gee;
 
 public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 	DocumentationParser docparser;
-	Vala.MarkupReader reader;
+	MarkupReader reader;
 
-	Vala.SourceFile current_source_file;
-	Vala.SourceLocation begin;
-	Vala.SourceLocation end;
-	Vala.MarkupTokenType current_token;
+	ErrorReporter reporter;
 
-	Vala.DataType dummy_type;
+	Api.SourceFile current_source_file;
+	MarkupSourceLocation begin;
+	MarkupSourceLocation end;
+	MarkupTokenType current_token;
 
 	LinkedList<string> type_cname_stack = new LinkedList<string> ();
 
 	int anonymous_param_count = 0;
 
-	public override string file_extension { get { return "gir"; } }
+	public override string file_extension {
+		get { return "gir"; }
+	}
+
+	private GirComment create_empty_gir_comment () {
+		return new GirComment ("", current_source_file, begin.line, begin.column, end.line, end.column);
+	}
+
+	private GirComment create_gir_comment (Api.SourceComment sc) {
+		return new GirComment (sc.content, sc.file, sc.first_line, sc.first_column, sc.last_line, sc.last_column);
+	}
+
+	private void error (string msg_format, ...) {
+		va_list args = va_list();
+		string msg = msg_format.vprintf (args);
+
+		string code_line = null;
 
-	public GirDocumentationImporter (Api.Tree tree, DocumentationParser docparser, ModuleLoader modules, Settings settings) {
+		unowned string start_src_line = ((string) begin.pos).utf8_offset (-begin.column);
+		int offset = start_src_line.index_of_char ('\n');
+		if (offset == -1) {
+			code_line = start_src_line;
+		} else {
+			code_line = start_src_line.substring (0, offset);
+		}
+
+		reporter.error (current_source_file.get_name (), begin.line, begin.column, end.column, code_line, msg);
+	}
+
+	public GirDocumentationImporter (Api.Tree tree, DocumentationParser docparser, ModuleLoader modules, Settings settings, ErrorReporter reporter) {
 		base (tree, modules, settings);
-		this.dummy_type = new Vala.StructValueType (new Vala.Struct ("Dummy"));
 		this.docparser = docparser;
+		this.reporter = reporter;
 	}
 
 	public override void process (string filename) {
@@ -52,8 +79,8 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 	}
 
 	void parse_file (string gir_file) {
-		reader = new Vala.MarkupReader (gir_file);
-		this.current_source_file = new Vala.SourceFile (tree.context, Vala.SourceFileType.PACKAGE, GLib.Path.get_basename (gir_file));
+		this.current_source_file = new Api.SourceFile (gir_file, null);
+		reader = new MarkupReader (gir_file, reporter);
 
 		// xml prolog
 		next ();
@@ -64,14 +91,14 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		this.current_source_file = null;
 	}
 
-	Vala.Comment? parse_doc () {
+	Api.SourceComment? parse_doc () {
 		start_element ("doc");
 
-		Vala.Comment comment = null;
+		Api.SourceComment comment = null;
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.TEXT) {
-			comment = new Vala.Comment (reader.content, get_current_src ());
+		if (current_token == MarkupTokenType.TEXT) {
+			comment = new Api.SourceComment (reader.content, current_source_file, begin.line, begin.column, end.line, end.column);
 			next ();
 		}
 
@@ -84,28 +111,22 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 	}
 
 	void start_element (string name) {
-		if (current_token != Vala.MarkupTokenType.START_ELEMENT || reader.name != name) {
-			// error
-			Vala.Report.error (get_current_src (), "expected start element of `%s' instead of `%s'".printf (name, reader.name));
+		if (current_token != MarkupTokenType.START_ELEMENT || reader.name != name) {
+			error ("expected start element of `%s' instead of `%s'", name, reader.name);
 		}
 	}
 
 	void end_element (string name) {
-		if (current_token != Vala.MarkupTokenType.END_ELEMENT || reader.name != name) {
-			// error
-			Vala.Report.error (get_current_src (), "expected end element of `%s' instead of `%s'".printf (name, reader.name));
+		if (current_token != MarkupTokenType.END_ELEMENT || reader.name != name) {
+			error ("expected end element of `%s' instead of `%s'", name, reader.name);
 		}
 		next ();
 	}
 
-	Vala.SourceReference get_current_src () {
-		return new Vala.SourceReference (this.current_source_file, begin.line, begin.column, end.line, end.column);
-	}
-
 	void parse_repository () {
 		start_element ("repository");
 		next ();
-		while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+		while (current_token == MarkupTokenType.START_ELEMENT) {
 			if (reader.name == "namespace") {
 				parse_namespace ();
 			} else if (reader.name == "include") {
@@ -115,8 +136,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 			} else if (reader.name == "c:include") {
 				parse_c_include ();
 			} else {
-				// error
-				Vala.Report.error (get_current_src (), "unknown child element `%s' in `repository'".printf (reader.name));
+				error ("unknown child element `%s' in `repository'", reader.name);
 				break;
 			}
 		}
@@ -146,12 +166,12 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 
 		int level = 1;
 		while (level > 0) {
-			if (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+			if (current_token == MarkupTokenType.START_ELEMENT) {
 				level++;
-			} else if (current_token == Vala.MarkupTokenType.END_ELEMENT) {
+			} else if (current_token == MarkupTokenType.END_ELEMENT) {
 				level--;
-			} else if (current_token == Vala.MarkupTokenType.EOF) {
-				Vala.Report.error (get_current_src (), "unexpected end of file");
+			} else if (current_token == MarkupTokenType.EOF) {
+				error ("unexpected end of file");
 				break;
 			}
 			next ();
@@ -162,7 +182,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		start_element ("namespace");
 		next ();
 
-		while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+		while (current_token == MarkupTokenType.START_ELEMENT) {
 			if (reader.get_attribute ("introspectable") == "0") {
 				skip_element ();
 				continue;
@@ -195,8 +215,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 			} else if (reader.name == "constant") {
 				parse_constant ();
 			} else {
-				// error
-				Vala.Report.error (get_current_src (), "unknown child element `%s' in `namespace'".printf (reader.name));
+				error ("unknown child element `%s' in `namespace'", reader.name);
 				break;
 			}
 		}
@@ -206,6 +225,13 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 	void parse_alias () {
 		start_element ("alias");
 		next ();
+
+		while (current_token == MarkupTokenType.START_ELEMENT) {
+			if (reader.name != "alias") {
+				skip_element ();
+			}
+		}
+
 		end_element ("alias");
 	}
 
@@ -215,11 +241,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		type_cname_stack.add (cname);
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			process_documentation (cname, create_gir_comment (parse_doc ()));
 		}
 
-		while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+		while (current_token == MarkupTokenType.START_ELEMENT) {
 			if (reader.get_attribute ("introspectable") == "0") {
 				skip_element ();
 				continue;
@@ -243,11 +269,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		type_cname_stack.add (cname);
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			process_documentation (cname, create_gir_comment (parse_doc ()));
 		}
 
-		while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+		while (current_token == MarkupTokenType.START_ELEMENT) {
 			if (reader.get_attribute ("introspectable") == "0") {
 				skip_element ();
 				continue;
@@ -270,18 +296,18 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		string cname = reader.get_attribute ("c:identifier");
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			process_documentation (cname, create_gir_comment (parse_doc ()));
 		}
 
 		end_element ("member");
 	}
 
-	void parse_return_value (GirDocumentationBuilder doc) {
+	void parse_return_value (GirComment doc) {
 		start_element ("return-value");
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
 			doc.return_value = parse_doc ();
 		}
 
@@ -290,7 +316,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		end_element ("return-value");
 	}
 
-	void parse_parameter (GirDocumentationBuilder doc) {
+	void parse_parameter (GirComment doc) {
 		start_element ("parameter");
 		string name = reader.get_attribute ("name");
 
@@ -301,7 +327,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
 			doc.add_parameter (name, parse_doc ());
 		}
 
@@ -329,11 +355,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		type_cname_stack.add (cname);
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			process_documentation (cname, create_gir_comment (parse_doc ()));
 		}
 
-		while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+		while (current_token == MarkupTokenType.START_ELEMENT) {
 			if (reader.get_attribute ("introspectable") == "0") {
 				skip_element ();
 				continue;
@@ -354,8 +380,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 			} else if (reader.name == "union") {
 				parse_union ();
 			} else {
-				// error
-				Vala.Report.error (get_current_src (), "unknown child element `%s' in `record'".printf (reader.name));
+				error ("unknown child element `%s' in `record'", reader.name);
 				break;
 			}
 		}
@@ -370,11 +395,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		type_cname_stack.add (cname);
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			process_documentation (cname, create_gir_comment (parse_doc ()));
 		}
 
-		while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+		while (current_token == MarkupTokenType.START_ELEMENT) {
 			if (reader.get_attribute ("introspectable") == "0") {
 				skip_element ();
 				continue;
@@ -403,8 +428,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 			} else if (reader.name == "glib:signal") {
 				parse_signal ();
 			} else {
-				// error
-				Vala.Report.error (get_current_src (), "unknown child element `%s' in `class'".printf (reader.name));
+				error ("unknown child element `%s' in `class'", reader.name);
 				break;
 			}
 		}
@@ -419,11 +443,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		type_cname_stack.add (cname);
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			process_documentation (cname, create_gir_comment (parse_doc ()));
 		}
 
-		while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+		while (current_token == MarkupTokenType.START_ELEMENT) {
 			if (reader.get_attribute ("introspectable") == "0") {
 				skip_element ();
 				continue;
@@ -446,8 +470,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 			} else if (reader.name == "glib:signal") {
 				parse_signal ();
 			} else {
-				// error
-				Vala.Report.error (get_current_src (), "unknown child element `%s' in `interface'".printf (reader.name));
+				error ("unknown child element `%s' in `interface'", reader.name);
 				break;
 			}
 		}
@@ -461,10 +484,10 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		string cname = reader.get_attribute ("name");
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc" && cname != null) {
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc" && cname != null) {
 			string real_cname = type_cname_stack.peek();
 			real_cname = (real_cname == null)? cname : real_cname+"."+cname;
-			process_documentation (real_cname, new GirDocumentationBuilder (parse_doc ()));
+			process_documentation (real_cname, create_gir_comment (parse_doc ()));
 		}
 
 		parse_type ();
@@ -477,8 +500,8 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		string cname = reader.get_attribute ("name");
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc" && cname != null) {
-			process_documentation (type_cname_stack.peek()+":"+cname, new GirDocumentationBuilder (parse_doc ()));
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc" && cname != null) {
+			process_documentation (type_cname_stack.peek()+":"+cname, create_gir_comment (parse_doc ()));
 		}
 
 		parse_type ();
@@ -495,20 +518,20 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		string cname = reader.get_attribute ("c:identifier");
 		next ();
 
-		GirDocumentationBuilder doc;
+		GirComment doc;
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			doc = new GirDocumentationBuilder (parse_doc ());
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			doc = create_gir_comment (parse_doc ());
 		} else {
-			doc = new GirDocumentationBuilder.empty (get_current_src ());
+			doc = create_empty_gir_comment ();
 		}
 
 		parse_return_value (doc);
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
 			start_element ("parameters");
 			next ();
-			while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+			while (current_token == MarkupTokenType.START_ELEMENT) {
 				parse_parameter (doc);
 			}
 			end_element ("parameters");
@@ -526,23 +549,23 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		string cname = reader.get_attribute ("c:identifier");
 		next ();
 
-		GirDocumentationBuilder doc;
+		GirComment doc;
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			doc = new GirDocumentationBuilder (parse_doc ());
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			doc = create_gir_comment (parse_doc ());
 		} else {
-			doc = new GirDocumentationBuilder.empty (get_current_src ());
+			doc = create_empty_gir_comment ();
 		}
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "return-value") {
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "return-value") {
 			parse_return_value (doc);
 		}
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
 			start_element ("parameters");
 			next ();
 
-			while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+			while (current_token == MarkupTokenType.START_ELEMENT) {
 				parse_parameter (doc);
 			}
 
@@ -565,22 +588,22 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		string cname = reader.get_attribute ("name");
 		next ();
 
-		GirDocumentationBuilder doc;
+		GirComment doc;
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			doc = new GirDocumentationBuilder (parse_doc ());
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			doc = create_gir_comment (parse_doc ());
 		} else {
-			doc = new GirDocumentationBuilder.empty (get_current_src ());
+			doc = create_empty_gir_comment ();
 		}
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "return-value") {
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "return-value") {
 			parse_return_value (doc);
 		}
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
 			start_element ("parameters");
 			next ();
-			while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+			while (current_token == MarkupTokenType.START_ELEMENT) {
 				parse_parameter (doc);
 			}
 			end_element ("parameters");
@@ -595,11 +618,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		string cname = reader.get_attribute ("c:type");
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			process_documentation (cname, create_gir_comment (parse_doc ()));
 		}
 
-		while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+		while (current_token == MarkupTokenType.START_ELEMENT) {
 			if (reader.get_attribute ("introspectable") == "0") {
 				skip_element ();
 				continue;
@@ -614,15 +637,13 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 			} else if (reader.name == "method") {
 				parse_method ("method");
 			} else {
-				// error
-				Vala.Report.error (get_current_src (), "unknown child element `%s' in `class'".printf (reader.name));
+				error ("unknown child element `%s' in `class'", reader.name);
 				break;
 			}
 		}
 
-		if (current_token != Vala.MarkupTokenType.END_ELEMENT) {
-			// error
-			Vala.Report.error (get_current_src (), "expected end element");
+		if (current_token != MarkupTokenType.END_ELEMENT) {
+			error ("expected end element");
 		}
 		next ();
 	}
@@ -633,11 +654,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		type_cname_stack.add (cname);
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			process_documentation (cname, new GirDocumentationBuilder (parse_doc ()));
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			process_documentation (cname, create_gir_comment (parse_doc ()));
 		}
 
-		while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
+		while (current_token == MarkupTokenType.START_ELEMENT) {
 			if (reader.get_attribute ("introspectable") == "0") {
 				skip_element ();
 				continue;
@@ -663,8 +684,8 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		string name = reader.get_attribute ("name");
 		next ();
 
-		if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "doc") {
-			process_documentation (name, new GirDocumentationBuilder (parse_doc ()));
+		if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "doc") {
+			process_documentation (name, create_gir_comment (parse_doc ()));
 		}
 
 		parse_type ();
@@ -672,7 +693,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
 		end_element ("constant");
 	}
 
-	void process_documentation (string? cname, GirDocumentationBuilder? doc) {
+	void process_documentation (string? cname, GirComment? doc) {
 		if (cname == null || doc == null) {
 			return;
 		}
diff --git a/src/libvaladoc/markupreader.vala b/src/libvaladoc/markupreader.vala
new file mode 100644
index 0000000..d6ea9d9
--- /dev/null
+++ b/src/libvaladoc/markupreader.vala
@@ -0,0 +1,306 @@
+/* markupreader.vala
+ *
+ * Copyright (C) 2008-2009  JÃrg Billeter
+ * Copyright (C) 2011       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:
+ * 	JÃrg Billeter <j bitron ch>
+ */
+
+using GLib;
+using Gee;
+
+
+/**
+ * Simple reader for a subset of XML.
+ */
+public class Valadoc.MarkupReader : Object {
+	public string filename {
+		private set;
+		get;
+	}
+
+	public string name {
+		private set;
+		get;
+	}
+
+	public string content {
+		private set;
+		get;
+	}
+
+	private MappedFile mapped_file;
+
+	private char* begin;
+	private char* current;
+	private char* end;
+
+	private int line;
+	private int column;
+
+	private Map<string, string> attributes = new HashMap<string, string> (str_hash, str_equal);
+	private bool empty_element;
+
+	private ErrorReporter reporter;
+
+	public MarkupReader (string filename, ErrorReporter reporter) {
+		this.filename = filename;
+		this.reporter = reporter;
+
+		try {
+			mapped_file = new MappedFile (filename, false);
+			begin = mapped_file.get_contents ();
+			end = begin + mapped_file.get_length ();
+
+			current = begin;
+
+			line = 1;
+			column = 1;
+		} catch (FileError e) {
+			reporter.simple_error ("Unable to map file `%s': %s", filename, e.message);
+		}
+	}
+
+	public string? get_attribute (string attr) {
+		return attributes[attr];
+	}
+
+	/*
+	 * Returns a copy of the current attributes.
+	 *
+	 * @return map of current attributes
+	 */
+	public Map<string,string> get_attributes () {
+		var result = new HashMap<string,string> (str_hash, str_equal);
+		foreach (var key in attributes.keys) {
+			result.set (key, attributes.get (key));
+		}
+		return result;
+	}
+
+	private string read_name () {
+		char* begin = current;
+		while (current < end) {
+			if (current[0] == ' ' || current[0] == '\t' || current[0] == '>'
+			    || current[0] == '/' || current[0] == '=' || current[0] == '\n') {
+				break;
+			}
+			unichar u = ((string) current).get_char_validated ((long) (end - current));
+			if (u != (unichar) (-1)) {
+				current += u.to_utf8 (null);
+			} else {
+				reporter.simple_error ("invalid UTF-8 character");
+			}
+		}
+		if (current == begin) {
+			// syntax error: invalid name
+		}
+		return ((string) begin).substring (0, (int) (current - begin));
+	}
+
+	public MarkupTokenType read_token (out MarkupSourceLocation token_begin, out MarkupSourceLocation token_end) {
+		attributes.clear ();
+
+		if (empty_element) {
+			empty_element = false;
+			return MarkupTokenType.END_ELEMENT;
+		}
+
+		space ();
+
+		MarkupTokenType type = MarkupTokenType.NONE;
+		char* begin = current;
+		token_begin.pos = begin;
+		token_begin.line = line;
+		token_begin.column = column;
+
+		if (current >= end) {
+			type = MarkupTokenType.EOF;
+		} else if (current[0] == '<') {
+			current++;
+			if (current >= end) {
+				// error
+			} else if (current[0] == '?') {
+				// processing instruction
+			} else if (current[0] == '!') {
+				// comment or doctype
+				current++;
+				if (current < end - 1 && current[0] == '-' && current[1] == '-') {
+					// comment
+					current += 2;
+					while (current < end - 2) {
+						if (current[0] == '-' && current[1] == '-' && current[2] == '>') {
+							// end of comment
+							current += 3;
+							break;
+						} else if (current[0] == '\n') {
+							line++;
+							column = 0;
+						}
+						current++;
+					}
+
+					// ignore comment, read next token
+					return read_token (out token_begin, out token_end);
+				}
+			} else if (current[0] == '/') {
+				type = MarkupTokenType.END_ELEMENT;
+				current++;
+				name = read_name ();
+				if (current >= end || current[0] != '>') {
+					// error
+				}
+				current++;
+			} else {
+				type = MarkupTokenType.START_ELEMENT;
+				name = read_name ();
+				space ();
+				while (current < end && current[0] != '>' && current[0] != '/') {
+					string attr_name = read_name ();
+					if (current >= end || current[0] != '=') {
+						// error
+					}
+					current++;
+					// FIXME allow single quotes
+					if (current >= end || current[0] != '"') {
+						// error
+					}
+					current++;
+
+					string attr_value = text ('"', false);
+
+					if (current >= end || current[0] != '"') {
+						// error
+					}
+					current++;
+					attributes.set (attr_name, attr_value);
+					space ();
+				}
+				if (current[0] == '/') {
+					empty_element = true;
+					current++;
+					space ();
+				} else {
+					empty_element = false;
+				}
+				if (current >= end || current[0] != '>') {
+					// error
+				}
+				current++;
+			}
+		} else {
+			space ();
+
+			if (current[0] != '<') {
+				content = text ('<', true);
+			} else {
+				// no text
+				// read next token
+				return read_token (out token_begin, out token_end);
+			}
+
+			type = MarkupTokenType.TEXT;
+		}
+
+		token_end.pos = current;
+		token_end.line = line;
+		token_end.column = column - 1;
+
+		return type;
+	}
+
+	private string text (char end_char, bool rm_trailing_whitespace) {
+		StringBuilder content = new StringBuilder ();
+		char* text_begin = current;
+		char* last_linebreak = current;
+
+		while (current < end && current[0] != end_char) {
+			unichar u = ((string) current).get_char_validated ((long) (end - current));
+			if (u == (unichar) (-1)) {
+				reporter.simple_error ("invalid UTF-8 character");
+			} else if (u == '&') {
+				char* next_pos = current + u.to_utf8 (null);
+				if (((string) next_pos).has_prefix ("amp;")) {
+					content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+					content.append_c ('&');
+					current += 5;
+					text_begin = current;
+				} else if (((string) next_pos).has_prefix ("quot;")) {
+					content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+					content.append_c ('"');
+					current += 6;
+					text_begin = current;
+				} else if (((string) next_pos).has_prefix ("apos;")) {
+					content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+					content.append_c ('\'');
+					current += 6;
+					text_begin = current;
+				} else if (((string) next_pos).has_prefix ("lt;")) {
+					content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+					content.append_c ('<');
+					current += 4;
+					text_begin = current;
+				} else if (((string) next_pos).has_prefix ("gt;")) {
+					content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+					content.append_c ('>');
+					current += 4;
+					text_begin = current;
+				} else {
+					current += u.to_utf8 (null);
+				}
+			} else {
+				if (u == '\n') {
+					line++;
+					column = 0;
+					last_linebreak = current;
+				}
+
+				current += u.to_utf8 (null);
+				column++;
+			}
+		}
+
+		if (text_begin != current) {
+			content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+		}
+
+		column += (int) (current - last_linebreak);
+
+		// Removes trailing whitespace
+		if (rm_trailing_whitespace) {
+			char* str_pos = ((char*)content.str) + content.len;
+			for (str_pos--; str_pos > ((char*)content.str) && str_pos[0].isspace(); str_pos--);
+			content.erase ((ssize_t) (str_pos-((char*) content.str) + 1), -1);
+		}
+
+		return content.str;
+	}
+
+	private void space () {
+		while (current < end && current[0].isspace ()) {
+			if (current[0] == '\n') {
+				line++;
+				column = 0;
+			}
+			current++;
+			column++;
+		}
+	}
+}
+
+
diff --git a/src/libvaladoc/markupsourcelocation.vala b/src/libvaladoc/markupsourcelocation.vala
new file mode 100644
index 0000000..af7dff1
--- /dev/null
+++ b/src/libvaladoc/markupsourcelocation.vala
@@ -0,0 +1,39 @@
+/* valasourcelocation.vala
+ *
+ * Copyright (C) 2008  JÃrg Billeter
+ *
+ * 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:
+ * 	JÃrg Billeter <j bitron ch>
+ */
+
+using GLib;
+
+/**
+ * Represents a position in a source file.
+ */
+public struct Valadoc.MarkupSourceLocation {
+	public char* pos;
+	public int line;
+	public int column;
+
+	public MarkupSourceLocation (char* _pos, int _line, int _column) {
+		pos = _pos;
+		line = _line;
+		column = _column;
+	}
+}
+
diff --git a/src/libvaladoc/markuptokentype.vala b/src/libvaladoc/markuptokentype.vala
new file mode 100644
index 0000000..5bd86d9
--- /dev/null
+++ b/src/libvaladoc/markuptokentype.vala
@@ -0,0 +1,50 @@
+/* markuptokentype.vala
+ *
+ * Copyright (C) 2008-2009  JÃrg Billeter
+ *
+ * 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:
+ * 	JÃrg Billeter <j bitron ch>
+ */
+
+
+public enum Valadoc.MarkupTokenType {
+	NONE,
+	START_ELEMENT,
+	END_ELEMENT,
+	TEXT,
+	EOF;
+
+	public string to_string () {
+		switch (this) {
+		case START_ELEMENT:
+			return "start element";
+
+		case END_ELEMENT:
+			return "end element";
+
+		case TEXT:
+			return "text";
+
+		case EOF:
+			return "end of file";
+
+		default:
+			return "unknown token type";
+		}
+	}
+}
+
diff --git a/src/libvaladoc/valadoc-1.0.deps.in b/src/libvaladoc/valadoc-1.0.deps.in
index 447458f..2e4a847 100755
--- a/src/libvaladoc/valadoc-1.0.deps.in
+++ b/src/libvaladoc/valadoc-1.0.deps.in
@@ -1,4 +1,3 @@
 libgvc
 gee-1.0
 gmodule-2.0
- VALA_PACKAGE@
diff --git a/src/libvaladoc/valadoc-1.0.pc.in b/src/libvaladoc/valadoc-1.0.pc.in
index 70bfc23..b16036f 100755
--- a/src/libvaladoc/valadoc-1.0.pc.in
+++ b/src/libvaladoc/valadoc-1.0.pc.in
@@ -9,6 +9,6 @@ vapidir= datadir@/vala/vapi
 Name: Valadoc
 Description: The Vala documentation compiler library
 Version: @VERSION@
-Requires: @VALA_PACKAGE@ libgvc gee-1.0 gmodule-2.0
+Requires: libgvc gee-1.0 gmodule-2.0
 Libs: -L${libdir} -lvaladoc
 Cflags: -I${includedir}/valadoc-1.0
diff --git a/src/valadoc/valadoc.vala b/src/valadoc/valadoc.vala
index 02684b3..67cffe0 100755
--- a/src/valadoc/valadoc.vala
+++ b/src/valadoc/valadoc.vala
@@ -239,7 +239,7 @@ public class ValaDoc : Object {
 		}
 
 		DocumentationImporter[] importers = {
-			new GirDocumentationImporter (doctree, docparser, modules, settings),
+			new GirDocumentationImporter (doctree, docparser, modules, settings, reporter),
 			new ValadocDocumentationImporter (doctree, docparser, modules, settings, reporter)
 		};
 



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