AC_SUBST(VALAC)
+AC_SUBST(VALAFLAGS)
AC_ARG_ENABLE(valadocorg, AS_HELP_STRING([--enable-valadocorg], []), enable_valadocorg=$enableval, enable_valadocorg=no)
AM_CONDITIONAL(ENABLE_VALADOCORG, test x$enable_valadocorg = xyes)
src/doclets/htmlhelpers/Makefile
src/doclets/htmlhelpers/deps/Makefile
src/doclets/htmlhelpers/doclet/Makefile
- src/doclets/htmlhelpers/taglets/Makefile
src/doclets/htm/Makefile
src/doclets/htm/doclet/Makefile
src/doclets/valadoc.org/Makefile
htmlhelpers \
htm \
devhelp \
- valadoc.org \
$(NULL)
install-data-hook:
- cd $(libdir)/valadoc/plugins/devhelp/ && if test -d taglets; then unlink taglets; fi && ln -s ../htmlhelpers/taglets && if test -d deps; then unlink deps; fi && ln -s ../htmlhelpers/deps
+ cd $(libdir)/valadoc/plugins/devhelp/ && if test -d deps; then unlink deps; fi && ln -s ../htmlhelpers/deps
install-data-hook:
- cd $(libdir)/valadoc/plugins/html/ && if test -d taglets; then unlink taglets; fi && ln -s ../htmlhelpers/taglets && if test -d deps; then unlink deps; fi && ln -s ../htmlhelpers/deps
+ cd $(libdir)/valadoc/plugins/html/ && if test -d deps; then unlink deps; fi && ln -s ../htmlhelpers/deps
SUBDIRS = \
doclet \
- taglets \
deps \
$(NULL)
globals.vala \
langlet.vala \
doclet.vala \
+ htmlrenderer.vala \
$(NULL)
using GLib;
-
+using Valadoc.Content;
public abstract class Valadoc.Html.BasicDoclet : Valadoc.Doclet {
protected Valadoc.Langlet langlet;
protected Settings settings;
+ protected HtmlRenderer _renderer;
+
+ construct {
+ _renderer = new HtmlRenderer (this);
+ }
protected string? get_link ( DocumentedElement element, DocumentedElement? pos ) {
return get_html_link ( this.settings, element, pos );
if ( page.name != "index.valadoc" ) {
GLib.FileStream file = GLib.FileStream.open ( Path.build_filename(contentp, page.name.ndup( page.name.len()-7).replace ("/", ".")+"html"), "w" );
this.write_file_header ( file, css_path_wiki, this.settings.pkg_name );
- page.write ( file );
+ _renderer.set_container (page);
+ _renderer.set_filestream (file);
+ _renderer.render (page.documentation);
this.write_file_footer ( file );
}
}
}
private void write_brief_description ( GLib.FileStream file, DocumentedElement element , DocumentedElement? pos ) {
- DocumentationTree? doctree = element.documentation;
+ Comment? doctree = element.documentation;
if ( doctree == null )
return ;
- Gee.Collection<DocElement> brief = doctree.get_brief ( );
- if ( brief.size > 0 ) {
+ Gee.List<Block> description = doctree.content;
+ if ( description.size > 0 ) {
file.printf ( " <span class=\"%s\">- ", css_inline_navigation_brief_description );
- int _max = brief.size;
- int _index = 0;
- foreach ( DocElement element2 in brief ) {
- if ( element2 is InlineTaglet )
- file.puts ( ((InlineTaglet)element2).to_string() );
- else
- element2.write ( file, _max, _index );
-
- _index++;
- }
+ _renderer.set_container (pos);
+ _renderer.set_filestream (file);
+ _renderer.render_children (description.get (0));
file.printf ( " </span>\n" );
}
}
private void write_documentation ( GLib.FileStream file, DocumentedElement element , DocumentedElement? pos ) {
- DocumentationTree? doctree = element.documentation;
+ Comment? doctree = element.documentation;
if ( doctree == null )
return ;
- Gee.Collection<DocElement> brief = doctree.get_brief ( );
- if ( brief.size > 0 ) {
- doctree.write_brief ( file );
- }
- file.printf ( "\n<br />\n" );
- file.printf ( "\n<br />\n" );
- doctree.write_content ( file );
+ _renderer.set_container (pos);
+ _renderer.set_filestream (file);
+ _renderer.render (doctree);
}
public void write_navi_packages_inline ( GLib.FileStream file, Tree tree ) {
WikiPage? wikiindex = (tree.wikitree == null)? null : tree.wikitree.search ( "index.valadoc" );
if ( wikiindex != null ) {
- wikiindex.write ( file );
+ _renderer.set_container (null);
+ _renderer.set_filestream (file);
+ _renderer.render (wikiindex.documentation);
}
file.printf ( "\t\t\t\t<h2 class=\"%s\">Content:</h2>\n", css_title );
file.printf ( "\t\t\t\t<h2 class=\"%s\">Description:</h2>\n", css_title );
if (wikipage != null) {
- wikipage.write (file);
+ _renderer.set_container (mself);
+ _renderer.set_filestream (file);
+ _renderer.render (wikipage.documentation);
}
file.printf ( "\n\t\t\t\t<h2 class=\"%s\">Content:</h2>\n", css_title );
--- /dev/null
+/* contentvisitor.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Valadoc.Content;
+
+public class Valadoc.Html.HtmlRenderer : ContentRenderer {
+
+ private BasicDoclet _doclet;
+ private Documentation? _container;
+ private unowned FileStream _stream;
+
+ public HtmlRenderer (BasicDoclet doclet) {
+ _doclet = doclet;
+ }
+
+ 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 string get_url (DocumentedElement symbol) {
+ return get_html_link (_doclet.settings, symbol, _container);
+ }
+
+ private void write_symbol_link (DocumentedElement symbol, string label) {
+ var url = get_url (symbol);
+ _stream.printf ("<a href=\"%s\">%s</a>",
+ url,
+ (label == null || label == "") ? symbol.full_name () : label);
+ }
+
+ private delegate void TagletWrite (Taglet taglet);
+
+ private void write_taglets (string header, string footer, string separator,
+ Gee.List<Taglet> taglets, TagletWrite write) {
+ if (taglets.size > 0) {
+ _stream.printf (header);
+ bool first = true;
+ foreach (var taglet in taglets) {
+ if (!first) {
+ _stream.printf (separator);
+ }
+ write (taglet);
+ first = false;
+ }
+ _stream.printf (footer);
+ }
+ }
+
+ public override void visit_comment (Comment element) {
+ Gee.List<Taglet> taglets;
+
+ taglets = element.find_taglets ((DocumentedElement) _container, typeof (Taglets.Deprecated));
+ write_taglets (
+ "<p class=\"main_title\"><b>Deprecated:</b> ",
+ "</p>",
+ "",
+ taglets,
+ (taglet) => {
+ var deprecated = taglet as Taglets.Deprecated;
+ deprecated.accept_children (this);
+ });
+
+ // Write description
+ element.accept_children (this);
+
+ taglets = element.find_taglets ((DocumentedElement) _container, typeof (Taglets.Param));
+ write_taglets (
+ "<h2 class=\"main_title\">Parameters:</h2>\n<table class=\"main_parameter_table\">",
+ "</table>",
+ "",
+ taglets,
+ (taglet) => {
+ var param = taglet as Taglets.Param;
+ _stream.printf ("<tr><td class=\"main_parameter_table_name\">%s</td><td>", param.parameter_name);
+ param.accept_children (this);
+ _stream.printf ("</td></tr>");
+ });
+
+ taglets = element.find_taglets ((DocumentedElement) _container, typeof (Taglets.Return));
+ write_taglets (
+ "<h2 class=\"main_title\">Returns:</h2>\n<table class=\"main_parameter_table\">",
+ "</table>",
+ "",
+ taglets,
+ (taglet) => {
+ var param = taglet as Taglets.Return;
+ _stream.printf ("<tr><td>");
+ param.accept_children (this);
+ _stream.printf ("</td></tr>");
+ });
+
+ taglets = element.find_taglets ((DocumentedElement) _container, typeof (Taglets.Throws));
+ write_taglets (
+ "<h2 class=\"main_title\">Throws:</h2>\n<table class=\"main_parameter_table\">",
+ "</table>",
+ "",
+ taglets,
+ (taglet) => {
+ var exception = taglet as Taglets.Throws;
+ _stream.printf ("<tr><td class=\"main_parameter_table_name\">%s</td><td>", exception.error_domain_name);
+ exception.accept_children (this);
+ _stream.printf ("</td></tr>");
+ });
+
+ taglets = element.find_taglets ((DocumentedElement) _container, typeof (Taglets.Since));
+ write_taglets (
+ "<h2 class=\"main_title\">Since:</h2>\n<p>",
+ "</p>",
+ ", ",
+ taglets,
+ (taglet) => {
+ var since = taglet as Taglets.Since;
+ _stream.printf ("%s", since.version);
+ });
+
+ taglets = element.find_taglets ((DocumentedElement) _container, typeof (Taglets.See));
+ write_taglets (
+ "<h2 class=\"main_title\">See also:</h2>\n<p>",
+ "</p>",
+ ", ",
+ taglets,
+ (taglet) => {
+ var see = taglet as Taglets.See;
+ write_symbol_link (see.symbol, see.symbol_name);
+ });
+ }
+
+ public override void visit_embedded (Embedded element) {
+ var caption = element.caption;
+ _stream.printf ("<img src=\"%s\">%s</a>",
+ element.url,
+ (caption == null || caption == "") ? "" : caption);
+ }
+
+ public override void visit_headline (Headline element) {
+ _stream.printf ("<h%d>", element.level);
+ element.accept_children (this);
+ _stream.printf ("</h%d>", element.level);
+ }
+
+ public override void visit_highlighted (Highlighted element) {
+ string tag = null;
+ switch (element.style) {
+ case Highlighted.Style.BOLD:
+ tag = "b";
+ break;
+ case Highlighted.Style.ITALIC:
+ tag = "i";
+ break;
+ case Highlighted.Style.UNDERLINED:
+ tag = "u";
+ break;
+ case Highlighted.Style.MONOSPACED:
+ tag = "code";
+ break;
+ case Highlighted.Style.STROKE:
+ tag = "stroke";
+ break;
+ }
+ if (tag != null) {
+ _stream.printf ("<%s>", tag);
+ }
+ element.accept_children (this);
+ if (tag != null) {
+ _stream.printf ("</%s>", tag);
+ }
+ }
+
+ public override void visit_link (Link element) {
+ var label = element.label;
+ _stream.printf ("<a href=\"%s\">%s</a>",
+ element.url,
+ (label == null || label == "") ? element.url : label);
+ }
+
+ public override void visit_symbol_link (SymbolLink element) {
+ write_symbol_link (element.symbol, element.label);
+ }
+
+ 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 ("<p>");
+ element.accept_children (this);
+ _stream.printf ("</p>");
+ }
+
+ public override void visit_source_code (SourceCode element) {
+ _stream.printf ("<pre>");
+ _stream.printf (element.code);
+ _stream.printf ("</pre>");
+ }
+
+ public override void visit_table (Table element) {
+ }
+
+ public override void visit_table_cell (TableCell element) {
+ }
+
+ public override void visit_taglet (Taglet element) {
+ }
+
+ public override void visit_text (Text element) {
+ write_string (element.content);
+ }
+
+ private void write_string (string content) {
+ unichar chr = content[0];
+ long lpos = 0;
+ int i = 0;
+
+ for (i = 0; chr != '\0' ; i++, chr = content[i]) {
+ switch (chr) {
+ case '\n':
+ _stream.puts (content.substring (lpos, i-lpos));
+ _stream.puts ("<br />");
+ lpos = i+1;
+ break;
+ case '<':
+ _stream.puts (content.substring (lpos, i-lpos));
+ _stream.puts ("<");
+ lpos = i+1;
+ break;
+ case '>':
+ _stream.puts (content.substring (lpos, i-lpos));
+ _stream.puts (">");
+ lpos = i+1;
+ break;
+ case '&':
+ _stream.puts (content.substring (lpos, i-lpos));
+ _stream.puts ("&");
+ lpos = i+1;
+ break;
+ }
+ }
+ _stream.puts (content.substring (lpos, i-lpos));
+ }
+}
+++ /dev/null
-NULL =
-
-
-AM_CFLAGS = -g \
- -I ../../../libvaladoc/ \
- -I ../doclet/ \
- $(GLIB_CFLAGS) \
- $(LIBVALA_CFLAGS) \
- $(LIBGDKPIXBUF_CFLAGS) \
- $(NULL)
-
-
-BUILT_SOURCES = libbasictaglets.vala.stamp
-
-
-basictagletsdir = $(libdir)/valadoc/plugins/htmlhelpers/taglets/
-
-
-basictaglets_LTLIBRARIES = \
- libbasictaglets.la \
- $(NULL)
-
-
-libbasictaglets_la_VALASOURCES = \
- bold.vala \
- center.vala \
- constant.vala \
- headline.vala \
- image.vala \
- italic.vala \
- link.vala \
- list.vala \
- listelement.vala \
- notification.vala \
- paragraph.vala \
- parameter.vala \
- return.vala \
- right.vala \
- see.vala \
- since.vala \
- source.vala \
- string.vala \
- table.vala \
- tablecell.vala \
- throws.vala \
- typelink.vala \
- underline.vala \
- registerfunction.vala \
- $(NULL)
-
-
-libbasictaglets_la_SOURCES = \
- libbasictaglets.vala.stamp \
- $(libbasictaglets_la_VALASOURCES:.vala=.c) \
- $(NULL)
-
-
-libbasictaglets.vala.stamp: $(libbasictaglets_la_VALASOURCES)
- $(VALAC) -C --vapidir ../../../vapi --pkg valadoc-1.0 --vapidir ../doclet/ --pkg libhtmlhelpers-1.0 --basedir . --pkg gdk-pixbuf-2.0 $^
- touch $@
-
-
-libbasictaglets_la_LDFLAGS = -module -avoid-version
-
-
-libbasictaglets_la_LIBADD = \
- ../../../libvaladoc/libvaladoc.la \
- $(LIBGVC_LIBS) \
- $(LIBVALA_LIBS) \
- $(GLIB_LIBS) \
- $(LIBGDKPIXBUFLIBS_) \
- $(NULL)
-
-
-EXTRA_DIST = $(libbasictaglets_la_VALASOURCES) libbasictaglets.vala.stamp
-
-
-MAINTAINERCLEANFILES = \
- $(libbasictaglets_la_VALASOURCES:.vala=.c) \
- $(NULL)
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-using Gdk;
-
-
-public class Valadoc.Html.ImageDocElement : Valadoc.ImageDocElement {
- private static uint counter = 0;
-
- private string htmlpath;
- private string npath;
- private string path;
- private string alt;
-
- public override bool parse ( Settings settings, Documentation pos, owned string path, owned string alt ) {
- if ( GLib.FileUtils.test ( path, GLib.FileTest.EXISTS | GLib.FileTest.IS_REGULAR ) == false ) {
- return false;
- }
-
- weak string? dotpos = path.rchr ( -1, '.' );
- string filename = "img0%u%s".printf(this.counter++, dotpos.ndup(dotpos.size()));
-
- this.path = realpath ( path );
-
- if ( pos == null || (pos is WikiPage)? ((WikiPage)pos).name=="index.valadoc": false ) {
- this.htmlpath = Path.build_filename("content", "img", filename);
- this.npath = Path.build_filename(settings.path, this.htmlpath);
- this.alt = alt;
- }
- else if ( pos is DocumentedElement ) {
- this.htmlpath = Path.build_filename("img", filename);
- this.npath = Path.build_filename(settings.path, ((DocumentedElement)pos).package.name, this.htmlpath);
- this.alt = alt;
- }
- else {
- this.htmlpath = Path.build_filename("img", filename);
- this.npath = Path.build_filename(settings.path, "content", this.htmlpath);
- this.alt = alt;
- }
- return true;
- }
-
- private string? create_thumb (string filename, string destinationpath) {
- int height;
- int width;
-
- weak PixbufFormat format = Pixbuf.get_file_info (filename, out width, out height);
- if ( width == 0 || height == 0 ) {
- return null;
- }
-
- if ( width > 700 ) {
- try {
- Pixbuf img = new Pixbuf.from_file (filename);
-
- int dest_height = (height*700)/width;
- int dest_width = 700;
-
-
- if (dest_height == 0) {
- dest_height++;
- }
-
- Pixbuf dest = new Pixbuf (img.get_colorspace(), img.get_has_alpha(), img.get_bits_per_sample(), dest_width, dest_height);
- img.scale (dest, 0, 0, dest_width, dest_height, 0, 0, (double)dest_width/img.get_width(), (double)dest_height/img.get_height(), Gdk.InterpType.BILINEAR);
-
- string newfilename = GLib.Path.build_filename(destinationpath, "tmb_"+Path.get_basename (filename));
- dest.save (newfilename, format.get_name());
- return newfilename;
- }
- catch (Error err) {
- return null;
- }
- }
-
- return filename;
- }
-
- public override bool write ( void* res, int max, int index ) {
- bool tmp = copy_file ( this.path, this.npath );
- if ( tmp == false )
- return false;
-
- string thumbpath = create_thumb (this.npath, Path.get_dirname(this.npath));
- if ( thumbpath == null ) {
- return false;
- }
-
- ((GLib.FileStream)res).printf ( "<a href=\"%s\"><img src=\"%s\" alt=\"%s\" /></a>", this.htmlpath, thumbpath, this.alt );
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.LinkDocElement : Valadoc.LinkDocElement {
- protected string desc;
- protected string path;
-
- public override bool parse ( Settings settings, Tree tree, Documentation pos, owned string path, owned string desc ) {
- if ( path.has_suffix(".valadoc")&&path.has_prefix("/") ) {
- if ( tree.wikitree == null ) {
- return false;
- }
-
- WikiPage? wikipage = tree.wikitree.search(path.offset(1));
- if ( wikipage == null ) {
- return false;
- }
-
- this.path = get_html_link(settings, wikipage, pos);
- this.desc = (owned)desc;
- return true;
- }
-
- this.path = (owned)path;
- this.desc = (owned)desc;
- return true;
- }
-
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- file.printf ("<a href=\"%s\">%s</a>", this.path, (this.desc==null||this.desc=="")? this.path: this.desc );
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.ListDocElement : Valadoc.ListDocElement {
- private Gee.ArrayList<ListEntryDocElement> entries;
- private ListType type;
-
- public override bool parse ( ListType type, Gee.ArrayList<ListEntryDocElement> entries ) {
- this.entries = entries;
- this.type = type;
- return true;
- }
-
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- int _max = this.entries.size;
- int _index = 0;
-
- file.printf ( (this.type == ListType.UNSORTED)? "<ul>\n" : "<ol>\n" );
-
- foreach ( ListEntryDocElement entry in this.entries ) {
- entry.write ( res, _max, _index );
- _index++;
- }
-
- file.printf ( (this.type == ListType.UNSORTED)? "</ul>\n" : "</ol>\n" );
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.NotificationDocElement : Valadoc.NotificationDocElement {
- private Gee.ArrayList<DocElement> content;
-
- public override bool parse ( Gee.ArrayList<DocElement> content ) {
- this.content = content;
- return true;
- }
-
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- int _max = this.content.size;
- int _index = 0;
-
- file.printf ( "\n<div class=\"%s\">\n", css_notification_area );
-
- foreach ( DocElement element in this.content ) {
- element.write ( res, _max, _index );
- _index++;
- }
-
- file.printf ( "\n</div>\n" );
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.ParameterTaglet : Valadoc.MainTaglet {
- public override int order { get { return 100; } }
- private Gee.Collection<DocElement> content;
- private string paramname;
-
- private static bool check_parameter_name ( Valadoc.ParameterListHandler me, string name ) {
- if ( name == "" )
- return false;
-
- foreach ( Valadoc.FormalParameter param in me.get_parameter_list ( ) ) {
- if ( param.name == name )
- return true;
- }
- return false;
- }
-
- public override bool write ( void* ptr, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)ptr;
-
- file.printf ( "\t<tr>\n" );
- file.printf ( "\t\t<td class=\"%s\">%s:</td>\n", css_parameter_table_name, this.paramname );
- file.printf ( "\t\t<td class=\"%s\">\n", css_parameter_table_text );
- file.puts ( "\t\t\t" );
-
- int _max = this.content.size;
- int _index = 0;
-
- foreach ( DocElement tag in this.content ) {
- tag.write ( ptr, _max, _index );
- _index++;
- }
-
- file.puts ( "\n" );
- file.printf ( "\t\t</td>\n" );
- file.printf ( "\t</tr>\n" );
- return true;
- }
-
- public override bool write_block_start ( void* ptr ) {
- weak GLib.FileStream file = (GLib.FileStream)ptr;
- file.printf ( "<h2 class=\"%s\">Parameters:</h2>\n", css_title );
- file.printf ( "<table class=\"%s\">\n", css_parameter_table );
- return true;
- }
-
- public override bool write_block_end ( void* ptr ) {
- weak GLib.FileStream file = (GLib.FileStream)ptr;
- file.printf ( "</table>\n" );
- return true;
- }
-
- public override bool parse ( Settings settings, Tree tree, DocumentedElement me, Gee.Collection<DocElement> content, ref ErrorLevel errlvl, out string errmsg ) {
- if ( me is Valadoc.ParameterListHandler == false ) {
- errmsg = "Tag @param cannot be used in this context";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- if ( content.size == 0 ) {
- errmsg = "Parameter name was expected";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- Gee.ArrayList<DocElement> contentlst = new Gee.ArrayList<DocElement> ();
- foreach ( DocElement element in content ) {
- contentlst.add ( element );
- }
-
- DocElement tag = contentlst.get( 0 );
- if ( tag is StringTaglet == false ) {
- errmsg = "Parameter name was expected";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- string str = ((StringTaglet)tag).content;
- weak string lposa = str.chr (-1, '\n');
- weak string lposb = str.chr (-1, ' ');
- weak string lpos;
-
- long lposaoffset = (lposa == null)? long.MAX : str.pointer_to_offset ( lposa );
- long lposboffset = (lposb == null)? long.MAX : str.pointer_to_offset ( lposb );
-
- if ( lposaoffset < lposboffset )
- lpos = lposa;
- else
- lpos = lposb;
-
- if ( lpos == null ) {
- this.paramname = str.strip ();
- ((StringTaglet)tag).content = "";
- }
- else {
- int namepos = (int)str.pointer_to_offset ( lpos );
- this.paramname = str.ndup ( namepos ).strip ();
- ((StringTaglet)tag).content = lpos.ndup ( lpos.size () ).chomp ();
- }
-
- bool tmp = this.check_parameter_name ( (Valadoc.ParameterListHandler)me, this.paramname );
- if ( tmp == false ) {
- errmsg = "Parameter is not available";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- this.content = contentlst;
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-using Valadoc;
-
-
-[ModuleInit]
-public void register_plugin (ModuleLoader loader) {
- loader.underline = typeof (Valadoc.Html.UnderlinedDocElement);
- loader.table_cell = typeof (Valadoc.Html.TableCellDocElement);
- loader.table = typeof (Valadoc.Html.TableDocElement);
- loader.string = typeof (Valadoc.Html.StringTaglet);
- loader.source = typeof (Valadoc.Html.SourceCodeDocElement);
- loader.right = typeof (Valadoc.Html.RightAlignedDocElement);
- loader.paragraph = typeof (Valadoc.Html.ParagraphDocElement);
- loader.notification = typeof (Valadoc.Html.NotificationDocElement);
- loader.list_element = typeof (Valadoc.Html.ListEntryDocElement);
- loader.list = typeof (Valadoc.Html.ListDocElement);
- loader.link = typeof (Valadoc.Html.LinkDocElement);
- loader.italic = typeof (Valadoc.Html.ItalicDocElement);
- loader.image = typeof (Valadoc.Html.ImageDocElement);
- loader.headline = typeof (Valadoc.Html.HeadlineDocElement);
- loader.source_inline = typeof (Valadoc.Html.CodeConstantDocElement);
- loader.center = typeof (Valadoc.Html.CenterDocElement);
- loader.bold = typeof (Valadoc.Html.BoldDocElement);
-
- loader.taglets.set ("see", typeof (Valadoc.Html.SeeTaglet));
- loader.taglets.set ("since", typeof (Valadoc.Html.SinceTaglet));
- loader.taglets.set ("link", typeof (Valadoc.Html.TypeLinkInlineTaglet));
- loader.taglets.set ("throws", typeof (Valadoc.Html.ExceptionTaglet));
- loader.taglets.set ("return", typeof (Valadoc.Html.ReturnTaglet));
- loader.taglets.set ("param", typeof (Valadoc.Html.ParameterTaglet));
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.ReturnTaglet : Valadoc.MainTaglet {
- public override int order { get { return 300; } }
- private Gee.Collection<DocElement> content;
-
-
- public override bool parse ( Settings settings, Tree tree, DocumentedElement me, Gee.Collection<DocElement> content, ref ErrorLevel errlvl, out string errmsg ) {
- if ( !(me is Valadoc.Method || me is Valadoc.Signal || me is Valadoc.Delegate) ) {
- errmsg = "Tag @return cannot be used in this context";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
- this.content = content;
- return true;
- }
-
- public override bool write ( void* res, int max, int index ) {
- int _max = this.content.size;
- int _index = 0;
-
- foreach ( DocElement element in this.content ) {
- element.write ( res, _max, _index );
- _index++;
- }
- return true;
- }
-
- public override bool write_block_start ( void* res ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- file.printf ( "<h2 class=\"%s\">Returns:</h2>\n", css_title );
- return true;
- }
-
- public override bool write_block_end ( void* res ) {
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.RightAlignedDocElement : Valadoc.RightAlignedDocElement {
- private Gee.ArrayList<DocElement> content;
-
- public override bool parse ( Gee.ArrayList<DocElement> content ) {
- this.content = content;
- return true;
- }
-
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- int _max = this.content.size;
- int _index = 0;
-
- file.printf ( "<div align=\"right\">" );
-
- foreach ( DocElement element in this.content ) {
- element.write ( res, _max, _index );
- _index++;
- }
-
- file.printf ( "</div>" );
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using Valadoc;
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.SeeTaglet : MainTaglet {
- public override int order { get { return 400; } }
- private string name;
- private string link;
- private string css;
-
- protected override bool write_block_start ( void* res ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- file.printf ( "<h2 class=\"%s\">See:</h2>\n", css_title );
- return true;
- }
-
- protected override bool write_block_end ( void* res ) {
- return true;
- }
-
- protected override bool write ( void* res, int max, int index ) {
- if ( this.link == null ) {
- ((GLib.FileStream)res).printf ( "<span class=\"%s\">%s</span>", this.css, this.name );
- }
- else {
- ((GLib.FileStream)res).printf ( "<a class=\"%s\" href=\"%s\">%s</a>", this.css, this.link, this.name );
- }
-
- if ( max != index+1 ) {
- ((GLib.FileStream)res).printf ( ", " );
- }
- return true;
- }
-
- public override bool parse ( Settings settings, Tree tree, DocumentedElement me, Gee.Collection<DocElement> content, ref ErrorLevel errlvl, out string errmsg ) {
- if ( content.size != 1 ) {
- errmsg = "Type name was expected";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- Gee.Iterator<DocElement> it = content.iterator ();
- it.next ();
-
- DocElement element = it.get ();
- if ( element is StringTaglet == false ) {
- errmsg = "Type name was expected";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- Valadoc.DocumentedElement? node = tree.search_symbol_str ( me, ((StringTaglet)element).content.strip ( ) );
- if ( node == null ) {
- errmsg = "Linked type is not available";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- this.name = node.full_name ( );
- this.css = get_html_content_link_css_class ( node );
- this.link = get_html_link ( settings, node, me );
- return true;
- }
-}
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.SinceTaglet : Valadoc.MainTaglet {
- public override int order { get { return 400; } }
- private StringTaglet content;
-
- public override bool write_block_start ( void* ptr ) {
- weak GLib.FileStream file = (GLib.FileStream)ptr;
- file.printf ( "<h2 class=\"%s\">Since:</h2>\n", css_title );
- return true;
- }
-
- public override bool write_block_end ( void* res ) {
- return true;
- }
-
- public override bool write ( void* res, int max, int index ) {
- ((GLib.FileStream)res).printf ( "%s", this.content.content );
- if ( max != index+1 )
- ((GLib.FileStream)res).puts ( ", " );
-
- return true;
- }
-
- public override bool parse ( Settings settings, Tree tree, DocumentedElement me, Gee.Collection<DocElement> content, ref ErrorLevel errlvl, out string errmsg ) {
- if ( content.size != 1 ) {
- errmsg = "Version name was expected";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- Gee.Iterator<DocElement> it = content.iterator ();
- it.next ();
-
- DocElement element = it.get ();
- if ( element is StringTaglet == false ) {
- errmsg = "Version name was expected";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- this.content = (StringTaglet)element;
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.SourceCodeDocElement : Valadoc.SourceCodeDocElement {
- private Language lang;
- private int srclines;
- private string src;
-
- public override bool parse (string src, Language lang) {
- this.src = src;
- this.lang = lang;
- this.srclines=0;
-
- for (weak string str=this.src; str.get_char()!='\0'; str=str.next_char()) {
- if (str.get_char () == '\n') {
- this.srclines++;
- }
- }
- return true;
- }
-
- public override bool write (void* res, int max, int index) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- file.printf ("\n\n\t<pre class=\"%s\">", css_source_sample);
- file.puts (src);
- file.puts ("</pre>\n\n");
- return true;
- }
-}
-
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.StringTaglet : Valadoc.StringTaglet {
- public override bool parse ( string content ) {
- this.content = content;
- return true;
- }
-
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- unichar chr = content[0];
- long lpos = 0;
- int i = 0;
-
- for ( i = 0; chr != '\0' ; i++, chr = content[i] ) {
- switch ( chr ) {
- case '\n':
- file.puts ( content.substring (lpos, i-lpos) );
- file.puts ( "<br />" );
- lpos = i+1;
- break;
- case '<':
- file.puts ( content.substring (lpos, i-lpos) );
- file.puts ( "<" );
- lpos = i+1;
- break;
- case '>':
- file.puts ( content.substring (lpos, i-lpos) );
- file.puts ( ">" );
- lpos = i+1;
- break;
- case '&':
- file.puts ( content.substring (lpos, i-lpos) );
- file.puts ( "&" );
- lpos = i+1;
- break;
- }
- }
- file.puts ( content.substring (lpos, i-lpos) );
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.TableDocElement : Valadoc.TableDocElement {
- private Gee.ArrayList<Gee.ArrayList<TableCellDocElement>> cells;
-
- public override void parse ( Gee.ArrayList<Gee.ArrayList<TableCellDocElement>> cells ) {
- this.cells = cells;
- }
-
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
-
- file.printf ( "<table border=\"1\" class=\"%s\">\n", css_wiki_table );
- foreach ( Gee.ArrayList<TableCellDocElement> row in this.cells ) {
- int _max = row.size;
- int _index = 0;
-
- file.puts ( "\t<tr>\n" );
- foreach ( TableCellDocElement cell in row ) {
- cell.write ( res, _max, _index );
- _index++;
- }
- file.puts ( "\t</tr>\n" );
-
- }
- file.puts ( "</table>\n" );
- return true;
- }
-}
-
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.TableCellDocElement : Valadoc.TableCellDocElement {
- private Gee.ArrayList<DocElement> content;
- private TextVerticalPosition hpos;
- private TextPosition pos;
- private int dcells;
- private int cells;
-
- public override void parse ( TextPosition pos, TextVerticalPosition hpos, int cells, int dcells, Gee.ArrayList<DocElement> content ) {
- this.content = content;
- this.dcells = dcells;
- this.cells = cells;
- this.hpos = hpos;
- this.pos = pos;
- }
-
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- int _max = this.content.size;
- int _index = 0;
-
- GLib.StringBuilder td = new GLib.StringBuilder ( "\t\t<td" );
- if ( this.cells != 1 ) {
- td.append ( " colspan=\"" );
- td.append ( this.cells.to_string() );
- td.append_unichar ( '\"' );
- }
-
- if ( this.dcells != 1 ) {
- td.append ( " rowspan=\"" );
- td.append ( this.dcells.to_string() );
- td.append_unichar ( '\"' );
- }
-
- switch ( this.pos ) {
- case TextPosition.CENTER:
- td.append ( " align=\"center\"" );
- break;
- case TextPosition.RIGHT:
- td.append ( " align=\"right\"" );
- break;
- }
-
- switch ( this.hpos ) {
- case TextVerticalPosition.TOP:
- td.append ( " valign=\"top\"" );
- break;
- case TextVerticalPosition.BOTTOM:
- td.append ( " valign=\"bottom\"" );
- break;
- }
-
- td.append_unichar ( '>' );
-
- file.puts ( td.str );
- foreach ( DocElement cell in this.content ) {
- cell.write ( res, _max, _index );
- _index++;
- }
- file.puts ( "</td>\n" );
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.ExceptionTaglet : Valadoc.MainTaglet {
- public override int order { get { return 200; } }
- private Gee.ArrayList<DocElement> content;
- private string paramname;
-
- public override bool parse ( Settings settings, Tree tree, DocumentedElement me, Gee.Collection<DocElement> content, ref ErrorLevel errlvl, out string errmsg ) {
- if ( me is Valadoc.ExceptionHandler == false ) {
- errmsg = "Tag @throws cannot be used in this context";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- if ( content.size == 0 ) {
- errmsg = "Exception name was expected";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
-
- Gee.ArrayList<DocElement> contentlst = new Gee.ArrayList<DocElement> ();
- foreach ( DocElement element in content ) {
- contentlst.add ( element );
- }
-
- DocElement tag = contentlst.get( 0 );
- if ( tag is StringTaglet == false ) {
- errmsg = "Exception name was expected";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- string str = ((StringTaglet)tag).content;
- weak string lposa = str.chr (-1, '\n');
- weak string lposb = str.chr (-1, ' ');
- weak string lpos;
-
- long lposaoffset = (lposa == null)? long.MAX : str.pointer_to_offset ( lposa );
- long lposboffset = (lposb == null)? long.MAX : str.pointer_to_offset ( lposb );
-
- if ( lposaoffset < lposboffset ) {
- lpos = lposa;
- }
- else {
- lpos = lposb;
- }
-
- if ( lpos == null ) {
- this.paramname = str.strip ();
- ((StringTaglet)tag).content = "";
- }
- else {
- int namepos = (int)str.pointer_to_offset ( lpos );
- this.paramname = str.ndup ( namepos ).strip ();
- ((StringTaglet)tag).content = lpos.ndup ( lpos.size () ).chomp ();
- }
-
- bool tmp = this.check_exception_parameter_name ( (Valadoc.ExceptionHandler)me, this.paramname );
- if ( tmp == false ) {
- errmsg = "Exception name was expected";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- this.content = contentlst;
- return true;
- }
-
- private bool check_exception_parameter_name ( Valadoc.ExceptionHandler me, string paramname ) {
- string paramname2 = "."+paramname;
-
- foreach ( DocumentedElement param in me.get_error_domains() ) {
- if ( param.name == paramname || param.full_name() == paramname || param.full_name().has_suffix(paramname2) ) {
- return true;
- }
- }
- return false;
- }
-
- public override bool write ( void* ptr, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)ptr;
-
- file.printf ( "\t<tr>\n" );
- file.printf ( "\t\t<td class=\"%s\">%s:</td>\n", css_parameter_table_name, this.paramname );
- file.printf ( "\t\t<td class=\"%s\">\n", css_parameter_table_text );
- file.puts ( "\t\t\t" );
-
- int _max = this.content.size;
- int _index = 0;
-
- foreach ( DocElement element in this.content ) {
- element.write ( ptr, _max, _index );
- _index++;
- }
-
- file.puts ( "\n" );
- file.printf ( "\t\t</td>\n" );
- file.printf ( "\t</tr>\n" );
- return true;
- }
-
- public override bool write_block_start ( void* ptr ) {
- weak GLib.FileStream file = (GLib.FileStream)ptr;
- file.printf ( "<h2 class=\"%s\">Exceptions:</h2>\n", css_title );
- file.printf ( "<table class=\"%s\">\n", css_exception_table );
- return true;
- }
-
- public override bool write_block_end ( void* ptr ) {
- weak GLib.FileStream file = (GLib.FileStream)ptr;
- file.printf ( "</table>\n" );
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.TypeLinkInlineTaglet : Valadoc.InlineTaglet {
- private string? link = null;
- private string? name = null;
- private string? css = null;
-
- protected override string to_string ( ) {
- return this.name;
- }
-
- protected override bool write ( void* res, int max, int index ) {
- if ( this.link == null ) {
- ((GLib.FileStream)res).printf ( "<span class=\"%s\">%s</span>", this.css, this.name );
- }
- else {
- ((GLib.FileStream)res).printf ( "<a class=\"%s\" href=\"%s\">%s</a>", this.css, this.link, this.name );
- }
-
- return true;
- }
-
- protected override bool parse ( Settings settings, Tree tree, Documentation self, string content, ref ErrorLevel errlvl, out string? errmsg ) {
- Valadoc.DocumentedElement? element = tree.search_symbol_str ( (self is DocumentedElement)? (DocumentedElement)self : null, content.strip() );
- if ( element == null ) {
- errmsg = "Linked type is not available";
- errlvl = ErrorLevel.ERROR;
- return false;
- }
-
- this.name = element.full_name ();
- if (self is DocumentedElement) {
- var doc_element = (DocumentedElement) self;
- var doc_element_name = doc_element.full_name ();
-
- if (this.name == doc_element_name) {
- this.name = element.name;
- } else if (this.name.has_prefix (doc_element_name)) {
- this.name = this.name.substring (doc_element_name.length + 1);
- } else if (doc_element.parent != null && doc_element.parent is DocumentedElement) {
- var doc_parent_element_name = ((DocumentedElement) doc_element.parent).full_name ();
- if (this.name == doc_parent_element_name) {
- this.name = element.name;
- } else if (this.name.has_prefix (doc_parent_element_name)) {
- this.name = this.name.substring (doc_parent_element_name.length + 1);
- }
- }
- }
- this.css = get_html_content_link_css_class ( element );
- this.link = get_html_link ( settings, element, self );
- return true;
- }
-}
-
-
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.UnderlinedDocElement : Valadoc.UnderlinedDocElement {
- private Gee.ArrayList<DocElement> content;
-
- public override bool parse ( Gee.ArrayList<DocElement> content ) {
- this.content = content;
- return true;
- }
-
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- int _max = this.content.size;
- int _index = 0;
-
- file.printf ( "<u>" );
-
- foreach ( DocElement element in this.content ) {
- element.write ( res, _max, _index );
- _index++;
- }
-
- file.printf ( "</u>" );
- return true;
- }
-}
-
-
filehelper.vala \
langlet.vala \
settings.vala \
- documentation/doctree.vala \
+ documentation/documentation.vala \
documentation/errorreporter.vala \
documentation/moduleloader.vala \
- documentation/parser.vala \
documentation/wiki.vala \
apitree/apitree.vala \
apitree/array.vala \
apitree/typeparameter.vala \
apitree/typereference.vala \
apitree/visitable.vala \
- html/attribute.vala \
- html/block.vala \
- html/htmlwriter.vala \
- html/inline.vala \
- html-apiwriter/apiwriter.vala \
- html-apiwriter/apiwriter-vala.vala \
+ content/block.vala \
+ content/blockcontent.vala \
+ content/comment.vala \
+ content/contentfactory.vala \
+ content/contentelement.vala \
+ content/contentrenderer.vala \
+ content/contentvisitor.vala \
+ content/embedded.vala \
+ content/headline.vala \
+ content/highlighted.vala \
+ content/inline.vala \
+ content/inlinetaglet.vala \
+ content/inlinecontent.vala \
+ content/link.vala \
+ content/list.vala \
+ content/listitem.vala \
+ content/page.vala \
+ content/paragraph.vala \
+ content/resourcelocator.vala \
+ content/sourcecode.vala \
+ content/styleattributes.vala \
+ content/symbollink.vala \
+ content/table.vala \
+ content/tablecell.vala \
+ content/taglet.vala \
+ content/text.vala \
+ parser/commentscanner.vala \
+ parser/documentationparser.vala \
+ parser/manyrule.vala \
+ parser/oneofrule.vala \
+ parser/optionalrule.vala \
+ parser/parser.vala \
+ parser/parsercallback.vala \
+ parser/rule.vala \
+ parser/scanner.vala \
+ parser/sequencerule.vala \
+ parser/sourcelocation.vala \
+ parser/stubrule.vala \
+ parser/token.vala \
+ parser/tokentype.vala \
+ parser/wikiscanner.vala \
+ taglets/tagletdeprecated.vala \
+ taglets/tagletinheritdoc.vala \
+ taglets/tagletinit.vala \
+ taglets/tagletlink.vala \
+ taglets/tagletparam.vala \
+ taglets/tagletreturn.vala \
+ taglets/tagletsee.vala \
+ taglets/tagletsince.vala \
+ taglets/tagletthrows.vala \
$(NULL)
libvaladoc.vala.stamp: $(libvaladoc_la_VALASOURCES)
- $(VALAC) -C -H valadoc-1.0.h --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 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 $^
touch $@
}
}
- public void parse_comments (Valadoc.Parser docparser) {
+ public void parse_comments (DocumentationParser docparser) {
this.wikitree = new WikiPageTree(this.reporter, this.settings);
wikitree.create_tree (docparser);
doclet.visit_class ( this );
}
- internal void parse_comments ( Valadoc.Parser docparser ) {
+ internal void parse_comments ( DocumentationParser docparser ) {
if ( this.documentation != null )
return ;
if ( this.vcomment != null ) {
- if ( docparser.is_inherit_doc ( this ) && this.base_type != null ) {
- ((Class)this.base_type).parse_comments ( docparser );
- this.documentation = this.base_type.documentation;
- }
- else {
- this.parse_comment_helper ( docparser );
- }
+ this.parse_comment_helper ( docparser );
}
this.parse_construction_method_comments ( docparser );
}
}
- protected void parse_class_comments ( Valadoc.Parser docparser ) {
+ protected void parse_class_comments ( DocumentationParser docparser ) {
foreach ( Class cl in this.classes ) {
cl.parse_comments ( docparser );
}
((ReturnTypeHandler)this).set_return_type_references ( );
}
- internal void parse_comment ( Valadoc.Parser docparser ) {
+ internal void parse_comment ( DocumentationParser docparser ) {
this.parse_comment_helper ( docparser );
}
}
}
- internal void parse_constant_comments ( Valadoc.Parser docparser ) {
+ internal void parse_constant_comments ( DocumentationParser docparser ) {
foreach ( Constant c in this.constants ) {
c.parse_comment ( docparser );
}
return lst.read_only_view;
}
- protected void parse_construction_method_comments ( Valadoc.Parser docparser ) {
+ protected void parse_construction_method_comments ( DocumentationParser docparser ) {
foreach ( Method cm in this.construction_methods ) {
cm.parse_comment ( docparser );
}
this.add_exception_list ( vexceptionlst );
}
- internal void parse_comment ( Valadoc.Parser docparser ) {
+ internal void parse_comment ( DocumentationParser docparser ) {
this.parse_comment_helper ( docparser );
}
}
}
- public void parse_delegate_comments ( Valadoc.Parser docparser ) {
+ public void parse_delegate_comments ( DocumentationParser docparser ) {
foreach ( Delegate del in this.delegates ) {
del.parse_comment ( docparser );
}
get; set;
}
- public DocumentationTree? documentation {
+ public Content.Comment? documentation {
protected set;
get;
}
return GLib.Path.get_basename ( path );
}
- protected void parse_comment_helper ( Valadoc.Parser docparser ) {
+ protected void parse_comment_helper ( DocumentationParser docparser ) {
this.documentation = docparser.parse ( this );
}
return this.en_values.read_only_view;
}
- internal void parse_comments ( Valadoc.Parser docparser ) {
+ internal void parse_comments ( DocumentationParser docparser ) {
this.parse_comment_helper ( docparser );
foreach ( EnumValue enval in this.en_values ) {
this.enums.add( tmp );
}
- protected void parse_enum_comments ( Valadoc.Parser docparser ) {
+ protected void parse_enum_comments ( DocumentationParser docparser ) {
foreach ( Enum en in this.enums ) {
en.parse_comments ( docparser );
}
return ( this.venval == venval );
}
- public void parse_comment ( Valadoc.Parser docparser ) {
+ public void parse_comment ( DocumentationParser docparser ) {
this.parse_comment_helper ( docparser );
}
langlet.write_error_code ( this, ptr );
}
- public void parse_comment ( Valadoc.Parser docparser ) {
+ public void parse_comment ( DocumentationParser docparser ) {
this.parse_comment_helper ( docparser );
}
return null;
}
- internal void parse_comments ( Valadoc.Parser docparser ) {
+ internal void parse_comments ( DocumentationParser docparser ) {
this.parse_comment_helper ( docparser );
this.parse_method_comments ( docparser );
}
}
- protected void parse_errordomain_comments ( Valadoc.Parser docparser ) {
+ protected void parse_errordomain_comments ( DocumentationParser docparser ) {
foreach ( ErrorDomain errdom in this.errdoms ) {
errdom.parse_comments ( docparser );
}
((ReturnTypeHandler)this).set_return_type_references ( );
}
- internal void parse_comment ( Valadoc.Parser docparser ) {
+ internal void parse_comment ( DocumentationParser docparser ) {
this.parse_comment_helper ( docparser );
}
}
}
- internal void parse_field_comments ( Valadoc.Parser docparser ) {
+ internal void parse_field_comments ( DocumentationParser docparser ) {
foreach ( Field field in this.fields ) {
field.parse_comment ( docparser );
}
langlet.write_interface ( this, ptr );
}
- internal void parse_comments ( Valadoc.Parser docparser ) {
+ internal void parse_comments ( DocumentationParser docparser ) {
this.parse_comment_helper ( docparser );
this.parse_delegate_comments ( docparser );
this.parse_property_comments ( docparser );
}
}
- protected void parse_interface_comments ( Valadoc.Parser docparser ) {
+ protected void parse_interface_comments ( DocumentationParser docparser ) {
foreach ( Interface iface in this.interfaces ) {
iface.parse_comments ( docparser );
}
return (m.vmethod == this.vmethod);
}
- internal void parse_comment (Valadoc.Parser docparser) {
+ internal void parse_comment (DocumentationParser docparser) {
if (this.documentation != null)
return ;
if (this.vcomment == null)
return ;
- if (this.base_method != null && docparser.is_inherit_doc (this)) {
- this.base_method.parse_comment (docparser);
- this.documentation = this.base_method.documentation;
- return ;
- }
-
this.parse_comment_helper (docparser);
}
}
}
- internal void parse_method_comments ( Valadoc.Parser docparser ) {
+ internal void parse_method_comments ( DocumentationParser docparser ) {
foreach ( Method m in this.methods ) {
m.parse_comment ( docparser );
}
this.set_enum_type_references ();
}
- internal void parse_comments (Valadoc.Parser docparser) {
+ internal void parse_comments (DocumentationParser docparser) {
this.parse_comment_helper (docparser);
this.parse_enum_comments (docparser);
this.parse_field_comments (docparser);
}
}
- internal void parse_namespace_comments ( Valadoc.Parser docparser ) {
+ internal void parse_namespace_comments ( DocumentationParser docparser ) {
foreach ( Namespace ns in this.namespaces ){
ns.parse_comments ( docparser );
}
doclet.visit_package ( this );
}
- internal void parse_comments ( Valadoc.Parser docparser ) {
+ internal void parse_comments ( DocumentationParser docparser ) {
this.parse_namespace_comments ( docparser );
}
this.set_return_type_references ( );
}
- public void parse_comment (Valadoc.Parser docparser) {
+ public void parse_comment (DocumentationParser docparser) {
if (this.documentation != null)
return ;
if (this.vcomment == null)
return ;
- if (this.base_property != null && docparser.is_inherit_doc (this)) {
- this.base_property.parse_comment (docparser);
- this.documentation = this.base_property.documentation;
- return ;
- }
-
this.parse_comment_helper (docparser);
}
return lst.read_only_view;
}
- protected void parse_property_comments ( Valadoc.Parser docparser ) {
+ protected void parse_property_comments ( DocumentationParser docparser ) {
foreach ( Property prop in this.properties ) {
prop.parse_comment ( docparser );
}
this.set_return_type_references ( );
}
- internal void parse_comment (Valadoc.Parser docparser) {
+ internal void parse_comment (DocumentationParser docparser) {
this.parse_comment_helper (docparser);
}
}
}
- internal void parse_signal_comments ( Valadoc.Parser docparser ) {
+ internal void parse_signal_comments ( DocumentationParser docparser ) {
foreach ( Signal sig in this.signals ) {
sig.parse_comment ( docparser );
}
langlet.write_struct (this, ptr);
}
- internal void parse_comments (Valadoc.Parser docparser) {
+ internal void parse_comments (DocumentationParser docparser) {
if (this.documentation != null)
return ;
if (this.vcomment != null) {
- if ( docparser.is_inherit_doc (this) && this.base_type != null) {
- ((Valadoc.Struct)this.base_type).parse_comments (docparser);
- this.documentation = this.base_type.documentation;
- }
- else {
- this.parse_comment_helper (docparser);
- }
+ this.parse_comment_helper (docparser);
}
this.parse_construction_method_comments (docparser);
}
}
- protected void parse_struct_comments ( Valadoc.Parser docparser ) {
+ protected void parse_struct_comments ( DocumentationParser docparser ) {
foreach ( Struct stru in this.structs ) {
stru.parse_comments ( docparser );
}
--- /dev/null
+/* block.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public interface Valadoc.Content.Block : ContentElement {
+}
--- /dev/null
+/* blockcontent.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public abstract class Valadoc.Content.BlockContent : ContentElement {
+ public Gee.List<Block> content { get { return _content; } }
+
+ private Gee.List<Block> _content;
+
+ internal BlockContent () {
+ _content = new ArrayList<Block> ();
+ }
+
+ public override void configure (Settings settings, ResourceLocator locator) {
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ foreach (Block element in _content) {
+ element.check (api_root, container, reporter);
+ }
+ }
+
+ public override void accept_children (ContentVisitor visitor) {
+ foreach (Block element in _content) {
+ element.accept (visitor);
+ }
+ }
+}
--- /dev/null
+/* comment.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public class Valadoc.Content.Comment : BlockContent {
+ public Gee.List<Taglet> taglets { get { return _taglets; } }
+
+ private Gee.List<Taglet> _taglets;
+
+ internal Comment () {
+ base ();
+ _taglets = new ArrayList<Taglet> ();
+ }
+
+ public override void configure (Settings settings, ResourceLocator locator) {
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ base.check (api_root, container, reporter);
+
+ foreach (Taglet element in _taglets) {
+ element.check (api_root, container, reporter);
+ }
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_comment (this);
+ }
+
+ public override void accept_children (ContentVisitor visitor) {
+ base.accept_children (visitor);
+
+ foreach (Taglet element in _taglets) {
+ element.accept (visitor);
+ }
+ }
+
+ public Gee.List<Taglet> find_taglets (DocumentedElement? container, Type taglet_type) {
+ Gee.List<Taglet> selected_taglets = new ArrayList<Taglet> ();
+
+ // TODO inherit stuff if needed
+
+ foreach (Taglet taglet in _taglets) {
+ if (taglet.get_type () == taglet_type) {
+ selected_taglets.add (taglet);
+ }
+ }
+
+ return selected_taglets;
+ }
+}
--- /dev/null
+/* contentelement.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public abstract class Valadoc.Content.ContentElement : Object {
+
+ public virtual void configure (Settings settings, ResourceLocator locator) {
+ }
+
+ public abstract void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter);
+
+ public abstract void accept (ContentVisitor visitor);
+
+ public virtual void accept_children (ContentVisitor visitor) {
+ }
+}
--- /dev/null
+/* contentfactory.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public class Valadoc.Content.ContentFactory : Object {
+
+ public ContentFactory (Settings settings, ResourceLocator locator, ModuleLoader modules) {
+ _settings = settings;
+ _locator = locator;
+ _modules = modules;
+ }
+
+ private Settings _settings;
+ private ResourceLocator _locator;
+ private ModuleLoader _modules;
+
+ private inline ContentElement configure (ContentElement element) {
+ element.configure (_settings, _locator);
+ return element;
+ }
+
+ public Comment create_comment () {
+ return (Comment) configure (new Comment ());
+ }
+
+ public Embedded create_embedded () {
+ return (Embedded) configure (new Embedded ());
+ }
+
+ public Headline create_headline () {
+ return (Headline) configure (new Headline ());
+ }
+
+ public Highlighted create_highlighted (Highlighted.Style style) {
+ return (Highlighted) configure (new Highlighted (style));
+ }
+
+ public Link create_link () {
+ return (Link) configure (new Link ());
+ }
+
+ public List create_list () {
+ return (List) configure (new List ());
+ }
+
+ public ListItem create_list_item () {
+ return (ListItem) configure (new ListItem ());
+ }
+
+ public Page create_page () {
+ return (Page) configure (new Page ());
+ }
+
+ public Paragraph create_paragraph () {
+ return (Paragraph) configure (new Paragraph ());
+ }
+
+ public SourceCode create_source_code () {
+ return (SourceCode) configure (new SourceCode ());
+ }
+
+ public Table create_table () {
+ return (Table) configure (new Table ());
+ }
+
+ public TableCell create_table_cell () {
+ return (TableCell) configure (new TableCell ());
+ }
+
+ public Taglet create_taglet (string name) {
+ return _modules.create_taglet (name);
+ }
+
+ public Text create_text (string? text = null) {
+ return (Text) configure (new Text (text));
+ }
+
+ public ContentElement set_style_attributes (StyleAttributes element,
+ VerticalAlign? valign,
+ HorizontalAlign? halign,
+ string? style) {
+ element.vertical_align = valign;
+ element.horizontal_align = halign;
+ element.style = style;
+ return element;
+ }
+}
--- /dev/null
+/* contentrenderer.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public abstract class Valadoc.Content.ContentRenderer : ContentVisitor {
+
+ public abstract void render (ContentElement element);
+
+ public abstract void render_children (ContentElement element);
+}
--- /dev/null
+/* contentvisitor.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public abstract class Valadoc.Content.ContentVisitor : Object {
+
+ public virtual void visit_comment (Comment element) {
+ }
+
+ public virtual void visit_embedded (Embedded element) {
+ }
+
+ public virtual void visit_headline (Headline element) {
+ }
+
+ public virtual void visit_highlighted (Highlighted element) {
+ }
+
+ public virtual void visit_link (Link element) {
+ }
+
+ public virtual void visit_symbol_link (SymbolLink element) {
+ }
+
+ public virtual void visit_list (List element) {
+ }
+
+ public virtual void visit_list_item (ListItem element) {
+ }
+
+ public virtual void visit_paragraph (Paragraph element) {
+ }
+
+ public virtual void visit_page (Page element) {
+ }
+
+ public virtual void visit_source_code (SourceCode element) {
+ }
+
+ public virtual void visit_table (Table element) {
+ }
+
+ public virtual void visit_table_cell (TableCell element) {
+ }
+
+ public virtual void visit_taglet (Taglet element) {
+ }
+
+ public virtual void visit_text (Text element) {
+ }
+}
--- /dev/null
+/* embedded.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public class Valadoc.Content.Embedded : ContentElement, Inline, StyleAttributes {
+ public string url { get; set; }
+ public string caption { get; set; }
+
+ public HorizontalAlign? horizontal_align { get; set; }
+ public VerticalAlign? vertical_align { get; set; }
+ public string? style { get; set; }
+
+ private ResourceLocator _locator;
+
+ internal Embedded () {
+ base ();
+ }
+
+ public override void configure (Settings settings, ResourceLocator locator) {
+ _locator = locator;
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ // Check the image exists if it a local resource
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_embedded (this);
+ }
+}
--- /dev/null
+/* headline.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public class Valadoc.Content.Headline : Block, InlineContent {
+ public int level { get; set; }
+
+ internal Headline () {
+ base ();
+ _level = 0;
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ // TODO report error if level == 0 ?
+
+ // Check inline content
+ base.check (api_root, container, reporter);
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_headline (this);
+ }
+}
-/*
+/* highlighted.vala
+ *
* Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
+ * 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 'Ptitjes Villevalois <ptitjes@free.fr>
*/
-
using GLib;
using Gee;
-
-public class Valadoc.Html.BoldDocElement : Valadoc.BoldDocElement {
- private Gee.ArrayList<DocElement> content;
-
- public override bool parse ( Gee.ArrayList<DocElement> content ) {
- this.content = content;
- return true;
+public class Valadoc.Content.Highlighted : InlineContent, Inline {
+ public enum Style {
+ NONE,
+ BOLD,
+ ITALIC,
+ UNDERLINED,
+ MONOSPACED,
+ STROKE
}
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- int _max = this.content.size;
- int _index = 0;
+ public Style style { get; set; }
- file.printf ( "<b>" );
+ internal Highlighted (Style style) {
+ base ();
+ _style = style;
+ }
- foreach ( DocElement element in this.content ) {
- element.write ( res, _max, _index );
- _index++;
- }
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ // Check inline content
+ base.check (api_root, container, reporter);
+ }
- file.printf ( "</b>" );
- return true;
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_highlighted (this);
}
}
-
-
-
--- /dev/null
+/* inline.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public interface Valadoc.Content.Inline : ContentElement {
+}
-/*
+/* inlinecontent.vala
+ *
* Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
+ * 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 'Ptitjes Villevalois <ptitjes@free.fr>
*/
-
using GLib;
using Gee;
+public abstract class Valadoc.Content.InlineContent : ContentElement {
+ public Gee.List<Inline> content { get { return _content; } }
-public class Valadoc.Html.ItalicDocElement : Valadoc.ItalicDocElement {
- private Gee.ArrayList<DocElement> content;
+ private Gee.List<Inline> _content;
- public override bool parse ( Gee.ArrayList<DocElement> content ) {
- this.content = content;
- return true;
+ construct {
+ _content = new ArrayList<Inline> ();
}
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- int _max = this.content.size;
- int _index = 0;
-
- file.printf ( "<i>" );
+ internal InlineContent () {
+ }
- foreach ( DocElement element in this.content ) {
- element.write ( res, _max, _index );
- _index++;
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ foreach (Inline element in _content) {
+ element.check (api_root, container, reporter);
}
+ }
- file.printf ( "</i>" );
- return true;
+ public override void accept_children (ContentVisitor visitor) {
+ foreach (Inline element in _content) {
+ element.accept (visitor);
+ }
}
}
-
-
--- /dev/null
+/* taglet.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public abstract class Valadoc.Content.InlineTaglet : ContentElement, Taglet, Inline {
+ protected Settings settings;
+ protected ResourceLocator locator;
+ private ContentElement _content;
+
+ public InlineTaglet () {
+ base ();
+ }
+
+ public abstract Rule? get_parser_rule (Rule run_rule);
+
+ public abstract ContentElement produce_content ();
+
+ private ContentElement get_content () {
+ if (_content == null) {
+ _content = produce_content ();
+ }
+ return _content;
+ }
+
+ public override void configure (Settings settings, ResourceLocator locator) {
+ this.settings = settings;
+ this.locator = locator;
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ ContentElement element = get_content ();
+ element.check (api_root, container, reporter);
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ ContentElement element = get_content ();
+ element.accept (visitor);
+ }
+}
--- /dev/null
+/* link.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public class Valadoc.Content.Link : ContentElement, Inline {
+ public string url { get; set; }
+ public string label { get; set; }
+
+ internal Link () {
+ base ();
+ }
+
+ public override void configure (Settings settings, ResourceLocator locator) {
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_link (this);
+ }
+}
-/*
+/* list.vala
+ *
* Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
+ * 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 'Ptitjes Villevalois <ptitjes@free.fr>
*/
-
using GLib;
using Gee;
+public class Valadoc.Content.List : ContentElement, Block {
+ public Gee.List<ListItem> items { get { return _items; } }
+
+ private Gee.List<ListItem> _items;
-public class Valadoc.Html.ListEntryDocElement : Valadoc.ListEntryDocElement {
- private Gee.ArrayList<DocElement> content;
-
- public override bool parse ( ListType type, long lvl, Gee.ArrayList<DocElement> content ) {
- this.content = content;
- return true;
+ internal List () {
+ base ();
+ _items = new ArrayList<ListItem> ();
}
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- int _max = this.content.size;
- int _index = 0;
-
- file.printf ( "\t<li>" );
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ // Check the list consistency in terms of successive item levels ?
- foreach ( DocElement element in this.content ) {
- element.write ( res, _max, _index );
- _index++;
+ // Check individual list items
+ foreach (ListItem element in _items) {
+ element.check (api_root, container, reporter);
}
+ }
- file.printf ( "</li>\n" );
- return true;
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_list (this);
}
}
-
-
--- /dev/null
+/* listitem.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public class Valadoc.Content.ListItem : InlineContent {
+ public enum Bullet {
+ NONE,
+ UNORDERED,
+ ORDERED,
+ ORDERED_LATIN,
+ ORDERED_CAPITAL,
+ ORDERED_NUMBER,
+ ORDERED_LOWER_CASE
+ }
+
+ public Bullet bullet { get; set; }
+ public int level { get; set; }
+
+ internal ListItem () {
+ base ();
+ _bullet = Bullet.UNORDERED;
+ _level = 0;
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ // TODO report error if level == 0 ?
+
+ // Check inline content
+ base.check (api_root, container, reporter);
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_list_item (this);
+ }
+}
-/*
+/* page.vala
+ *
* Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
+ * 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 'Ptitjes Villevalois <ptitjes@free.fr>
*/
-
using GLib;
using Gee;
-
-public class Valadoc.Html.HeadlineDocElement : Valadoc.HeadlineDocElement {
- private string title;
- private int lvl;
-
- public override bool parse (string title, int lvl) {
- this.title = title;
- this.lvl = lvl;
- return true;
+public class Valadoc.Content.Page : BlockContent {
+ internal Page () {
+ base ();
}
- public override bool write (void* res, int max, int index) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- file.printf ("\n\n<h%d>%s</h%d>\n", this.lvl, this.title, this.lvl);
- return true;
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_page (this);
}
}
-
-
--- /dev/null
+/* paragraph.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public class Valadoc.Content.Paragraph : InlineContent, Block, StyleAttributes {
+ public HorizontalAlign? horizontal_align { get; set; }
+ public VerticalAlign? vertical_align { get; set; }
+ public string? style { get; set; }
+
+ internal Paragraph () {
+ base ();
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ // Check inline content
+ base.check (api_root, container, reporter);
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_paragraph (this);
+ }
+}
--- /dev/null
+/* resourcelocator.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public interface Valadoc.ResourceLocator : Object {
+ public abstract string resolve (string path);
+}
--- /dev/null
+/* sourcecode.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public class Valadoc.Content.SourceCode : ContentElement, Block {
+ public enum Language {
+ GENIE,
+ VALA,
+ C
+ }
+
+ public string code { get; set; }
+ public Language language { get; set; }
+
+ internal SourceCode () {
+ base ();
+ _language = Language.VALA;
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_source_code (this);
+ }
+}
--- /dev/null
+/* styleattributes.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public enum Valadoc.Content.HorizontalAlign {
+ LEFT,
+ RIGHT,
+ CENTER
+}
+
+public enum Valadoc.Content.VerticalAlign {
+ TOP,
+ MIDDLE,
+ BOTTOM
+}
+
+public interface Valadoc.Content.StyleAttributes : ContentElement {
+ public abstract HorizontalAlign? horizontal_align { get; set; }
+ public abstract VerticalAlign? vertical_align { get; set; }
+ public abstract string? style { get; set; }
+}
--- /dev/null
+/* link.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public class Valadoc.Content.SymbolLink : ContentElement, Inline {
+ public DocumentedElement symbol { get; set; }
+ public string label { get; set; }
+
+ internal SymbolLink (DocumentedElement? symbol = null, string? label = null) {
+ base ();
+ _symbol = symbol;
+ _label = label;
+ }
+
+ public override void configure (Settings settings, ResourceLocator locator) {
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_symbol_link (this);
+ }
+}
--- /dev/null
+/* table.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public class Valadoc.Content.Table : ContentElement, Block {
+ public Gee.List<Gee.List<TableCell>> cells { get { return _cells; } }
+
+ private Gee.List<Gee.List<TableCell>> _cells;
+
+ internal Table () {
+ base ();
+ _cells = new ArrayList<Gee.List<TableCell>> ();
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ // Check the table consistency in term of row/column number
+
+ // Check individual cells
+ foreach (var row in _cells) {
+ foreach (var cell in row) {
+ cell.check (api_root, container, reporter);
+ }
+ }
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_table (this);
+ }
+}
--- /dev/null
+/* tablecell.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public class Valadoc.Content.TableCell : InlineContent, StyleAttributes {
+ public HorizontalAlign? horizontal_align { get; set; }
+ public VerticalAlign? vertical_align { get; set; }
+ public string? style { get; set; }
+ public int colspan { get; set; }
+ public int rowspan { get; set; }
+
+ internal TableCell () {
+ base ();
+ _colspan = 1;
+ _rowspan = 1;
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ // Check inline content
+ base.check (api_root, container, reporter);
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_table_cell (this);
+ }
+}
--- /dev/null
+/* taglet.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+
+public interface Valadoc.Content.Taglet : ContentElement {
+
+ public abstract Rule? get_parser_rule (Rule run_rule);
+}
-/*
+/* text.vala
+ *
* Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
+ * 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 'Ptitjes Villevalois <ptitjes@free.fr>
*/
-
using GLib;
using Gee;
+public class Valadoc.Content.Text : ContentElement, Inline {
+ public string content { get; set; }
-public class Valadoc.Html.ParagraphDocElement : Valadoc.ParagraphDocElement {
- private ArrayList<DocElement> content;
-
- public override bool parse (ArrayList<DocElement> content) {
- this.content = content;
- return true;
+ construct {
+ _content = "";
}
- public override bool write (void* res, int max, int index) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- int _max = this.content.size;
- int _index = 0;
-
- file.printf ("<p>");
-
- foreach (DocElement element in this.content) {
- element.write (res, _max, _index);
- _index++;
+ internal Text (string? text = null) {
+ if (text != null) {
+ _content = text;
}
-
- file.printf ("</p>");
- return true;
}
-}
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ }
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_text (this);
+ }
+}
+++ /dev/null
-/*
- * Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
- * 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.
- */
-
-using GLib;
-using Gee;
-
-
-
-public enum Valadoc.TextVerticalPosition {
- TOP,
- MIDDLE,
- BOTTOM
-}
-
-public enum Valadoc.TextPosition {
- LEFT,
- RIGHT,
- CENTER
-}
-
-public enum Valadoc.ImageDocElementPosition {
- NEUTRAL,
- MIDDLE,
- RIGHT,
- LEFT
-}
-
-public enum Valadoc.Language {
- GENIE,
- VALA,
- C
-}
-
-public enum Valadoc.ListType {
- UNSORTED,
- SORTED
-}
-
-
-public interface Valadoc.Documentation : Object {
- public abstract string? get_filename ();
-}
-
-public abstract class Valadoc.DocElement : Object {
- public abstract bool write (void* res, int max, int index);
-}
-
-public abstract class Valadoc.Taglet : DocElement {
-}
-
-public abstract class Valadoc.InlineTaglet : Taglet {
- public abstract bool parse (Settings settings, Tree tree, Documentation self, string content, ref ErrorLevel errlvl, out string? errmsg);
- public abstract string to_string ();
-}
-
-public abstract class Valadoc.CodeConstantDocElement : Valadoc.DocElement {
- public abstract bool parse (string constant);
-}
-
-public abstract class Valadoc.MainTaglet : Taglet {
- // deprecated
- protected string? get_data_type (DocumentedElement me) {
- if (me is Valadoc.Class)
- return "class";
- if (me is Valadoc.Delegate)
- return "delegate";
- if (me is Valadoc.Interface)
- return "interface";
- if (me is Valadoc.Method)
- return "method";
- if (me is Valadoc.Property)
- return "property";
- if (me is Valadoc.Signal)
- return "signal";
- if (me is Valadoc.Enum)
- return "enum";
- if (me is Valadoc.EnumValue)
- return "enum-value";
- if (me is Valadoc.ErrorDomain)
- return "errordomain";
- if (me is Valadoc.ErrorCode)
- return "error-code";
- if (me is Valadoc.Field)
- return "field";
- if (me is Valadoc.Constant)
- return "constant";
- if (me is Valadoc.Namespace)
- return "namespace";
-
- return null;
- }
-
- public virtual int order { get { return 0; } }
- public abstract bool parse (Settings settings, Tree tree, DocumentedElement me, Gee.Collection<DocElement> content, ref ErrorLevel errlvl, out string errmsg);
- public abstract bool write_block_start (void* res);
- public abstract bool write_block_end (void* res);
-}
-
-
-
-public abstract class Valadoc.StringTaglet : Taglet {
- // deprecated
- public string content {
- protected set; get;
- }
-
- public abstract bool parse (string content);
-}
-
-public abstract class Valadoc.ParagraphDocElement : DocElement {
- public abstract bool parse (ArrayList<DocElement> paragraph);
-}
-
-public abstract class Valadoc.HeadlineDocElement : DocElement {
- public abstract bool parse (string title, int lvl);
-}
-
-public abstract class Valadoc.ImageDocElement : DocElement {
- public abstract bool parse (Settings settings, Documentation pos, owned string path, owned string alt);
-}
-
-public abstract class Valadoc.LinkDocElement : DocElement {
- public abstract bool parse (Settings settings, Tree tree, Documentation pos, owned string link, owned string desc);
-}
-
-public abstract class Valadoc.SourceCodeDocElement : DocElement {
- public abstract bool parse (string src, Language lang);
-}
-
-public abstract class Valadoc.ListEntryDocElement : DocElement {
- public abstract bool parse (ListType type, long lvl, Gee.ArrayList<DocElement> content);
-}
-
-public abstract class Valadoc.ListDocElement : DocElement {
- public abstract bool parse (ListType type, Gee.ArrayList<ListEntryDocElement> entries);
-}
-
-public abstract class Valadoc.NotificationDocElement : DocElement {
- public abstract bool parse (Gee.ArrayList<DocElement> content);
-}
-
-
-public abstract class Valadoc.HighlightedDocElement : DocElement {
- public abstract bool parse (Gee.ArrayList<DocElement> content);
-}
-
-public abstract class Valadoc.ItalicDocElement : HighlightedDocElement {
-}
-
-public abstract class Valadoc.BoldDocElement : HighlightedDocElement {
-}
-
-public abstract class Valadoc.UnderlinedDocElement : HighlightedDocElement {
-}
-
-
-
-public abstract class Valadoc.ContentPositionDocElement : DocElement {
- public abstract bool parse (Gee.ArrayList<DocElement> content);
-}
-
-public abstract class Valadoc.CenterDocElement : ContentPositionDocElement {
-}
-
-public abstract class Valadoc.RightAlignedDocElement : ContentPositionDocElement {
-}
-
-public abstract class Valadoc.TableCellDocElement : DocElement {
- public abstract void parse (TextPosition pos, TextVerticalPosition hpos, int size, int dsize, Gee.ArrayList<DocElement> content);
-}
-
-public abstract class Valadoc.TableDocElement : DocElement {
- public abstract void parse (Gee.ArrayList<Gee.ArrayList<TableCellDocElement>> cells);
-}
-
-
-
-
-public class Valadoc.DocumentationTree : Object {
- private Gee.ArrayList<DocElement> description = new Gee.ArrayList<DocElement> ();
- private Gee.ArrayList<DocElement> brief = new Gee.ArrayList<DocElement> ();
- private Gee.HashMap<Type, Gee.ArrayList<MainTaglet> > taglets
- = new Gee.HashMap<Type, Gee.ArrayList<MainTaglet> > ();
-
- public void add_taglet (MainTaglet taglet) {
- if ( this.taglets.contains (taglet.get_type())) {
- ArrayList<MainTaglet> lst = this.taglets.get(taglet.get_type());
- lst.add(taglet);
- }
- else {
- ArrayList<MainTaglet> lst = new ArrayList<MainTaglet> ();
- this.taglets.set(taglet.get_type(), lst);
- lst.add(taglet);
- }
- }
-
- public void add_taglets (Collection<MainTaglet> taglets) {
- foreach (MainTaglet tag in taglets) {
- this.add_taglet(tag);
- }
- }
-
- public Gee.Collection<DocElement> get_brief ( ) {
- return this.brief == null ? Collection.empty<DocElement> () : this.brief.read_only_view;
- }
-
- public void add_brief (Gee.ArrayList<DocElement> content) {
- this.brief = content;
- }
-
- public Gee.Collection<DocElement> get_description () {
- return this.description == null ? Collection.empty<DocElement> () : this.description.read_only_view;
- }
-
- public void add_description (Gee.ArrayList<DocElement> content) {
- this.description = content;
- }
-
- private static Gee.ArrayList< Gee.ArrayList<MainTaglet> > sort_tag_collection (Gee.Collection< Gee.ArrayList<MainTaglet> > lst) {
- Gee.ArrayList< Gee.ArrayList<MainTaglet> > slst
- = new Gee.ArrayList< Gee.ArrayList<MainTaglet> > ();
-
- foreach (Gee.ArrayList<MainTaglet> entry in lst) {
- slst.add (entry);
- }
-
- //<bublesort>
- int count = slst.size;
- if (count <= 0)
- return slst;
-
- for (int i = 0; i < count; i++) {
- for (int j = count-1; j>i; j--) {
- if (slst.get(j).get(0).order < slst.get(j-1).get(0).order) {
- Gee.ArrayList<MainTaglet> tmp1 = slst.get(j-1);
- Gee.ArrayList<MainTaglet> tmp2 = slst.get(j);
-
- slst.remove_at (j);
- slst.insert (j, tmp1);
- slst.remove_at (j-1);
- slst.insert (j-1, tmp2);
- }
- }
- }
- //</bublesort>
- return slst;
- }
-
- public bool write_brief (void* res) {
- if (this.brief == null)
- return true;
-
- int _max = this.brief.size;
- int _index = 0;
-
- foreach (DocElement element in this.brief) {
- element.write (res, _max, _index);
- _index++;
- }
- return true;
- }
-
- public bool write_content (void* res) {
- if (this.description == null)
- return true;
-
- int max = this.description.size;
- int i = 0;
- bool tmp;
-
- foreach (DocElement tag in this.description) {
- tmp = tag.write (res, max, i);
- if (tmp == false)
- return false;
-
- i++;
- }
-
- Gee.Collection< Gee.ArrayList<MainTaglet> > lst = this.taglets.values;
- Gee.ArrayList< Gee.ArrayList<MainTaglet> > alst = sort_tag_collection ( lst );
-
- foreach (Gee.ArrayList<MainTaglet> tags in alst) {
- MainTaglet ftag = tags.get (0);
- max = tags.size;
- i = 0;
-
- tmp = ftag.write_block_start (res);
- if (tmp == false)
- return false;
-
- foreach (MainTaglet tag in tags) {
- tmp = tag.write (res, max, i);
- if ( tmp == false )
- return false;
-
- i++;
- }
-
- tmp = ftag.write_block_end (res);
- if (tmp == false)
- return false;
- }
- return true;
- }
-}
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
using GLib;
using Gee;
-
-public class Valadoc.Html.CodeConstantDocElement : Valadoc.CodeConstantDocElement {
- private string constant;
-
- public override bool parse (string constant) {
- this.constant = constant;
- return true;
- }
-
- public override bool write (void* res, int max, int index) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- file.printf ("<font class=\"%s\">%s</font>", css_content_literal, this.constant);
- return true;
- }
+public interface Valadoc.Documentation : Object {
+ public abstract string? get_filename ();
}
-
private inline void msg ( ErrorType type, string file, long line, long startpos, long endpos, string errline, string msg ) {
this.stream.printf ( "%s:%lu.%lu-%lu.%lu: %s: %s\n", file, line, startpos, line, endpos, (type == ErrorType.ERROR)? "error" : "warning", msg );
if (startpos <= endpos) {
- this.stream.printf ( "\t%s\n", errline );
- this.stream.printf ( "\t%s%s\n", string.nfill ((uint)startpos, ' '), string.nfill( (uint)(endpos-startpos), '^' ) );
+ this.stream.printf ( "%s\n", errline );
+ for (int i = 0; i < errline.length; i++) {
+ if (errline[i] == '\t') {
+ this.stream.printf ("\t");
+ } else if (i >= startpos - 1 && i < endpos - 1) {
+ this.stream.printf ("^");
+ } else {
+ this.stream.printf (" ");
+ }
+ }
+ this.stream.printf ("\n");
}
}
public class Valadoc.ModuleLoader : Object {
public Doclet doclet;
- public Gee.HashMap<string, GLib.Type> taglets;
- public GLib.Type bold;
- public GLib.Type center;
- public GLib.Type headline;
- public GLib.Type image;
- public GLib.Type italic;
- public GLib.Type link;
- public GLib.Type list;
- public GLib.Type list_element;
- public GLib.Type notification;
- public GLib.Type right;
- public GLib.Type source;
- public GLib.Type source_inline;
- public GLib.Type @string;
- public GLib.Type table;
- public GLib.Type table_cell;
- public GLib.Type underline;
- public GLib.Type paragraph;
+ public Gee.HashMap<string, GLib.Type> taglets = new Gee.HashMap<string, Type> (GLib.str_hash, GLib.str_equal);
private Module docletmodule;
private Type doclettype;
if ( tmp == false ) {
return false;
}
+ return true;
+ }
- return this.load_taglets ( path );
+ public Content.Taglet create_taglet (string keyword) {
+ return (Content.Taglet) GLib.Object.new (taglets.get (keyword));
}
private bool load_doclet ( string path ) {
this.doclet = (Doclet)GLib.Object.new (doclettype);
return true;
}
-
- private bool load_taglets (string fulldirpath) {
- try {
- taglets = new Gee.HashMap<string, Type> (GLib.str_hash, GLib.str_equal);
- Gee.ArrayList<Module*> modules = new Gee.ArrayList<weak Module*> ( );
-
- string pluginpath = build_filename(fulldirpath, "taglets");
- size_t modulesuffixlen = Module.SUFFIX.size() + 1;
-
- void* function;
-
- GLib.Dir dir = GLib.Dir.open (pluginpath);
-
- taglets.set ("toto", typeof (Type));
- taglets.unset ("toto");
-
- for (weak string entry = dir.read_name(); entry != null ; entry = dir.read_name()) {
- if (!entry.has_suffix("." + Module.SUFFIX))
- continue;
-
- string tagletpath = build_filename (pluginpath, entry);
- Module* module = Module.open (tagletpath, ModuleFlags.BIND_LAZY);
- if (module == null) {
- taglets = null;
- return false;
- }
-
- module->symbol("register_plugin", out function);
- Valadoc.TagletRegisterFunction tagletregisterfkt = (Valadoc.TagletRegisterFunction) function;
- if (function == null) {
- taglets = null;
- return false;
- }
-
- tagletregisterfkt (this);
- }
- return true;
- }
- catch (FileError err) {
- taglets = null;
- return false;
- }
- }
}
-
public class Valadoc.WikiPage : Object, Documentation {
- private Gee.ArrayList<DocElement> content;
+ public Content.Page documentation {
+ protected set;
+ get;
+ }
public string documentation_str {
private set;
}
}
- public bool parse ( Parser docparser ) {
- docparser.parse_wikipage ( this );
- return true;
- }
-
- public void add_content (Gee.ArrayList<DocElement> content) {
- this.content = content;
- }
-
- public bool write (void* res) {
- if ( this.content == null )
- return true;
-
- int max = this.content.size;
- bool tmp = false;
- int i = 0;
-
- foreach ( DocElement tag in this.content ) {
- tmp = tag.write ( res, max, i );
- if ( tmp == false )
- return false;
-
- i++;
- }
-
+ public bool parse (DocumentationParser docparser) {
+ documentation = docparser.parse_wikipage ( this );
return true;
}
}
return null;
}
- private void create_tree_from_path (Parser docparser, string path, string? nameoffset = null) throws GLib.FileError {
+ private void create_tree_from_path (DocumentationParser docparser, string path, string? nameoffset = null) throws GLib.FileError {
Dir dir = Dir.open (path);
for (string? curname = dir.read_name(); curname!=null ; curname = dir.read_name()) {
}
}
- public void create_tree ( Parser docparser ) throws GLib.FileError {
+ public void create_tree ( DocumentationParser docparser ) throws GLib.FileError {
try {
weak string path = this.settings.wiki_directory;
if (path == null) {
--- /dev/null
+/* commentscanner.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+public class Valadoc.CommentScanner : WikiScanner {
+
+ public CommentScanner (Settings settings) {
+ base (settings);
+ }
+
+ private bool in_line_start;
+ private bool past_star;
+ private int start_column;
+
+ public override void reset () {
+ base.reset ();
+
+ in_line_start = true;
+ past_star = false;
+ start_column = 0;
+ }
+
+ public override int get_line_start_column () {
+ return start_column;
+ }
+
+ protected override void accept (unichar c) throws ParserError {
+ if (in_line_start) {
+ start_column++;
+ if (c == '*') {
+ past_star = true;
+ } else if (past_star) {
+ past_star = false;
+ if (c == '\n') {
+ base.accept (c);
+ in_line_start = true;
+ start_column = 0;
+ } else if (c == ' ') {
+ in_line_start = false;
+ }
+ }
+ } else {
+ base.accept (c);
+ if (c == '\n') {
+ in_line_start = true;
+ start_column = 0;
+ }
+ }
+ }
+}
--- /dev/null
+/* documentationparser.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+using Valadoc.Content;
+
+public class Valadoc.DocumentationParser : Object, ResourceLocator {
+
+ public DocumentationParser (Settings settings, ErrorReporter reporter, Tree tree, ModuleLoader modules) {
+ _settings = settings;
+ _reporter = reporter;
+ _tree = tree;
+ _modules = modules;
+
+ _factory = new ContentFactory (_settings, this, _modules);
+
+ _wiki_scanner = new WikiScanner (_settings);
+ _wiki_parser = new Parser (_settings, _wiki_scanner, _reporter);
+ _wiki_scanner.set_parser (_wiki_parser);
+
+ _comment_scanner = new CommentScanner (_settings);
+ _comment_parser = new Parser (_settings, _comment_scanner, _reporter);
+ _comment_scanner.set_parser (_comment_parser);
+
+ init_rules ();
+ }
+
+ private Settings _settings;
+ private ErrorReporter _reporter;
+ private Tree _tree;
+ private ModuleLoader _modules;
+
+ private ContentFactory _factory;
+ private WikiScanner _wiki_scanner;
+ private CommentScanner _comment_scanner;
+ private Parser _wiki_parser;
+ private Parser _comment_parser;
+
+ private Parser _parser;
+ private WikiScanner _scanner;
+
+ public Comment? parse (DocumentedElement element) {
+ if (element.documentation != null) {
+ return element.documentation;
+ }
+
+ var comment = element.vcomment as Vala.Comment;
+ if (comment == null) {
+ return null;
+ }
+
+ weak string content = element.vcomment.content;
+ var source_ref = comment.source_reference;
+ try {
+ Comment doc_comment = parse_comment (content, source_ref.file.filename, source_ref.first_line, source_ref.first_column);
+ doc_comment.check (_tree, element, _reporter);
+ return doc_comment;
+ } catch (ParserError error) {
+ return null;
+ }
+ }
+
+ public Page? parse_wikipage (WikiPage page) {
+ if (page.documentation != null) {
+ return page.documentation;
+ }
+
+ if (page.documentation_str == null) {
+ return null;
+ }
+
+ try {
+ Page documentation = parse_wiki (page.documentation_str, page.get_filename ());
+ documentation.check (_tree, null, _reporter);
+ return documentation;
+ } catch (ParserError error) {
+ return null;
+ }
+ }
+
+ private Comment parse_comment (string content, string filename, int first_line, int first_column) throws ParserError {
+ _parser = _comment_parser;
+ _scanner = _comment_scanner;
+ _stack.clear ();
+ _comment_parser.parse (content, filename, first_line, first_column);
+ return (Comment) pop ();
+ }
+
+ private Page parse_wiki (string content, string filename) throws ParserError {
+ _parser = _wiki_parser;
+ _scanner = _wiki_scanner;
+ _stack.clear ();
+ _wiki_parser.parse (content, filename, 0, 0);
+ return (Page) pop ();
+ }
+
+ public string resolve (string path) {
+ return path;
+ }
+
+ private ArrayList<Object> _stack = new ArrayList<Object> ();
+
+ private void push (Object element) {
+ _stack.add (element);
+ }
+
+ private Object peek () {
+ assert (_stack.size > 0);
+ return _stack.get (_stack.size - 1);
+ }
+
+ private Object pop () {
+ Object node = peek ();
+ _stack.remove_at (_stack.size - 1);
+ return node;
+ }
+
+ private Rule multiline_run;
+
+ private void init_rules () {
+ // Inline rules
+
+ StubRule run = new StubRule ();
+ run.set_name ("Run");
+
+ TokenType.Action add_text = (token) => {
+ var text = peek () as Text;
+ if (text == null) {
+ push (text = _factory.create_text ());
+ }
+ text.content += token.to_string ();
+ };
+
+ TokenType word = TokenType.any_word ().action (add_text);
+ TokenType space = TokenType.SPACE.action (add_text);
+
+ Rule text =
+ Rule.seq ({
+ word,
+ Rule.option ({ space }),
+ Rule.option ({
+ Rule.many ({
+ Rule.one_of ({
+ word,
+ TokenType.STAR.action (add_text),
+ TokenType.SHARP.action (add_text),
+ TokenType.LESS_THAN.action (add_text),
+ TokenType.GREATER_THAN.action (add_text),
+ TokenType.ALIGN_RIGHT.action (add_text),
+ TokenType.ALIGN_CENTER.action (add_text)
+ }),
+ Rule.option ({ space })
+ })
+ })
+ })
+ .set_name ("Text")
+ .set_start (() => { push (_factory.create_text ()); });
+
+ Rule run_with_spaces =
+ Rule.seq ({
+ Rule.many ({
+ Rule.option ({
+ Rule.many ({ TokenType.SPACE })
+ }),
+ run
+ })
+ })
+ .set_name ("RunWithSpaces");
+
+ multiline_run = Rule.many ({
+ run_with_spaces,
+ TokenType.EOL.action (() => { ((InlineContent) peek ()).content.add (_factory.create_text (" ")); })
+ })
+ .set_name ("MultiLineRun");
+
+ Rule inline_taglet =
+ Rule.seq ({
+ TokenType.OPEN_BRACE,
+ TokenType.AROBASE,
+ TokenType.any_word ().action ((token) => {
+ var taglet = _factory.create_taglet (token.to_string ());
+ if (!(taglet is Inline)) {
+ _parser.error ("Invalid taglet in this context: %s".printf (token.to_string ()));
+ }
+ push (taglet);
+ Rule? taglet_rule = taglet.get_parser_rule (multiline_run);
+ if (taglet_rule != null) {
+ _parser.push_rule (Rule.seq ({ TokenType.SPACE, taglet_rule }));
+ }
+ }),
+ TokenType.CLOSED_BRACE
+ })
+ .set_name ("InlineTaglet");
+
+ Rule bold =
+ Rule.seq ({ TokenType.SINGLE_QUOTE_2, run, TokenType.SINGLE_QUOTE_2 })
+ .set_name ("Bold")
+ .set_start (() => { push (_factory.create_highlighted (Highlighted.Style.BOLD)); });
+ Rule italic =
+ Rule.seq ({ TokenType.SLASH_2, run, TokenType.SLASH_2 })
+ .set_name ("Italic")
+ .set_start (() => { push (_factory.create_highlighted (Highlighted.Style.ITALIC)); });
+ Rule underlined =
+ Rule.seq ({ TokenType.UNDERSCORE_2, run, TokenType.UNDERSCORE_2 })
+ .set_name ("Underlined")
+ .set_start (() => { push (_factory.create_highlighted (Highlighted.Style.UNDERLINED)); });
+ Rule monospace =
+ Rule.seq ({ TokenType.BACK_QUOTE, run, TokenType.BACK_QUOTE })
+ .set_name ("Monospace")
+ .set_start (() => { push (_factory.create_highlighted (Highlighted.Style.MONOSPACED)); });
+
+ Rule embedded =
+ Rule.seq ({
+ TokenType.DOUBLE_OPEN_BRACE.action (() => { _scanner.set_url_escape_mode (true); }),
+ TokenType.any_word (),
+ Rule.option ({
+ TokenType.PIPE.action (() => { _scanner.set_url_escape_mode (false); }),
+ run
+ }),
+ TokenType.DOUBLE_CLOSED_BRACE.action (() => { _scanner.set_url_escape_mode (false); })
+ })
+ .set_name ("Embedded")
+ .set_start (() => { push (_factory.create_embedded ()); });
+ Rule link =
+ Rule.seq ({
+ TokenType.DOUBLE_OPEN_BRACKET.action (() => { _scanner.set_url_escape_mode (true); }),
+ TokenType.any_word (),
+ Rule.option ({
+ TokenType.PIPE.action (() => { _scanner.set_url_escape_mode (false); }),
+ run
+ }),
+ TokenType.DOUBLE_CLOSED_BRACKET.action (() => { _scanner.set_url_escape_mode (false); })
+ })
+ .set_name ("Link")
+ .set_start (() => { push (_factory.create_link ()); });
+
+ run.set_rule (
+ Rule.many ({
+ Rule.one_of ({
+ text, inline_taglet, bold, italic, underlined, monospace, embedded, link
+ })
+ .set_reduce (() => { ((InlineContent) peek ()).content.add ((Inline) pop ()); }),
+ Rule.option ({ space })
+ .set_reduce (() => { ((InlineContent) peek ()).content.add ((Inline) pop ()); })
+ })
+ .set_name ("Run")
+ );
+
+ // Block rules
+
+ Rule paragraph =
+ Rule.seq ({
+ Rule.option ({
+ Rule.one_of ({
+ TokenType.ALIGN_CENTER.action (() => { ((Paragraph) peek ()).horizontal_align = HorizontalAlign.RIGHT; }),
+ TokenType.ALIGN_RIGHT.action (() => { ((Paragraph) peek ()).horizontal_align = HorizontalAlign.RIGHT; })
+ })
+ }),
+ Rule.many ({
+ run,
+ TokenType.EOL.action (() => { ((Paragraph) peek ()).content.add (_factory.create_text (" ")); })
+ })
+ })
+ .set_name ("Paragraph")
+ .set_start (() => { push (_factory.create_paragraph ()); })
+ .set_reduce (() => { ((BlockContent) peek ()).content.add ((Block) pop ()); });
+
+ Rule source_code =
+ Rule.seq ({
+ TokenType.TRIPLE_OPEN_BRACE.action ((token) => { _scanner.set_code_escape_mode (true); }),
+ TokenType.any_word ().action ((token) => { ((SourceCode) peek ()).code = token.to_string (); }),
+ TokenType.TRIPLE_CLOSED_BRACE.action ((token) => { _scanner.set_code_escape_mode (false); }),
+ TokenType.EOL
+ })
+ .set_name ("SourceCode")
+ .set_start (() => { push (_factory.create_source_code ()); })
+ .set_reduce (() => { ((BlockContent) peek ()).content.add ((Block) pop ()); });
+
+ Rule list_item =
+ Rule.seq ({
+ Rule.many ({
+ TokenType.SPACE.action ((token) => { ((ListItem) peek ()).level++; })
+ }),
+ Rule.one_of ({
+ TokenType.STAR.action ((token) => { ((ListItem) peek ()).bullet = ListItem.Bullet.UNORDERED; }),
+ TokenType.SHARP.action ((token) => { ((ListItem) peek ()).bullet = ListItem.Bullet.ORDERED; }),
+ TokenType.str (".").action ((token) => { ((ListItem) peek ()).bullet = ListItem.Bullet.NONE; }),
+ TokenType.str ("I.").action ((token) => { ((ListItem) peek ()).bullet = ListItem.Bullet.ORDERED_LATIN; }),
+ TokenType.str ("A.").action ((token) => { ((ListItem) peek ()).bullet = ListItem.Bullet.ORDERED_CAPITAL; }),
+ TokenType.str ("1.").action ((token) => { ((ListItem) peek ()).bullet = ListItem.Bullet.ORDERED_NUMBER; }),
+ TokenType.str ("a.").action ((token) => { ((ListItem) peek ()).bullet = ListItem.Bullet.ORDERED_LOWER_CASE; })
+ }),
+ run,
+ TokenType.EOL
+ })
+ .set_name ("ListItem")
+ .set_start (() => { push (_factory.create_list_item ()); })
+ .set_reduce (() => { ((Content.List) peek ()).items.add ((ListItem) pop ()); });
+ Rule list =
+ Rule.seq ({
+ Rule.many ({
+ list_item
+ }),
+ TokenType.EOL
+ })
+ .set_name ("List")
+ .set_start (() => { push (_factory.create_list ()); })
+ .set_reduce (() => { ((BlockContent) peek ()).content.add ((Block) pop ()); });
+
+ Rule table_cell_attributes =
+ Rule.seq ({
+ TokenType.LESS_THAN,
+ Rule.option ({
+ Rule.one_of ({
+ Rule.seq ({
+ Rule.option ({
+ Rule.one_of ({
+ TokenType.ALIGN_RIGHT.action ((token) => { ((TableCell) peek ()).horizontal_align = HorizontalAlign.RIGHT; }),
+ TokenType.ALIGN_CENTER.action ((token) => { ((TableCell) peek ()).horizontal_align = HorizontalAlign.CENTER; })
+ })
+ }),
+ Rule.option ({
+ Rule.one_of ({
+ TokenType.ALIGN_TOP.action ((token) => { ((TableCell) peek ()).vertical_align = VerticalAlign.TOP; }),
+ TokenType.ALIGN_BOTTOM.action ((token) => { ((TableCell) peek ()).vertical_align = VerticalAlign.BOTTOM; })
+ })
+ })
+ }),
+ TokenType.any_word ().action ((token) => { ((TableCell) peek ()).style = token.to_string (); })
+ })
+ }),
+ Rule.option ({
+ Rule.one_of ({
+ Rule.seq ({
+ TokenType.PIPE,
+ TokenType.any_number ().action ((token) => { ((TableCell) peek ()).colspan = token.to_int (); })
+ }),
+ Rule.seq ({
+ TokenType.MINUS,
+ TokenType.any_number ().action ((token) => { ((TableCell) peek ()).rowspan = token.to_int (); })
+ })
+ })
+ }),
+ TokenType.GREATER_THAN
+ })
+ .set_name ("CellAttributes");
+ Rule table_cell =
+ Rule.seq ({
+ Rule.seq ({
+ Rule.option ({
+ table_cell_attributes
+ }),
+ run_with_spaces,
+ Rule.option ({
+ Rule.many ({ TokenType.SPACE })
+ })
+ }),
+ TokenType.DOUBLE_PIPE
+ })
+ .set_name ("Cell")
+ .set_start (() => { push (_factory.create_table_cell ()); })
+ .set_reduce (() => { ((ArrayList<TableCell>) peek ()).add ((TableCell) pop ()); });
+ Rule table_row =
+ Rule.seq ({
+ TokenType.DOUBLE_PIPE,
+ Rule.many ({
+ table_cell
+ }),
+ TokenType.EOL
+ })
+ .set_name ("Row")
+ .set_start (() => { push (new ArrayList<TableCell> ()); })
+ .set_reduce (() => { ((Table) peek ()).cells.add ((ArrayList<TableCell>) pop ()); });
+ Rule table =
+ Rule.seq ({
+ Rule.many ({
+ table_row
+ })
+ })
+ .set_name ("Table")
+ .set_start (() => { push (_factory.create_table ()); })
+ .set_reduce (() => { ((BlockContent) peek ()).content.add ((Block) pop ()); });
+
+ Rule headline =
+ Rule.one_of ({
+ Rule.seq ({
+ TokenType.EQUAL_1.action ((token) => { ((Headline) peek ()).level = 1; }),
+ run,
+ TokenType.EQUAL_1,
+ TokenType.EOL
+ }),
+ Rule.seq ({
+ TokenType.EQUAL_2.action ((token) => { ((Headline) peek ()).level = 2; }),
+ run,
+ TokenType.EQUAL_2,
+ TokenType.EOL
+ }),
+ Rule.seq ({
+ TokenType.EQUAL_3.action ((token) => { ((Headline) peek ()).level = 3; }),
+ run,
+ TokenType.EQUAL_3,
+ TokenType.EOL
+ }),
+ Rule.seq ({
+ TokenType.EQUAL_4.action ((token) => { ((Headline) peek ()).level = 4; }),
+ run,
+ TokenType.EQUAL_4,
+ TokenType.EOL
+ }),
+ Rule.seq ({
+ TokenType.EQUAL_5.action ((token) => { ((Headline) peek ()).level = 5; }),
+ run,
+ TokenType.EQUAL_5,
+ TokenType.EOL
+ })
+ })
+ .set_name ("Headline")
+ .set_start (() => { push (_factory.create_headline ()); })
+ .set_reduce (() => { ((BlockContent) peek ()).content.add ((Block) pop ()); });
+
+ Rule blocks =
+ Rule.one_of ({
+ source_code,
+ list,
+ table,
+ headline,
+ paragraph
+ })
+ .set_name ("Blocks");
+
+ Rule page =
+ Rule.seq ({
+ blocks,
+ Rule.option ({
+ Rule.many ({
+ TokenType.EOL,
+ Rule.option ({ blocks })
+ })
+ })
+ })
+ .set_name ("Page")
+ .set_start (() => { push (_factory.create_page ()); });
+
+ Rule description =
+ Rule.seq ({
+ blocks,
+ Rule.option ({
+ Rule.many ({
+ TokenType.EOL,
+ Rule.option ({ blocks })
+ })
+ })
+ })
+ .set_name ("Description");
+
+ Rule taglet =
+ Rule.seq ({
+ TokenType.AROBASE,
+ TokenType.any_word ().action ((token) => {
+ var taglet = _factory.create_taglet (token.to_string ());
+ if (!(taglet is Block)) {
+ _parser.error ("Invalid taglet in this context", token);
+ }
+ push (taglet);
+ Rule? taglet_rule = taglet.get_parser_rule (multiline_run);
+ if (taglet_rule != null) {
+ _parser.push_rule (Rule.seq ({ TokenType.SPACE, taglet_rule }));
+ }
+ }),
+ Rule.option ({
+ Rule.many ({ TokenType.EOL })
+ })
+ })
+ .set_name ("Taglet")
+ .set_reduce (() => { ((Comment) peek ()).taglets.add ((Taglet) pop ()); });
+
+ Rule comment =
+ Rule.seq ({
+ TokenType.EOL,
+ description,
+ Rule.option ({
+ Rule.many ({ taglet })
+ })
+ })
+ .set_name ("Comment")
+ .set_start (() => { push (_factory.create_comment ()); });
+
+ _comment_parser.set_root_rule (comment);
+ _wiki_parser.set_root_rule (page);
+ }
+
+ private void dump_stack () {
+ message ("Dumping stack");
+ foreach (Object object in _stack) {
+ message ("%s", object.get_type ().name ());
+ }
+ }
+}
--- /dev/null
+/* parser.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+
+internal class Valadoc.ManyRule : Rule {
+
+ public ManyRule (Object scheme) {
+ _scheme = scheme;
+ }
+
+ private Object _scheme;
+
+ private class State : Object {
+ public bool started = false;
+ public bool done_one = false;
+ }
+
+ public override bool is_optional () {
+ return is_optional_rule (_scheme);
+ }
+
+ public override bool starts_with_token (Token token) {
+ if (has_start_token (_scheme, token)) {
+ return true;
+ }
+ return false;
+ }
+
+ public override bool accept_token (Token token, ParserCallback parser, Rule.Forward forward) throws ParserError {
+ var state = parser.get_rule_state () as State;
+ if (state == null) {
+ state = new State ();
+ parser.set_rule_state (state);
+ }
+
+ if (!state.started) {
+ do_start (parser);
+ state.started = true;
+ }
+
+ if (state.done_one && parser.would_parent_accept_token (token)) {
+ do_reduce (parser);
+ return false;
+ }
+ if (parser.would_parent_reduce_to_rule (token, this)) {
+ do_reduce (parser);
+ return false;
+ }
+
+ bool handled;
+ if (try_to_apply (_scheme, token, parser, out handled)) {
+ state.done_one = true;
+ return handled;
+ }
+ if (parser.would_parent_accept_token (token)) {
+ do_reduce (parser);
+ return false;
+ }
+
+ if (_scheme is TokenType) {
+ parser.error ("expected %s".printf (((TokenType) _scheme).to_pretty_string ()), token);
+ } else {
+ parser.error ("unexpected token", token);
+ }
+ assert_not_reached ();
+ }
+
+ public override bool would_accept_token (Token token, Object? state) {
+ if (has_start_token (_scheme, token)) {
+ return true;
+ }
+ return false;
+ }
+
+ public override bool would_reduce (Token token, Object? rule_state) {
+ var state = rule_state as State;
+ return state.done_one || is_optional_rule (_scheme);
+ }
+
+ public override string to_string (Object? rule_state) {
+ var state = rule_state as State;
+ if (state == null) {
+ state = new State ();
+ }
+ return "%-15s%-15s(started=%s;done_one=%s)".printf (name != null ? name : " ", "[many]", state.started.to_string (), state.done_one.to_string ());
+ }
+}
--- /dev/null
+/* parser.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+
+internal class Valadoc.OneOfRule : Rule {
+
+ public OneOfRule (Object[] scheme) {
+ _scheme = scheme;
+ }
+
+ private Object[] _scheme;
+
+ private class State : Object {
+ public int selected = -1;
+ }
+
+ public override bool is_optional () {
+ return false;
+ }
+
+ public override bool starts_with_token (Token token) {
+ foreach (Object? scheme_element in _scheme) {
+ if (has_start_token (scheme_element, token)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public override bool accept_token (Token token, ParserCallback parser, Rule.Forward forward) throws ParserError {
+ var state = parser.get_rule_state () as State;
+ if (state == null) {
+ state = new State ();
+ parser.set_rule_state (state);
+ }
+
+ if (state.selected == -1) {
+ do_start (parser);
+
+ bool handled;
+ for (int i = 0; i < _scheme.length; i++) {
+ Object? scheme_element = _scheme[i];
+ if (try_to_apply (scheme_element, token, parser, out handled)) {
+ state.selected = i;
+ return handled;
+ }
+ }
+ } else {
+ do_reduce (parser);
+ return false;
+ }
+
+ parser.error ("unexpected token", token);
+ assert_not_reached ();
+ }
+
+ public override bool would_accept_token (Token token, Object? state) {
+ return false;
+ }
+
+ public override bool would_reduce (Token token, Object? rule_state) {
+ var state = rule_state as State;
+ return state.selected != -1;
+ }
+
+ public override string to_string (Object? rule_state) {
+ var state = rule_state as State;
+ if (state == null) {
+ state = new State ();
+ }
+ return "%-15s%-15s(selected=%d/%d)".printf (name != null ? name : " ", "[one-of]", state.selected, _scheme.length);
+ }
+}
--- /dev/null
+/* parser.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+
+internal class Valadoc.OptionalRule : Rule {
+
+ public OptionalRule (Object scheme) {
+ _scheme = scheme;
+ }
+
+ private Object _scheme;
+
+ private class State : Object {
+ public bool started = false;
+ }
+
+ public override bool is_optional () {
+ return true;
+ }
+
+ public override bool starts_with_token (Token token) {
+ return has_start_token (_scheme, token);
+ }
+
+ public override bool accept_token (Token token, ParserCallback parser, Rule.Forward forward) throws ParserError {
+ var state = parser.get_rule_state () as State;
+ if (state == null) {
+ state = new State ();
+ parser.set_rule_state (state);
+ }
+
+ if (!state.started) {
+ do_start (parser);
+ state.started = true;
+
+ bool handled;
+ if (try_to_apply (_scheme, token, parser, out handled)) {
+ return handled;
+ } else {
+ do_reduce (parser);
+ return false;
+ }
+ } else {
+ do_reduce (parser);
+ return false;
+ }
+ }
+
+ public override bool would_accept_token (Token token, Object? state) {
+ return false;
+ }
+
+ public override bool would_reduce (Token token, Object? state) {
+ return true;
+ }
+
+ public override string to_string (Object? rule_state) {
+ var state = rule_state as State;
+ if (state == null) {
+ state = new State ();
+ }
+ return "%-15s%-15s(started=%s)".printf (name != null ? name : " ", "[option]", state.started.to_string ());
+ }
+}
--- /dev/null
+/* parser.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+
+public errordomain Valadoc.ParserError {
+ INTERNAL_ERROR,
+ UNEXPECTED_TOKEN
+}
+
+public class Valadoc.Parser : ParserCallback {
+
+ public Parser (Settings settings, Scanner scanner, ErrorReporter reporter) {
+ _settings = settings;
+ _scanner = scanner;
+ _reporter = reporter;
+
+ TokenType.init_token_types ();
+ }
+
+ private Settings _settings;
+ private Scanner _scanner;
+ private ErrorReporter _reporter;
+ private Rule _root_rule;
+
+ private string _filename;
+ private int _first_line;
+ private int _first_column;
+ private Token _current_token;
+
+ private ArrayList<Rule> rule_stack = new ArrayList<Rule> ();
+ private ArrayList<Object?> rule_state_stack = new ArrayList<Object?> ();
+
+ public void set_root_rule (Rule root_rule) {
+ _root_rule = root_rule;
+ }
+
+ public void parse (string content, string filename, int first_line, int first_column) throws ParserError {
+ _filename = filename;
+ _first_line = first_line;
+ _first_column = first_column;
+
+ rule_stack.clear ();
+ rule_state_stack.clear ();
+
+ try {
+ push_rule (_root_rule);
+ _scanner.reset ();
+ _scanner.scan (content);
+ _scanner.end ();
+
+ if (rule_stack.size != 0) {
+ error ("Rule stack is not empty!");
+ }
+ } catch (ParserError e) {
+ #if DEBUG
+ log_error (e.message);
+ #endif
+ // Set an in_error boolean, try to recover
+ // And only throw the error at the end of parse ?
+ throw e;
+ }
+ }
+
+ public void accept_token (Token token) throws ParserError {
+ #if HARD_DEBUG
+ debug ("Incomming token: %s", token.to_pretty_string ());
+ #endif
+
+ _current_token = token;
+ int rule_depth = rule_stack.size;
+ Rule.Forward forward = Rule.Forward.NONE;
+ Rule? rule = peek_rule ();
+ if (rule == null) {
+ throw new ParserError.INTERNAL_ERROR ("Rule stack is empty!");
+ }
+ while (rule != null) {
+ if (rule.accept_token (token, this, forward)) {
+ break;
+ }
+
+ // Check for invalid recursion
+ if (rule_depth != rule_stack.size && peek_rule () == rule) {
+ error ("Parser state error");
+ break;
+ }
+ rule = peek_rule ();
+
+ // Rule stack size have changed
+ // Check for propagation
+ forward = rule_depth > rule_stack.size ? Rule.Forward.CHILD
+ : Rule.Forward.PARENT;
+ rule_depth = rule_stack.size;
+ }
+ }
+
+ private Rule? peek_rule (int offset = -1) {
+ assert (offset < 0);
+ if (rule_stack.size + offset < 0) {
+ return null;
+ }
+ return rule_stack.get (rule_stack.size + offset);
+ }
+
+ private Rule pop_rule () {
+ int last_index = rule_stack.size - 1;
+ Rule rule = rule_stack.get (last_index);
+ rule_stack.remove_at (last_index);
+ rule_state_stack.remove_at (last_index);
+ return rule;
+ }
+
+ public void push_rule (Rule rule) {
+ rule_stack.add (rule);
+ rule_state_stack.add (null);
+
+ #if HARD_DEBUG
+ debug ("Pushed at %2d: %s", rule_stack.size - 1, rule.to_string (null));
+ #endif
+ }
+
+ private Object? peek_state (int offset = -1) {
+ assert (offset < 0);
+ if (rule_state_stack.size + offset < 0) {
+ return null;
+ }
+ return rule_state_stack.get (rule_state_stack.size + offset);
+ }
+
+ public Object? get_rule_state () {
+ return peek_state ();
+ }
+
+ public void set_rule_state (Object state) {
+ int last_index = rule_stack.size - 1;
+ rule_state_stack.set (last_index, state);
+ }
+
+ public void reduce () {
+ pop_rule ();
+
+ #if HARD_DEBUG
+ Rule? parent_rule = peek_rule ();
+ if (parent_rule != null) {
+ debug ("Reduced to %2d: %s", rule_stack.size - 1, parent_rule.to_string (peek_state ()));
+ }
+ #endif
+ }
+
+ public bool would_parent_accept_token (Token token) {
+ int offset = -2;
+ Rule? parent_rule = peek_rule (offset);
+ Object? state = peek_state (offset);
+ while (parent_rule != null) {
+ #if VERY_HARD_DEBUG
+ debug ("WouldAccept - Offset %d; Index %d: %s", offset, rule_stack.size + offset, parent_rule.to_string (state));
+ #endif
+ if (parent_rule.would_accept_token (token, state)) {
+ #if VERY_HARD_DEBUG
+ debug ("WouldAccept - Yes");
+ #endif
+ return true;
+ }
+ if (!parent_rule.would_reduce (token, state)) {
+ #if VERY_HARD_DEBUG
+ debug ("WouldAccept - No");
+ #endif
+ return false;
+ }
+ offset--;
+ parent_rule = peek_rule (offset);
+ state = peek_state (offset);
+ }
+ #if VERY_HARD_DEBUG
+ debug ("WouldAccept - No");
+ #endif
+ return false;
+ }
+
+ public bool would_parent_reduce_to_rule (Token token, Rule rule) {
+ int offset = -2;
+ Rule? parent_rule = peek_rule (offset);
+ Object? state = peek_state (offset);
+ while (parent_rule != null) {
+ #if VERY_HARD_DEBUG
+ debug ("WouldReduce - Offset %d; Index %d: %s", offset, rule_stack.size + offset, parent_rule.to_string (state));
+ #endif
+ if (!parent_rule.would_reduce (token, state)) {
+ break;
+ }
+ offset--;
+ parent_rule = peek_rule (offset);
+ state = peek_state (offset);
+ }
+ if ((parent_rule != null && parent_rule.would_accept_token (token, state))
+ || (parent_rule == null && TokenType.EOF.matches (token))) {
+ #if VERY_HARD_DEBUG
+ debug ("WouldReduce - Yes");
+ #endif
+ return true;
+ }
+ #if VERY_HARD_DEBUG
+ debug ("WouldReduce - No");
+ #endif
+ return false;
+ }
+
+ public void warning (string message, Token? token = null) {
+ string error_message = message + (token != null ? ": " + token.to_pretty_string () : "");
+ _reporter.warning (_filename,
+ get_line (token),
+ get_start_column (token),
+ get_end_column (token),
+ _scanner.get_line_content (),
+ error_message);
+ }
+
+ public void error (string message, Token? token = null) throws ParserError {
+ string error_message = message + (token != null ? ": " + token.to_pretty_string () : "");
+ _reporter.error (_filename, get_line (token),
+ get_start_column (token),
+ get_end_column (token),
+ _scanner.get_line_content (),
+ error_message);
+ throw new ParserError.UNEXPECTED_TOKEN (error_message);
+ }
+
+ private int get_line (Token? token) {
+ if (token == null) {
+ token = _current_token;
+ }
+ return token.begin.line + _first_line;
+ }
+
+ private int get_start_column (Token? token) {
+ if (token == null) {
+ token = _current_token;
+ }
+ if (token.begin.line == 0) {
+ return token.begin.column + _first_column + 1;
+ } else {
+ return token.begin.column + 1;
+ }
+ }
+
+ private int get_end_column (Token? token) {
+ if (token == null) {
+ token = _current_token;
+ }
+ if (token.end.line == 0) {
+ return token.end.column + _first_column + 1;
+ } else {
+ return token.end.column + 1;
+ }
+ }
+
+#if DEBUG
+ private void log_error (string message) {
+ stderr.printf ("An error occured while parsing: %s\n", message);
+ stderr.printf ("\nDumping rule stack:\n");
+ for (int i = 0; i < rule_stack.size; i++) {
+ stderr.printf ("\t%2d: %s\n", i, rule_stack[i].to_string (rule_state_stack[i]));
+ }
+ }
+#endif
+}
-/*
+/* parser.vala
+ *
* Valadoc - a documentation tool for vala.
- * Copyright (C) 2008 Florian Brosch
- *
+ * 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 'Ptitjes Villevalois <ptitjes@free.fr>
*/
-
-using GLib;
using Gee;
+public interface Valadoc.ParserCallback {
+ public abstract Object? get_rule_state ();
+ public abstract void set_rule_state (Object state);
-public class Valadoc.Html.CenterDocElement : Valadoc.CenterDocElement {
- private Gee.ArrayList<DocElement> content;
-
- public override bool parse ( Gee.ArrayList<DocElement> content ) {
- this.content = content;
- return true;
- }
-
- public override bool write ( void* res, int max, int index ) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- int _max = this.content.size;
- int _index = 0;
+ public abstract void push_rule (Rule rule);
+ public abstract void reduce ();
- file.printf ( "<div align=\"center\">" );
+ public abstract bool would_parent_accept_token (Token token);
+ public abstract bool would_parent_reduce_to_rule (Token token, Rule rule);
- foreach ( DocElement element in this.content ) {
- element.write ( res, _max, _index );
- _index++;
- }
-
- file.printf ( "</div>" );
- return true;
- }
+ public abstract void warning (string message, Token? token = null);
+ public abstract void error (string message, Token? token = null) throws ParserError;
}
-
-
--- /dev/null
+/* parser.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+
+public abstract class Valadoc.Rule : Object {
+
+ public static Rule seq (Object?[] scheme) {
+ return new SequenceRule (scheme);
+ }
+
+ public static Rule one_of (Object?[] scheme) {
+ return new OneOfRule (scheme);
+ }
+
+ public static Rule many (Object?[] scheme) {
+ if (scheme.length == 1) {
+ return new ManyRule (scheme[0]);
+ } else {
+ return new ManyRule (new SequenceRule (scheme));
+ }
+ }
+
+ public static Rule option (Object?[] scheme) {
+ if (scheme.length == 1) {
+ return new OptionalRule (scheme[0]);
+ } else {
+ return new OptionalRule (new SequenceRule (scheme));
+ }
+ }
+
+ protected Rule () {
+ }
+
+ private string? _name = null;
+ private Action _start_action;
+ private Action _reduce_action;
+
+ public string name { get { return _name; } }
+
+ public Rule set_name (string name) {
+ _name = name;
+ return this;
+ }
+
+ public delegate void Action () throws ParserError;
+
+ public Rule set_start (Action action) {
+ _start_action = action;
+ return this;
+ }
+
+ public Rule set_reduce (Action action) {
+ _reduce_action = action;
+ return this;
+ }
+
+ public enum Forward {
+ NONE, PARENT, CHILD
+ }
+
+ public abstract bool is_optional ();
+ public abstract bool starts_with_token (Token token);
+ public abstract bool accept_token (Token token, ParserCallback parser, Rule.Forward forward) throws ParserError;
+ public abstract bool would_accept_token (Token token, Object? state);
+ public abstract bool would_reduce (Token token, Object? state);
+
+ public abstract string to_string (Object? state);
+
+ protected bool is_optional_rule (Object? scheme_element) {
+ Rule? scheme_rule = scheme_element as Rule;
+ if (scheme_rule != null) {
+ return scheme_rule.is_optional ();
+ }
+ return false;
+ }
+
+ protected bool has_start_token (Object? scheme_element, Token token) {
+ TokenType? scheme_token_type = scheme_element as TokenType;
+ if (scheme_token_type != null) {
+ return scheme_token_type.matches (token);
+ }
+ Rule? scheme_rule = scheme_element as Rule;
+ if (scheme_rule != null) {
+ return scheme_rule.starts_with_token (token);
+ }
+ return false;
+ }
+
+ protected bool try_to_apply (Object? scheme_element, Token token, ParserCallback parser, out bool handled) throws ParserError {
+ #if VERY_HARD_DEBUG
+ {
+ TokenType? scheme_token = scheme_element as TokenType;
+ Rule? scheme_rule = scheme_element as Rule;
+ if (scheme_token != null) {
+ message ("TryToApply: token='%s'; scheme_token='%s'", token.to_string (), scheme_token.to_string ());
+ } else if (scheme_rule != null) {
+ message ("TryToApply: token='%s'; scheme_rule='%s'", token.to_string (), scheme_rule.to_string (parser.get_rule_state ()));
+ } else {
+ assert (scheme_element != null);
+ }
+ }
+ #endif
+ TokenType? scheme_token_type = scheme_element as TokenType;
+ if (scheme_token_type != null && scheme_token_type.matches (token)) {
+ scheme_token_type.do_action (token);
+ handled = true;
+ return true;
+ }
+ Rule? scheme_rule = scheme_element as Rule;
+ if (scheme_rule != null && scheme_rule.starts_with_token (token)) {
+ parser.push_rule (scheme_rule);
+ handled = false;
+ return true;
+ }
+ return false;
+ }
+
+ protected void do_start (ParserCallback parser) throws ParserError {
+ if (_start_action != null) {
+ _start_action ();
+ }
+ }
+
+ protected void do_reduce (ParserCallback parser) throws ParserError {
+ if (_reduce_action != null) {
+ _reduce_action ();
+ }
+ parser.reduce ();
+ }
+}
--- /dev/null
+/* commentscanner.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+public interface Valadoc.Scanner : Object {
+
+ public abstract void set_parser (Parser parser);
+
+ public abstract void reset ();
+
+ public abstract void scan (string content) throws ParserError;
+
+ public abstract void end () throws ParserError;
+
+ public abstract void stop ();
+
+ public abstract string get_line_content ();
+}
--- /dev/null
+/* parser.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+
+internal class Valadoc.SequenceRule : Rule {
+
+ public SequenceRule (Object[] scheme) {
+ _scheme = scheme;
+ }
+
+ private Object[] _scheme;
+
+ private class State : Object {
+ public int index = 0;
+ }
+
+ public override bool is_optional () {
+ return false;
+ }
+
+ public override bool starts_with_token (Token token) {
+ return test_token (0, token);
+ }
+
+ private bool test_token (int from_index, Token token) {
+ int i = from_index;
+ while (i < _scheme.length) {
+ if (has_start_token (_scheme[i], token)) {
+ return true;
+ }
+ if (!is_optional_rule (_scheme[i])) {
+ break;
+ }
+ i++;
+ }
+ return false;
+ }
+
+ private bool test_reduce (int from_index, Token token) {
+ int i = from_index;
+ while (i < _scheme.length) {
+ if (!is_optional_rule (_scheme[i])) {
+ return false;
+ }
+ i++;
+ }
+ return true;
+ }
+
+ public override bool accept_token (Token token, ParserCallback parser, Rule.Forward forward) throws ParserError {
+ var state = parser.get_rule_state () as State;
+ if (state == null) {
+ state = new State ();
+ parser.set_rule_state (state);
+ }
+
+ if (state.index == 0) {
+ do_start (parser);
+ } else if (state.index == _scheme.length) {
+ do_reduce (parser);
+ return false;
+ }
+
+ Object? scheme_element = null;
+ bool handled;
+ do {
+ scheme_element = _scheme[state.index];
+ if (try_to_apply (scheme_element, token, parser, out handled)) {
+ state.index++;
+ return handled;
+ }
+ if (!is_optional_rule (scheme_element)) {
+ break;
+ }
+ state.index++;
+ } while (state.index < _scheme.length);
+
+ if (state.index == _scheme.length) {
+ do_reduce (parser);
+ return false;
+ }
+
+ if (scheme_element is TokenType) {
+ parser.error ("expected %s".printf (((TokenType) scheme_element).to_pretty_string ()), token);
+ } else {
+ parser.error ("unexpected token", token);
+ }
+ assert_not_reached ();
+ }
+
+ public override bool would_accept_token (Token token, Object? rule_state) {
+ var state = rule_state as State;
+ return test_token (state.index, token);
+ }
+
+ public override bool would_reduce (Token token, Object? rule_state) {
+ var state = rule_state as State;
+ return state.index == _scheme.length || test_reduce (state.index, token);
+ }
+
+ public override string to_string (Object? rule_state) {
+ var state = rule_state as State;
+ if (state == null) {
+ state = new State ();
+ }
+ return "%-15s%-15s(index=%d/%d)".printf (name != null ? name : " ", "[seq]", state.index, _scheme.length);
+ }
+}
--- /dev/null
+/* sourcelocation.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.SourceLocation {
+ public int line;
+ public int column;
+
+ public SourceLocation (int _line, int _column) {
+ line = _line;
+ column = _column;
+ }
+}
--- /dev/null
+/* parser.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+
+public class Valadoc.StubRule : Rule {
+
+ public StubRule () {
+ }
+
+ private Rule _rule;
+
+ public Rule set_rule (Rule rule) {
+ _rule = rule;
+ return this;
+ }
+
+ public override bool is_optional () {
+ return _rule.is_optional ();
+ }
+
+ public override bool starts_with_token (Token token) {
+ return _rule.starts_with_token (token);
+ }
+
+ public override bool accept_token (Token token, ParserCallback parser, Rule.Forward forward) throws ParserError {
+ return _rule.accept_token (token, parser, forward);
+ }
+
+ public override bool would_accept_token (Token token, Object? state) {
+ return _rule.would_accept_token (token, state);
+ }
+
+ public override bool would_reduce (Token token, Object? state) {
+ return _rule.would_reduce (token, state);
+ }
+
+ public override string to_string (Object? state) {
+ return _rule.to_string (state);
+ }
+}
--- /dev/null
+/* parser.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+
+public class Valadoc.Token : Object {
+
+ public Token.from_type (TokenType type, SourceLocation begin, SourceLocation end) {
+ _type = type;
+ _begin = begin;
+ _end = end;
+ }
+
+ public Token.from_word (string word, SourceLocation begin, SourceLocation end) {
+ _word = word;
+ _begin = begin;
+ _end = end;
+ }
+
+ private TokenType? _type = null;
+ private string? _word = null;
+ private SourceLocation _begin;
+ private SourceLocation _end;
+
+ public bool is_word {
+ get {
+ return _word != null;
+ }
+ }
+
+ public bool is_number {
+ get {
+ if (_word == null || _word.length == 0) {
+ return false;
+ } else if (_word[0] == '0' && _word.length > 1) {
+ return false;
+ }
+ for (int i = 0; i < _word.length; i++) {
+ if (_word[i] < '0' || _word[i] > '9') {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ public string? word {
+ get {
+ return _word;
+ }
+ }
+
+ public TokenType? token_type {
+ get {
+ return _type;
+ }
+ }
+
+ public SourceLocation begin {
+ get {
+ return _begin;
+ }
+ }
+
+ public SourceLocation end {
+ get {
+ return _end;
+ }
+ }
+
+ public string to_string () {
+ return _word == null ? _type.to_string () : _word;
+ }
+
+ public string to_pretty_string () {
+ return _word == null ? _type.to_pretty_string () : _word;
+ }
+
+ public int to_int () {
+ assert (is_number);
+ return _word.to_int ();
+ }
+}
--- /dev/null
+/* parser.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+
+public class Valadoc.TokenType : Object {
+
+ public static TokenType ANY;
+ public static TokenType ANY_WORD;
+ public static TokenType ANY_NUMBER;
+ public static TokenType EOF;
+ public static TokenType EOL;
+ public static TokenType AROBASE;
+ public static TokenType SPACE;
+ public static TokenType TAB;
+ public static TokenType EQUAL_1;
+ public static TokenType EQUAL_2;
+ public static TokenType EQUAL_3;
+ public static TokenType EQUAL_4;
+ public static TokenType EQUAL_5;
+ public static TokenType MINUS;
+ public static TokenType STAR;
+ public static TokenType SHARP;
+ public static TokenType LESS_THAN;
+ public static TokenType GREATER_THAN;
+ public static TokenType ALIGN_TOP;
+ public static TokenType ALIGN_BOTTOM;
+ public static TokenType SINGLE_QUOTE_2;
+ public static TokenType SLASH_2;
+ public static TokenType UNDERSCORE_2;
+ public static TokenType BACK_QUOTE;
+ public static TokenType OPEN_BRACE;
+ public static TokenType CLOSED_BRACE;
+ public static TokenType DOUBLE_OPEN_BRACE;
+ public static TokenType DOUBLE_CLOSED_BRACE;
+ public static TokenType TRIPLE_OPEN_BRACE;
+ public static TokenType TRIPLE_CLOSED_BRACE;
+ public static TokenType DOUBLE_OPEN_BRACKET;
+ public static TokenType DOUBLE_CLOSED_BRACKET;
+ public static TokenType PIPE;
+ public static TokenType DOUBLE_PIPE;
+ public static TokenType ALIGN_RIGHT;
+ public static TokenType ALIGN_CENTER;
+
+ private static bool initialized = false;
+
+ internal static void init_token_types () {
+ if (!initialized) {
+ ANY = new TokenType.basic ("<any>");
+ ANY_WORD = new TokenType.basic ("<any-word>");
+ ANY_NUMBER = new TokenType.basic ("<any-number>");
+ EOF = new TokenType.basic ("\0", "<end-of-file>");
+ EOL = new TokenType.basic ("\n", "<end-of-line>");
+ AROBASE = new TokenType.basic ("@");
+ SPACE = new TokenType.basic (" ", "<space>");
+ TAB = new TokenType.basic ("\t", "<tab>");
+ EQUAL_1 = new TokenType.basic ("=");
+ EQUAL_2 = new TokenType.basic ("==");
+ EQUAL_3 = new TokenType.basic ("====");
+ EQUAL_4 = new TokenType.basic ("=====");
+ EQUAL_5 = new TokenType.basic ("======");
+ MINUS = new TokenType.basic ("-");
+ STAR = new TokenType.basic ("*");
+ SHARP = new TokenType.basic ("#");
+ LESS_THAN = new TokenType.basic ("<");
+ GREATER_THAN = new TokenType.basic (">");
+ ALIGN_TOP = new TokenType.basic ("^");
+ ALIGN_BOTTOM = new TokenType.basic ("v");
+ SINGLE_QUOTE_2 = new TokenType.basic ("''");
+ SLASH_2 = new TokenType.basic ("//");
+ UNDERSCORE_2 = new TokenType.basic ("__");
+ BACK_QUOTE = new TokenType.basic ("`");
+ OPEN_BRACE = new TokenType.basic ("{");
+ CLOSED_BRACE = new TokenType.basic ("}");
+ DOUBLE_OPEN_BRACE = new TokenType.basic ("{{");
+ DOUBLE_CLOSED_BRACE = new TokenType.basic ("}}");
+ TRIPLE_OPEN_BRACE = new TokenType.basic ("{{{");
+ TRIPLE_CLOSED_BRACE = new TokenType.basic ("}}}");
+ DOUBLE_OPEN_BRACKET = new TokenType.basic ("[[");
+ DOUBLE_CLOSED_BRACKET = new TokenType.basic ("]]");
+ PIPE = new TokenType.basic ("|");
+ DOUBLE_PIPE = new TokenType.basic ("||");
+ ALIGN_RIGHT = new TokenType.basic ("))");
+ ALIGN_CENTER = new TokenType.basic (")(");
+ initialized = true;
+ }
+ }
+
+ private static int EXACT_WORD = -1;
+
+ public static TokenType str (string str) {
+ return new TokenType (str, EXACT_WORD, null);
+ }
+
+ public static TokenType any () {
+ return ANY;
+ }
+
+ public static TokenType any_word () {
+ return ANY_WORD;
+ }
+
+ public static TokenType any_number () {
+ return ANY_NUMBER;
+ }
+
+ private TokenType (string string_value, int basic_value, Action? action) {
+ _string_value = string_value;
+ _basic_value = basic_value;
+ _action = action;
+ }
+
+ private TokenType.basic (string string_value, string? pretty_string = null) {
+ _string_value = string_value;
+ _pretty_string = pretty_string;
+ _basic_value = ++_last_basic_value;
+ }
+
+ private static int _last_basic_value = -1;
+
+ private string _string_value;
+ private string? _pretty_string;
+ private int _basic_value = -1;
+ private Action? _action = null;
+
+ public delegate void Action (Token token) throws ParserError;
+
+ public TokenType action (Action action) {
+ return new TokenType (_string_value, _basic_value, action);
+ }
+
+ public void do_action (Token matched_token) throws ParserError {
+ if (_action != null) {
+ _action (matched_token);
+ }
+ }
+
+ public bool matches (Token token) {
+ if (_basic_value == ANY._basic_value) {
+ return true;
+ } else if (_basic_value == ANY_WORD._basic_value && token.is_word) {
+ return true;
+ } else if (_basic_value == ANY_NUMBER._basic_value && token.is_number) {
+ return true;
+ } else if (_basic_value == EXACT_WORD && token.is_word && token.word == _string_value) {
+ return true;
+ } else if (token.token_type != null && token.token_type._basic_value == _basic_value) {
+ return true;
+ }
+ return false;
+ }
+
+ public string to_string () {
+ return _string_value;
+ }
+
+ public string to_pretty_string () {
+ if (_pretty_string != null) {
+ return _pretty_string;
+ }
+ return _string_value;
+ }
+}
--- /dev/null
+/* commentscanner.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+public class Valadoc.WikiScanner : Object, Scanner {
+
+ public WikiScanner (Settings settings) {
+ _settings = settings;
+ }
+
+ private Settings _settings;
+ private Parser _parser;
+
+ private string _content;
+ private int _index;
+ private bool _stop;
+ private int _last_index;
+ private int _last_line;
+ private int _last_column;
+ private int _line;
+ private int _column;
+ private bool _url_escape_mode;
+ private bool _code_escape_mode;
+ private unichar _last_char;
+ private int _skip;
+ private StringBuilder _current_string = new StringBuilder ();
+
+ public void set_parser (Parser parser) {
+ _parser = parser;
+ }
+
+ public virtual void reset () {
+ _stop = false;
+ _last_index = 0;
+ _last_line = 0;
+ _last_column = 0;
+ _line = 0;
+ _column = 0;
+ _url_escape_mode = false;
+ _code_escape_mode = false;
+ _last_char = 0;
+ _skip = 0;
+ _current_string.erase (0, -1);
+ }
+
+ public void scan (string _content) throws ParserError {
+ this._content = _content;
+ for (_index = 0; !_stop && _index < _content.length; _index++) {
+ unichar c = _content[_index];
+ accept (c);
+ }
+ }
+
+ public void end () throws ParserError {
+ emit_token (TokenType.EOF);
+ }
+
+ public virtual void stop () {
+ _stop = true;
+ }
+
+ public void set_url_escape_mode (bool escape_mode) {
+ _url_escape_mode = escape_mode;
+ }
+
+ public void set_code_escape_mode (bool escape_mode) {
+ _code_escape_mode = escape_mode;
+ }
+
+ public int get_line () {
+ return _line;
+ }
+
+ public virtual string get_line_content () {
+ int i = _index;
+ while (i > 0 && _content[i-1] != '\n') {
+ i--;
+ }
+ StringBuilder builder = new StringBuilder ();
+ while (i < _content.length && _content[i] != '\n') {
+ unichar c = _content[i++];
+ if (c == '\t') {
+ builder.append (" ");
+ } else {
+ builder.append_unichar (c);
+ }
+ }
+ return builder.str;
+ }
+
+ protected unichar get_next_char (int offset = 1) {
+ return _content[_index + offset];
+ }
+
+ protected virtual void accept (unichar c) throws ParserError {
+ _column++;
+ if (_skip == 0) {
+ if (_code_escape_mode) {
+ switch (c) {
+ case '}':
+ if (get_next_char (1) == c && get_next_char (2) == c) {
+ _code_escape_mode = false; // This is a temporary hack
+ emit_token (TokenType.TRIPLE_CLOSED_BRACE);
+ _skip = 2;
+ } else {
+ append_char (c);
+ }
+ return;
+ default:
+ append_char (c);
+ return;
+ }
+ } else if (_url_escape_mode) {
+ switch (c) {
+ // Reserved characters
+ case ';':
+ case '/':
+ case '?':
+ case ':':
+ case '@':
+ case '#':
+ case '=':
+ case '&':
+ // Special characters
+ case '$':
+ case '-':
+ case '_':
+ case '.':
+ case '+':
+ case '!':
+ case '*':
+ case '\'':
+ case '(':
+ case ')':
+ case ',':
+ append_char (c);
+ return;
+ default:
+ break;
+ }
+ }
+
+ switch (c) {
+ case '@':
+ if (get_next_char () == '@') {
+ append_char (c);
+ _skip = 1;
+ } else {
+ emit_token (TokenType.AROBASE);
+ }
+ break;
+
+ case '{':
+ look_for_three (c,
+ TokenType.OPEN_BRACE,
+ TokenType.DOUBLE_OPEN_BRACE,
+ TokenType.TRIPLE_OPEN_BRACE);
+ break;
+
+ case '}':
+ look_for_three (c,
+ TokenType.CLOSED_BRACE,
+ TokenType.DOUBLE_CLOSED_BRACE,
+ TokenType.TRIPLE_CLOSED_BRACE);
+ break;
+
+ case '[':
+ look_for_two_or_append (c, TokenType.DOUBLE_OPEN_BRACKET);
+ break;
+
+ case ']':
+ look_for_two_or_append (c, TokenType.DOUBLE_CLOSED_BRACKET);
+ break;
+
+ case '|':
+ look_for_two (c,
+ TokenType.PIPE,
+ TokenType.DOUBLE_PIPE);
+ break;
+
+ case ')':
+ if (get_next_char () == ')') {
+ emit_token (TokenType.ALIGN_RIGHT);
+ _skip = 1;
+ } else if (get_next_char () == '(') {
+ emit_token (TokenType.ALIGN_CENTER);
+ _skip = 1;
+ } else {
+ append_char (c);
+ }
+ break;
+
+ case '*':
+ emit_token (TokenType.STAR);
+ break;
+
+ case '#':
+ emit_token (TokenType.SHARP);
+ break;
+
+ case '-':
+ if (_last_char.isalnum () || get_next_char ().isalnum ()) {
+ append_char (c);
+ } else {
+ emit_token (TokenType.MINUS);
+ }
+ break;
+
+ case '=':
+ look_for_five (c,
+ TokenType.EQUAL_1,
+ TokenType.EQUAL_2,
+ TokenType.EQUAL_3,
+ TokenType.EQUAL_4,
+ TokenType.EQUAL_5);
+ break;
+
+ case '<':
+ emit_token (TokenType.LESS_THAN);
+ break;
+
+ case '>':
+ emit_token (TokenType.GREATER_THAN);
+ break;
+
+ case '^':
+ emit_token (TokenType.ALIGN_TOP);
+ break;
+
+ case 'v':
+ unichar next_char = get_next_char ();
+ if (_last_char.isalnum () || _last_char == ' '
+ || next_char.isalnum () || next_char == ' ') {
+ append_char (c);
+ } else {
+ emit_token (TokenType.ALIGN_BOTTOM);
+ }
+ break;
+
+ case '\'':
+ look_for_two_or_append (c, TokenType.SINGLE_QUOTE_2);
+ break;
+
+ case '/':
+ look_for_two_or_append (c, TokenType.SLASH_2);
+ break;
+
+ case '_':
+ look_for_two_or_append (c, TokenType.UNDERSCORE_2);
+ break;
+
+ case '`':
+ emit_token (TokenType.BACK_QUOTE);
+ break;
+
+ case '\t':
+ emit_token (TokenType.TAB);
+ break;
+
+ case ' ':
+ emit_token (TokenType.SPACE);
+ break;
+
+ case '\r':
+ break;
+
+ case '\n':
+ emit_token (TokenType.EOL);
+ _line++;
+ _column = 0;
+ _last_column = 0;
+ break;
+
+ default:
+ append_char (c);
+ break;
+ }
+ } else {
+ _skip--;
+ }
+ _last_char = c;
+ }
+
+ private void append_char (unichar c) {
+ _current_string.append_unichar (c);
+ }
+
+ public virtual int get_line_start_column () {
+ return 0;
+ }
+
+ private SourceLocation get_begin () {
+ return SourceLocation (_last_line, get_line_start_column () + _last_column);
+ }
+
+ private SourceLocation get_end (int offset = 0) {
+ return SourceLocation (_line, get_line_start_column () + _column + offset);
+ }
+
+ private void emit_current_word () throws ParserError {
+ if (_current_string.len > 0) {
+ _parser.accept_token (new Token.from_word (_current_string.str, get_begin (), get_end (-1)));
+ _current_string.erase (0, -1);
+
+ _last_index = _index;
+ _last_line = _line;
+ _last_column = _column - 1;
+ }
+ }
+
+ private void emit_token (TokenType type) throws ParserError {
+ emit_current_word ();
+
+ _parser.accept_token (new Token.from_type (type, get_begin (), get_end (_skip)));
+
+ _last_index = _index;
+ _last_line = _line;
+ _last_column = _column;
+ }
+
+ private void look_for_two_or_append (unichar c, TokenType type) throws ParserError {
+ if (get_next_char () == c) {
+ emit_token (type);
+ _skip = 1;
+ } else {
+ append_char (c);
+ }
+ }
+
+ private void look_for_two (unichar c, TokenType one, TokenType two) throws ParserError {
+ if (get_next_char (1) == c) {
+ emit_token (two);
+ _skip = 1;
+ } else {
+ emit_token (one);
+ }
+ }
+
+ private void look_for_three (unichar c, TokenType one, TokenType two, TokenType three) throws ParserError {
+ if (get_next_char (1) == c) {
+ if (get_next_char (2) == c) {
+ emit_token (three);
+ _skip = 2;
+ } else {
+ emit_token (two);
+ _skip = 1;
+ }
+ } else {
+ emit_token (one);
+ }
+ }
+
+ private void look_for_five (unichar c, TokenType one, TokenType two, TokenType three, TokenType four, TokenType five) throws ParserError {
+ if (get_next_char (1) == c) {
+ if (get_next_char (2) == c) {
+ if (get_next_char (3) == c) {
+ if (get_next_char (4) == c) {
+ emit_token (five);
+ _skip = 4;
+ } else {
+ emit_token (four);
+ _skip = 3;
+ }
+ } else {
+ emit_token (three);
+ _skip = 2;
+ }
+ } else {
+ emit_token (two);
+ _skip = 1;
+ }
+ } else {
+ emit_token (one);
+ }
+ }
+}
--- /dev/null
+/* taglet.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+using Valadoc.Content;
+
+public class Valadoc.Taglets.Deprecated : InlineContent, Taglet, Block {
+ public Rule? get_parser_rule (Rule run_rule) {
+ return run_rule;
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ base.check (api_root, container, reporter);
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_taglet (this);
+ }
+}
--- /dev/null
+/* tagletinheritdoc.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+using Valadoc.Content;
+
+public class Valadoc.Taglets.InheritDoc : InlineTaglet {
+ private DocumentedElement? _inherited;
+
+ public override Rule? get_parser_rule (Rule run_rule) {
+ return null;
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ // TODO Check that the container is an override of an abstract symbol
+ // Also retrieve that abstract symbol _inherited
+
+ if (container is Method) {
+ _inherited = ((Method) container).base_method;
+ } else if (container is Property) {
+ _inherited = ((Property) container).base_property;
+ }
+
+ // TODO report error if inherited is null
+
+ // TODO postpone check after complete parse of the api tree comments
+ // And reenable that check
+ //base.check (api_root, container, reporter);
+ }
+
+ public override ContentElement produce_content () {
+ if (_inherited != null) {
+ Paragraph inherited_paragraph = _inherited.documentation.content.get (0) as Paragraph;
+
+ Highlighted paragraph = new Highlighted (Highlighted.Style.NONE);
+ foreach (var element in inherited_paragraph.content) {
+ paragraph.content.add (element);
+ }
+ return paragraph;
+ }
+ return new Text ("");
+ }
+}
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
-using GLib;
-using Gee;
-
-
-public class Valadoc.Html.CodeConstantDocElement : Valadoc.CodeConstantDocElement {
- private string constant;
-
- public override bool parse (string constant) {
- this.constant = constant;
- return true;
- }
-
- public override bool write (void* res, int max, int index) {
- weak GLib.FileStream file = (GLib.FileStream)res;
- file.printf ("<font class=\"%s\">%s</font>", css_content_literal, this.constant);
- return true;
+using Valadoc;
+
+namespace Valadoc.Taglets {
+ public void init (ModuleLoader loader) {
+ loader.taglets.set ("see", typeof (Valadoc.Taglets.See));
+ loader.taglets.set ("since", typeof (Valadoc.Taglets.Since));
+ loader.taglets.set ("link", typeof (Valadoc.Taglets.Link));
+ loader.taglets.set ("throws", typeof (Valadoc.Taglets.Throws));
+ loader.taglets.set ("return", typeof (Valadoc.Taglets.Return));
+ loader.taglets.set ("param", typeof (Valadoc.Taglets.Param));
+ loader.taglets.set ("deprecated", typeof (Valadoc.Taglets.Deprecated));
+ loader.taglets.set ("inheritDoc", typeof (Valadoc.Taglets.InheritDoc));
}
}
-
-
-[ModuleInit]
-public GLib.Type register_plugin (Gee.HashMap<string, Type> taglets) {
- return typeof (Valadoc.Html.CodeConstantDocElement);
-}
-
--- /dev/null
+/* taglet.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+using Valadoc.Content;
+
+public class Valadoc.Taglets.Link : InlineTaglet {
+ public string symbol_name { private set; get; }
+
+ private DocumentedElement _symbol;
+
+ public override Rule? get_parser_rule (Rule run_rule) {
+ return Rule.seq ({
+ TokenType.any_word ().action ((token) => { symbol_name = token.to_string (); })
+ });
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ _symbol = api_root.search_symbol_str (container, symbol_name);
+ if (_symbol == null) {
+ // TODO use ContentElement's source reference
+ reporter.simple_error ("%s does not exist".printf (symbol_name));
+ }
+
+ base.check (api_root, container, reporter);
+ }
+
+ public override ContentElement produce_content () {
+ var link = new Content.SymbolLink ();
+ link.symbol = _symbol;
+ link.label = symbol_name;
+ return link;
+ }
+}
--- /dev/null
+/* taglet.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+using Valadoc.Content;
+
+public class Valadoc.Taglets.Param : InlineContent, Taglet, Block {
+ public string parameter_name { private set; get; }
+
+ public Rule? get_parser_rule (Rule run_rule) {
+ return Rule.seq ({
+ TokenType.any_word ().action ((token) => { parameter_name = token.to_string (); }),
+ Rule.many ({ TokenType.SPACE }),
+ run_rule
+ });
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ // TODO check for the existence of such a parameter
+
+ base.check (api_root, container, reporter);
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_taglet (this);
+ }
+}
--- /dev/null
+/* taglet.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+using Valadoc.Content;
+
+public class Valadoc.Taglets.Return : InlineContent, Taglet, Block {
+ public Rule? get_parser_rule (Rule run_rule) {
+ return run_rule;
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ // TODO check for the existence of a return type
+
+ base.check (api_root, container, reporter);
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_taglet (this);
+ }
+}
--- /dev/null
+/* taglet.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+using Valadoc.Content;
+
+public class Valadoc.Taglets.See : ContentElement, Taglet, Block {
+ public string symbol_name { private set; get; }
+ public DocumentedElement symbol { private set; get; }
+
+ public Rule? get_parser_rule (Rule run_rule) {
+ return Rule.seq ({
+ TokenType.any_word ().action ((token) => { symbol_name = token.to_string (); })
+ });
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ symbol = api_root.search_symbol_str (container, symbol_name);
+ if (symbol == null) {
+ // TODO use ContentElement's source reference
+ reporter.simple_error ("%s does not exist".printf (symbol_name));
+ }
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_taglet (this);
+ }
+}
--- /dev/null
+/* taglet.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+using Valadoc.Content;
+
+public class Valadoc.Taglets.Since : ContentElement, Taglet, Block {
+ public string version;
+
+ public Rule? get_parser_rule (Rule run_rule) {
+ return Rule.seq ({
+ TokenType.any_word ().action ((token) => { version = token.to_string (); })
+ });
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_taglet (this);
+ }
+}
--- /dev/null
+/* taglet.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 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using GLib;
+using Gee;
+using Valadoc.Content;
+
+public class Valadoc.Taglets.Throws : InlineContent, Taglet, Block {
+ public string error_domain_name { private set; get; }
+ public DocumentedElement error_domain { private set; get; }
+
+ public Rule? get_parser_rule (Rule run_rule) {
+ return Rule.seq ({
+ TokenType.any_word ().action ((token) => { error_domain_name = token.to_string (); }),
+ Rule.many ({ TokenType.SPACE }),
+ run_rule
+ });
+ }
+
+ public override void check (Tree api_root, DocumentedElement? container, ErrorReporter reporter) {
+ error_domain = api_root.search_symbol_str (container, error_domain_name);
+ if (error_domain == null) {
+ // TODO use ContentElement's source reference
+ reporter.simple_error ("%s does not exist".printf (error_domain_name));
+ }
+
+ base.check (api_root, container, reporter);
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_taglet (this);
+ }
+}
--- /dev/null
+*
+ * This is a stupid {@dumb} ''toto'' //''documentation''// comment
+ * for everything I didn't comment until now
+ *
+ * __Another__ description //line//
+ *
+ * Yet another __description__ line, but this one __lasts__
+ * along some [[http://live.gnome.org/valadoc/|The Valadoc Website]]
+ * {{./img/an_image.png|An image}}
+ * //lines//
+ *
+ * )) A right-aligned paragraph+ {@link AType} that continues at the
+ * next line
+ *
+ * )( Center-aligned stuff
+ *
+ * {@inheritDoc}
+ *
+ * {{{
+ * if (toto) {
+ * do_bad_stuff (my_variable++);
+ * }
+ * }}}
+ * * A list item
+ * * Another list item
+ * . No bullet
+ * * A list item
+ * * Another list item
+ *
+ * ||<header-3> Joint Header Cell ||
+ * ||<header> Joint Cell || Cell3 ||
+ * || Cell1 || <|2> Joint Cell ||
+ *
+ * == Header 2 ==
+ * === Header 3 ===
+ * One can write immediately after headers
+ *
+ * ==== Header 4 ====
+ * A. Mixed with ordered items
+ * 1. Another ordered items
+ *
+ * And some other data
+ *
+ * @param test a test parameter
+ * that continues here
+ * @return the value it returns
+ * and this is the @@last line
+
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+
+DEBUG_FLAGS=""
+#DEBUG_FLAGS="$DEBUG_FLAGS -D DEBUG"
+#DEBUG_FLAGS="$DEBUG_FLAGS -D HARD_DEBUG"
+#DEBUG_FLAGS="$DEBUG_FLAGS -D VERY_HARD_DEBUG"
+
+COMMAND="./testparser testcomment.test"
+COMMAND="gdb -ex run -ex bt -ex finish -ex quit --args $COMMAND"
+
+valac -C $DEBUG_FLAGS -g -o testparser --pkg vala-1.0 \
+ parser/commentscanner.vala \
+ parser/documentationfactory.vala \
+ parser/documentationparser.vala \
+ parser/manyrule.vala \
+ parser/oneofrule.vala \
+ parser/parser.vala \
+ parser/parsercallback.vala \
+ parser/rule.vala \
+ parser/scanner.vala \
+ parser/sequencerule.vala \
+ parser/stubrule.vala \
+ parser/token.vala \
+ parser/wikiscanner.vala \
+ documentation/errorreporter.vala \
+ settings.vala \
+ testparser.vala \
+&& valac $DEBUG_FLAGS -g -o testparser --pkg vala-1.0 \
+ parser/commentscanner.vala \
+ parser/documentationfactory.vala \
+ parser/documentationparser.vala \
+ parser/manyrule.vala \
+ parser/oneofrule.vala \
+ parser/parser.vala \
+ parser/parsercallback.vala \
+ parser/rule.vala \
+ parser/scanner.vala \
+ parser/sequencerule.vala \
+ parser/stubrule.vala \
+ parser/token.vala \
+ parser/wikiscanner.vala \
+ documentation/errorreporter.vala \
+ settings.vala \
+ testparser.vala \
+&& $COMMAND
--- /dev/null
+/** Just a test file for parser2 **/
+
+namespace Valadoc {
+ void main (string[] args) {
+ Settings settings = new Settings ();
+ ErrorReporter reporter = new ErrorReporter ();
+ DocumentationParser parser = new DocumentationParser(settings, reporter);
+
+ string filename = args[1];
+ string content;
+ if (FileUtils.get_contents (filename, out content)) {
+ Object root = parser.parse_comment (content, filename, 0, 0);
+ stdout.printf ("\n%s\n", ((Node) root).to_string ());
+ }
+ }
+}
ModuleLoader modules = new ModuleLoader ();
+ Taglets.init (modules);
bool tmp = modules.load (fulldirpath);
if (tmp == false) {
reporter.simple_error ("failed to load plugin");
Valadoc.Tree doctree = new Valadoc.Tree (reporter, settings);
- Valadoc.Parser docparser = new Valadoc.Parser (settings, reporter, doctree, modules);
+ Valadoc.DocumentationParser docparser = new Valadoc.DocumentationParser (settings, reporter, doctree, modules);
if (reporter.errors > 0) {
return quit (reporter);
}