[valadoc] - valadoc.org doclet improvements
- From: Florian Brosch <flobrosch src gnome org>
- To: svn-commits-list gnome org
- Subject: [valadoc] - valadoc.org doclet improvements
- Date: Tue, 21 Jul 2009 11:58:41 +0000 (UTC)
commit eb854b46fdf9c75479e4037e5bafe19e019e8591
Author: Florian Brosch <flo brosch gmail com>
Date: Tue Jul 21 13:46:18 2009 +0200
- valadoc.org doclet improvements
- html-writer, initial work
- bug fixes
configure.in | 2 +
src/doclets/devhelp/Makefile.am | 1 +
src/doclets/htmlhelpers/Makefile.am | 10 +-
src/doclets/htmlhelpers/html/Makefile.am | 55 +++
src/doclets/htmlhelpers/html/attribute.vala | 18 +
src/doclets/htmlhelpers/html/block.vala | 65 +++
src/doclets/htmlhelpers/html/htmlwriter.vala | 87 ++++
src/doclets/htmlhelpers/html/inline.vala | 74 +++
src/doclets/htmlhelpers/languages/Makefile.am | 57 +++
src/doclets/htmlhelpers/languages/vala.vala | 615 +++++++++++++++++++++++++
src/doclets/valadoc.org/doclet/Makefile.am | 24 +-
src/doclets/valadoc.org/doclet/template.vala | 39 ++-
src/libvaladoc/apitree.vala | 48 ++-
src/vapi/valadoc-1.2.0.deps | 2 +
14 files changed, 1061 insertions(+), 36 deletions(-)
---
diff --git a/configure.in b/configure.in
index 850e887..f76e937 100644
--- a/configure.in
+++ b/configure.in
@@ -71,6 +71,8 @@ AC_CONFIG_FILES([Makefile
src/doclets/Makefile
src/doclets/htmlhelpers/Makefile
src/doclets/htmlhelpers/deps/Makefile
+ src/doclets/htmlhelpers/html/Makefile
+ src/doclets/htmlhelpers/languages/Makefile
src/doclets/htmlhelpers/doclet/Makefile
src/doclets/htmlhelpers/taglets/Makefile
src/doclets/htmlhelpers/taglets/see/Makefile
diff --git a/src/doclets/devhelp/Makefile.am b/src/doclets/devhelp/Makefile.am
index 6a563cf..47c7e60 100644
--- a/src/doclets/devhelp/Makefile.am
+++ b/src/doclets/devhelp/Makefile.am
@@ -4,3 +4,4 @@ NULL =
SUBDIRS = doclet \
$(NULL)
+
diff --git a/src/doclets/htmlhelpers/Makefile.am b/src/doclets/htmlhelpers/Makefile.am
index e8a7c07..10df173 100644
--- a/src/doclets/htmlhelpers/Makefile.am
+++ b/src/doclets/htmlhelpers/Makefile.am
@@ -1,8 +1,10 @@
NULL =
-SUBDIRS = \
- doclet \
- taglets \
- deps \
+SUBDIRS = \
+ html \
+ languages \
+ doclet \
+ taglets \
+ deps \
$(NULL)
diff --git a/src/doclets/htmlhelpers/html/Makefile.am b/src/doclets/htmlhelpers/html/Makefile.am
new file mode 100644
index 0000000..f0e283d
--- /dev/null
+++ b/src/doclets/htmlhelpers/html/Makefile.am
@@ -0,0 +1,55 @@
+NULL =
+
+
+AM_CFLAGS = -g \
+ $(GLIB_CFLAGS) \
+ $(LIBVALA_CFLAGS) \
+ $(NULL)
+
+
+BUILT_SOURCES = libhtmlwriter.vala.stamp
+
+
+htmlwriterdir = $(libdir)/valadoc/plugins/htmlhelpers/
+
+
+htmlwriter_LTLIBRARIES = \
+ libhtmlwriter.la \
+ $(NULL)
+
+
+libhtmlwriter_la_VALASOURCES = \
+ htmlwriter.vala \
+ attribute.vala \
+ block.vala \
+ inline.vala \
+ $(NULL)
+
+
+libhtmlwriter_la_SOURCES = \
+ libhtmlwriter.vala.stamp \
+ $(libhtmlwriter_la_VALASOURCES:.vala=.c) \
+ $(NULL)
+
+
+libhtmlwriter.vala.stamp: $(libhtmlwriter_la_VALASOURCES)
+ $(VALAC) -C --pkg vala-1.0 --basedir . --save-temps --library htmlwriter-1.0 -H htmlwriter-1.0.h $^
+ touch $@
+
+
+libhtmlwriter_la_LDFLAGS = $(NULL)
+
+
+libhtmlwriter_la_LIBADD = \
+ $(GLIB_LIBS) \
+ $(LIBVALA_LIBS) \
+ $(NULL)
+
+
+EXTRA_DIST = $(libhtmlwriter_la_VALASOURCES) libhtmlwriter.vala.stamp
+
+
+MAINTAINERCLEANFILES = \
+ $(libhtmlwriter_la_VALASOURCES:.vala=.c) \
+ $(NULL)
+
diff --git a/src/doclets/htmlhelpers/html/attribute.vala b/src/doclets/htmlhelpers/html/attribute.vala
new file mode 100644
index 0000000..8c061c8
--- /dev/null
+++ b/src/doclets/htmlhelpers/html/attribute.vala
@@ -0,0 +1,18 @@
+
+using Gee;
+
+
+public class Valadoc.Html.Attribute {
+ private string name;
+ private string val;
+
+ public Attribute (string name, string val) {
+ this.name = name;
+ this.val = val;
+ }
+
+ public string to_string (string path) {
+ return " %s=\"%s\"".printf (this.name, this.val);
+ }
+}
+
diff --git a/src/doclets/htmlhelpers/html/block.vala b/src/doclets/htmlhelpers/html/block.vala
new file mode 100644
index 0000000..08aef6a
--- /dev/null
+++ b/src/doclets/htmlhelpers/html/block.vala
@@ -0,0 +1,65 @@
+
+using Gee;
+
+
+public abstract class Valadoc.Html.BlockElement : Valadoc.Html.Element {
+ public override string to_string (uint depth, string path) {
+ string depthstr = string.nfill (depth, '\t');
+ StringBuilder str = new StringBuilder (depthstr);
+ str.append_c ('<');
+ str.append (this.tag);
+ str.append (this.attributes_to_string (path));
+ if (this.children.size > 0) {
+ str.append (">\n");
+
+ str.append (this.children_to_string (depth+1, path));
+
+ str.append_c ('\n');
+ str.append (depthstr);
+ str.append ("</");
+ str.append (this.tag);
+ str.append (">\n");
+ }
+ else {
+ str.append (" />\n");
+ }
+ return str.str;
+ }
+}
+
+
+public class Valadoc.Html.Html : Valadoc.Html.BlockElement {
+ private static string mytag = "html";
+
+ public Html () {
+ this.tag = mytag;
+ }
+}
+
+
+public class Valadoc.Html.Head : Valadoc.Html.BlockElement {
+ private static string mytag = "head";
+
+ public Head () {
+ this.tag = mytag;
+ }
+}
+
+
+public class Valadoc.Html.Body : Valadoc.Html.BlockElement {
+ private static string mytag = "body";
+
+ public Body () {
+ this.tag = mytag;
+ }
+}
+
+
+public class Valadoc.Html.Div : Valadoc.Html.BlockElement {
+ private static string mytag = "div";
+
+ public Div () {
+ this.tag = mytag;
+ }
+}
+
diff --git a/src/doclets/htmlhelpers/html/htmlwriter.vala b/src/doclets/htmlhelpers/html/htmlwriter.vala
new file mode 100644
index 0000000..e78623f
--- /dev/null
+++ b/src/doclets/htmlhelpers/html/htmlwriter.vala
@@ -0,0 +1,87 @@
+
+using Gee;
+
+
+public abstract class Valadoc.Html.Entry {
+ public abstract string to_string (uint depth, string path);
+}
+
+
+public class Valadoc.Html.String : Valadoc.Html.Entry {
+ private string str;
+
+ public String (string str) {
+ this.str = str;
+ }
+
+ public override string to_string (uint depth, string path) {
+ return this.str;
+ }
+}
+
+
+public abstract class Valadoc.Html.Element : Valadoc.Html.Entry {
+ protected ArrayList<Attribute> attributes = new ArrayList<Attribute> ();
+ protected ArrayList<Entry> children = new ArrayList<Entry> ();
+ protected weak string tag;
+
+ public void add_attribute (Attribute att) {
+ this.attributes.add (att);
+ }
+
+ public void add_attributes (Collection<Attribute> attributes) {
+ foreach (Attribute att in attributes) {
+ this.attributes.add (att);
+ }
+ }
+
+ public void add_child (Entry el) {
+ this.children.add (el);
+ }
+
+ public void add_childs (Collection<Entry> elements) {
+ foreach (Entry el in elements) {
+ this.children.add (el);
+ }
+ }
+
+ protected string children_to_string (uint depth, string path) {
+ StringBuilder str = new StringBuilder ();
+
+ foreach (Entry child in this.children) {
+ str.append (child.to_string(depth, path));
+ }
+ return str.str;
+ }
+
+ protected string attributes_to_string (string path) {
+ if (this.attributes == null) {
+ return "";
+ }
+
+ StringBuilder str = new StringBuilder ();
+
+ foreach (Attribute att in this.attributes) {
+ str.append (att.to_string(path));
+ }
+ return str.str;
+ }
+}
+
+
+public class Valadoc.Html.Document {
+ private Html root;
+
+ public void set_root (Html root) {
+ this.root = root;
+ }
+
+ public string to_string (string path) {
+ if (this.root == null) {
+ return "";
+ }
+
+ return this.root.to_string (0, path);
+ }
+}
+
diff --git a/src/doclets/htmlhelpers/html/inline.vala b/src/doclets/htmlhelpers/html/inline.vala
new file mode 100644
index 0000000..cc96e75
--- /dev/null
+++ b/src/doclets/htmlhelpers/html/inline.vala
@@ -0,0 +1,74 @@
+
+using Gee;
+
+
+public abstract class Valadoc.Html.InlineElement : Valadoc.Html.Element {
+ public override string to_string (uint depth, string path) {
+ StringBuilder str = new StringBuilder ("<");
+ str.append (this.tag);
+ str.append (this.attributes_to_string (path));
+ if (this.children.size > 0) {
+ str.append_c ('>');
+
+ str.append (this.children_to_string (depth+1, path));
+
+ str.append ("</");
+ str.append (this.tag);
+ str.append (">");
+ }
+ else {
+ str.append (" />");
+ }
+ return str.str;
+ }
+}
+
+
+public class Valadoc.Html.Span : Valadoc.Html.InlineElement {
+ private static string mytag = "span";
+
+ public Span () {
+ this.tag = mytag;
+ }
+
+ public Span.from_list (Collection<Entry> list) {
+ this.tag = mytag;
+
+ foreach (Entry e in list) {
+ this.children.add (e);
+ }
+ }
+}
+
+
+public class Valadoc.Html.Link : Valadoc.Html.InlineElement {
+ private static string mytag = "a";
+ private Attribute path;
+
+ public class Link (string path, Entry desc) {
+ this.path = new Attribute ("href", path);
+ this.add_attribute (this.path);
+ this.children.add (desc);
+ this.tag = mytag;
+ }
+
+ public Link.from_list (string path, Collection<Entry> descs) {
+ this.path = new Attribute ("href", path);
+ this.add_attribute (this.path);
+ this.tag = mytag;
+
+ foreach (Entry desc in descs) {
+ this.children.add (desc);
+ }
+ }
+}
+
+
+public class Valadoc.Html.Image : Valadoc.Html.InlineElement {
+ private static string mytag = "img";
+
+ public Image (string path) {
+ this.tag = mytag;
+ }
+}
+
diff --git a/src/doclets/htmlhelpers/languages/Makefile.am b/src/doclets/htmlhelpers/languages/Makefile.am
new file mode 100644
index 0000000..398160e
--- /dev/null
+++ b/src/doclets/htmlhelpers/languages/Makefile.am
@@ -0,0 +1,57 @@
+NULL =
+
+
+AM_CFLAGS = -g \
+ -I ../../../libvaladoc/ \
+ -I ../html/ \
+ $(GLIB_CFLAGS) \
+ $(LIBVALA_CFLAGS) \
+ $(NULL)
+
+
+BUILT_SOURCES = libapiwriter.vala.stamp
+
+
+apiwriterdir = $(libdir)/valadoc/plugins/htmlhelpers/
+
+
+apiwriter_LTLIBRARIES = \
+ libapiwriter.la \
+ $(NULL)
+
+
+libapiwriter_la_VALASOURCES = \
+ vala.vala \
+ $(NULL)
+
+
+libapiwriter_la_SOURCES = \
+ libapiwriter.vala.stamp \
+ $(libapiwriter_la_VALASOURCES:.vala=.c) \
+ $(NULL)
+
+
+libapiwriter.vala.stamp: $(libapiwriter_la_VALASOURCES)
+ $(VALAC) -C --vapidir ../../../vapi --pkg valadoc-1.0 --vapidir ../html/ --pkg htmlwriter-1.0 --basedir . --save-temps -H apiwriter-1.0.h --library apiwriter-1.0 $^
+ touch $@
+
+
+libapiwriter_la_LDFLAGS = -module -avoid-version
+
+
+libapiwriter_la_LIBADD = \
+ ../../../libvaladoc/libvaladoc.la \
+ ../html/libhtmlwriter.la \
+ $(LIBGVC_LIBS) \
+ $(LIBVALA_LIBS) \
+ $(GLIB_LIBS) \
+ $(NULL)
+
+
+EXTRA_DIST = $(libapiwriter_la_VALASOURCES) libapiwriter.vala.stamp
+
+
+MAINTAINERCLEANFILES = \
+ $(libapiwriter_la_VALASOURCES:.vala=.c) \
+ $(NULL)
+
diff --git a/src/doclets/htmlhelpers/languages/vala.vala b/src/doclets/htmlhelpers/languages/vala.vala
new file mode 100644
index 0000000..99eb791
--- /dev/null
+++ b/src/doclets/htmlhelpers/languages/vala.vala
@@ -0,0 +1,615 @@
+
+
+using Valadoc.Html;
+using Valadoc;
+using Gee;
+
+public class Valadoc.Html.Api.Vala {
+ private Attribute csskeyword = new Attribute ("class", "apikeyword");
+ private Attribute cssformalparam = new Attribute ("class", "apiformalparameter");
+ private Attribute cssparamlist = new Attribute ("class", "apiparameterlist");
+ private Attribute cssexclist = new Attribute ("class", "apiexceptionlist");
+ private Attribute cssapi = new Attribute ("class", "api");
+ private Attribute csstype = new Attribute ("class", "apitype");
+ private Attribute cssbasictype = new Attribute ("class", "apibasictype");
+ private Attribute csslink = new Attribute ("class", "apilink");
+ private Attribute cssoptparamlist = new Attribute ("class", "apioptparameterlist");
+
+
+ private Entry keyword (string str) {
+ Span span = new Span ();
+ span.add_attribute (this.csskeyword);
+ span.add_child (new String(str));
+ return span;
+ }
+
+ private Entry type (Basic? type, out bool documentedelement) {
+ ArrayList<Entry> elements = new ArrayList<Entry> ();
+ weak Attribute css = this.csstype;
+ documentedelement = false;
+
+ while (true) {
+ if (type == null) {
+ elements.insert (0, this.keyword("void"));
+ break;
+ }
+ else if (type is Pointer) {
+ elements.add (new String("*"));
+ type = ((Pointer)type).data_type;
+ }
+ else if (type is Array) {
+ //TODO: multidim. arrays
+ elements.add (new String("[]"));
+ type = ((Array)type).data_type;
+ }
+ else if (type is TypeParameter) {
+ elements.insert (0, new String (((TypeParameter)type).name));
+ break;
+ }
+ else if (type is DocumentedElement) {
+ weak DocumentedElement dtype = (DocumentedElement)type;
+ if (dtype.package.name == "glib-2.0" && dtype.nspace.name == null && (dtype is Struct || dtype is Class)) {
+ css = this.cssbasictype;
+ }
+
+ Link link = new Link ("/%s/%s.html".printf (dtype.package.name, dtype.full_name ()), new String (dtype.name));
+ link.add_attribute (csslink);
+ elements.insert (0, link);
+ documentedelement = true;
+ break;
+ }
+ else { // typereference
+ // prepend:
+ ArrayList<Entry> lst = this.type_reference (((TypeReference)type));
+ foreach (Entry e in elements) {
+ lst.add (e);
+ }
+ elements = lst;
+ break;
+ }
+ }
+
+ Span span = new Span.from_list (elements);
+ span.add_attribute (css);
+ return span;
+ }
+
+ private ArrayList<Entry>? type_parameter_list (TemplateParameterListHandler tplh) {
+ Collection<TypeParameter> tpllist = tplh.get_template_param_list ();
+ if (tpllist.size == 0) {
+ return null;
+ }
+
+ ArrayList<Entry> cnt = new ArrayList<Entry> ();
+ int i = 0;
+
+ cnt.add (new String ("<"));
+
+ foreach (TypeParameter tpl in tpllist ) {
+ Span span = new Span ();
+ span.add_child (new String (tpl.name));
+ span.add_attribute (this.csstype);
+ cnt.add (span);
+
+ if (++i != tpllist.size) {
+ cnt.add (new String (", "));
+ }
+ }
+
+ cnt.add (new String (">"));
+ return cnt;
+ }
+
+ private ArrayList<Entry> type_reference (TypeReference typeref) {
+ ArrayList<Entry> list = new ArrayList<Entry> ();
+ bool documentedelement;
+
+ StringBuilder str = new StringBuilder ();
+ //if(typeref.pass_ownership) {
+ //}
+
+ if(typeref.is_dynamic) {
+ str.append ("dynamic ");
+ }
+
+ if(typeref.is_owned) {
+ str.append ("owned ");
+ }
+
+ if(typeref.is_unowned) {
+ str.append ("unowned ");
+ }
+
+ if(typeref.is_weak) {
+ str.append ("weak ");
+ }
+
+ if (str.len > 0) {
+ list.add (this.keyword (str.str));
+ }
+
+ list.add (this.type (typeref.data_type, out documentedelement));
+
+ Collection<TypeReference> typeargs = typeref.get_type_arguments ();
+ if (typeargs.size != 0) {
+ list.add (new String ("<"));
+ int i = 0;
+
+ foreach (TypeReference tref in typeargs) {
+ foreach (Entry e in this.type_reference (tref)) {
+ list.add (e);
+ }
+
+ if (++i != typeargs.size) {
+ list.add (new String (", "));
+ }
+ }
+
+ list.add (new String (">"));
+ }
+
+ if(typeref.is_nullable && documentedelement) {
+ list.add(new String("?"));
+ }
+
+ return list;
+ }
+
+ private Entry formal_parameter (FormalParameter param) {
+ Span span = new Span ();
+ span.add_attribute (this.cssformalparam);
+
+ if (param.ellipsis) {
+ span.add_child (new String ("..."));
+ return span;
+ }
+ else {
+ if (param.is_out) {
+ span.add_child (this.keyword("out "));
+ }
+ else if (param.is_ref) {
+ span.add_child (this.keyword("ref "));
+ }
+
+ span.add_childs (this.type_reference(param.type_reference));
+ span.add_child (new String(" "+param.name));
+ return span;
+ }
+ }
+
+ private Entry parameter_list (ParameterListHandler paramh) {
+ Span rspan = new Span ();
+ Span span = rspan;
+
+ span.add_attribute (cssparamlist);
+
+ span.add_child (new String("("));
+ bool default_value = false;
+ int i = 0;
+
+ foreach (FormalParameter param in paramh.param_list) {
+ if (param.has_default_value) {
+ default_value = true;
+
+ span = new Span ();
+ span.add_attribute (this.cssoptparamlist);
+ span.add_child (new String("["));
+ rspan.add_child (span);
+ }
+
+ span.add_child (this.formal_parameter(param));
+ if (++i != paramh.param_list.size) {
+ span.add_child (new String (", "));
+ }
+ }
+
+ if (default_value) {
+ span.add_child (new String("]"));
+ span = rspan;
+ }
+
+ span.add_child (new String(")"));
+ return rspan;
+ }
+
+ private string symbol_accessibility (SymbolAccessibility symbol) {
+ if (symbol.is_public) {
+ return "public";
+ }
+ else if (symbol.is_protected) {
+ return "protected ";
+ }
+ else {
+ return "private ";
+ }
+ }
+
+ private Entry exception (DocumentedElement element) {
+ Span span = new Span();
+ span.add_child (new String (element.full_name()));
+ return span;
+ }
+
+ private Entry? exceptions (ExceptionHandler exh) {
+ Collection<DocumentedElement> errs = exh.get_error_domains ();
+ if (errs.size == 0) {
+ return null;
+ }
+
+ Span span = new Span ();
+ span.add_attribute (cssexclist);
+
+ span.add_child (this.keyword(" throws "));
+
+ foreach (DocumentedElement type in errs) {
+ span.add_child (this.exception(type));
+ }
+
+ return span;
+ }
+
+ public Div from_method (Method m) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+ StringBuilder str = new StringBuilder (this.symbol_accessibility (m));
+ str.append_c (' ');
+
+ if ( m.is_abstract ) {
+ str.append ("abstract ");
+ }
+ else if ( m.is_virtual ) {
+ str.append ("virtual ");
+ }
+ else if ( m.is_override ) {
+ str.append ("override ");
+ }
+
+ if ( m.is_static ) {
+ str.append ("static ");
+ }
+
+ if ( m.is_inline ) {
+ str.append ("inline ");
+ }
+
+ api.add_child (this.keyword(str.str));
+ str = null;
+
+
+ // return type:
+ if (m.is_constructor == false) {
+ Collection<Entry> lst = this.type_reference (m.type_reference);
+ api.add_childs (lst);
+ }
+
+ api.add_child (new String (" "+m.name));
+
+
+ Collection<Entry> lst = this.type_parameter_list ((m.is_constructor)? (TemplateParameterListHandler)m.parent: m);
+ if (lst != null) {
+ api.add_childs (lst);
+ }
+
+ api.add_child (new String (" "));
+
+ // type parameters
+ api.add_child (this.parameter_list (m));
+ Entry? exceptions = this.exceptions (m);
+ if (exceptions != null) {
+ api.add_child (exceptions);
+ }
+
+ if (m.is_yields) {
+ api.add_child (this.keyword(" yields"));
+ }
+
+ api.add_child (new String(";"));
+ return api;
+ }
+
+ public Div from_delegate (Delegate del) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+
+ api.add_child (this.keyword(this.symbol_accessibility (del) + " delegate "));
+
+
+ // return type:
+ Collection<Entry> lst = this.type_reference (del.type_reference);
+ foreach (Entry e in lst) {
+ api.add_child (e);
+ }
+
+ api.add_child (new String (" "+del.name));
+
+ lst = this.type_parameter_list (del);
+ if (lst != null) {
+ api.add_childs (lst);
+ }
+
+ api.add_child (new String (" "));
+
+
+ // type parameters
+ api.add_child (this.parameter_list (del));
+ Entry? exceptions = this.exceptions (del);
+ if (exceptions != null) {
+ api.add_child (exceptions);
+ }
+
+ api.add_child (new String(";"));
+ return api;
+ }
+
+ public Div from_signal (Signal sig) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+
+ api.add_child (this.keyword(this.symbol_accessibility (sig) + " signal "));
+
+ // return type:
+ Collection<Entry> lst = this.type_reference (sig.type_reference);
+ foreach (Entry e in lst) {
+ api.add_child (e);
+ }
+
+ api.add_child (new String (" "+sig.name+" "));
+ // type parameters
+ api.add_child (this.parameter_list (sig));
+ api.add_child (new String(";"));
+ return api;
+ }
+
+ public Div from_field (Field field) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+ StringBuilder str = new StringBuilder (this.symbol_accessibility (field));
+ str.append_c (' ');
+
+ if (field.is_volatile) {
+ str.append ("volatile ");
+ }
+
+ if (field.is_static) {
+ str.append ("static ");
+ }
+
+ api.add_child (this.keyword (str.str));
+
+ foreach (Entry e in this.type_reference (field.type_reference)) {
+ api.add_child (e);
+ }
+
+ api.add_child (new String(" "+field.name+";"));
+ return api;
+ }
+
+ public Div from_constant (Constant c) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+ api.add_child (this.keyword (this.symbol_accessibility (c)+" const "));
+
+ foreach (Entry e in this.type_reference (c.type_reference)) {
+ api.add_child (e);
+ }
+
+ api.add_child (new String(" "+c.name+";"));
+ return api;
+ }
+
+ public Div from_namespace (Namespace ns) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+ api.add_child (this.keyword ("namespace "));
+ api.add_child (new String (ns.name+";"));
+ return api;
+ }
+
+ public Div from_enum (Enum en) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+ api.add_child (this.keyword (this.symbol_accessibility (en) + " enum "));
+ api.add_child (new String (en.name+";"));
+ return api;
+ }
+
+ public Div from_errordomain (ErrorDomain err) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+ api.add_child (this.keyword (this.symbol_accessibility (err) + " errordomain "));
+ api.add_child (new String (err.name+";"));
+ return api;
+ }
+
+ public Div from_enumvalue (EnumValue env) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+ api.add_child (new String (env.name));
+ return api;
+ }
+
+ public Div from_errorcode (ErrorCode errc) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+ api.add_child (new String (errc.name));
+ return api;
+ }
+
+ public Div from_struct (Struct stru) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+ api.add_child (this.keyword (this.symbol_accessibility (stru) + " struct "));
+ api.add_child (new String (stru.name));
+
+ Collection<Entry> lst = this.type_parameter_list (stru);
+ if (lst != null) {
+ api.add_childs (lst);
+ }
+
+ api.add_child (new String (";"));
+ return api;
+ }
+
+ public Div from_class (Class cl) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+ StringBuilder str = new StringBuilder (this.symbol_accessibility (cl));
+ if (cl.is_abstract) {
+ str.append (" abstract");
+ }
+
+ str.append (" class ");
+
+ api.add_child (this.keyword(str.str));
+ str = null;
+
+ api.add_child (new String (cl.name));
+
+ Collection<Entry> lst = this.type_parameter_list (cl);
+ if (lst != null) {
+ api.add_childs (lst);
+ }
+
+ api.add_child (new String (";"));
+ return api;
+ }
+
+ public Div from_interface (Interface iface) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+
+ api.add_child (this.keyword (this.symbol_accessibility (iface)+" interface "));
+ api.add_child (new String (iface.name));
+
+ Collection<Entry> lst = this.type_parameter_list (iface);
+ if (lst != null) {
+ api.add_childs (lst);
+ }
+
+ api.add_child (new String (";"));
+ return api;
+ }
+
+ private Entry from_property_accessor (PropertyAccessor propac) {
+ StringBuilder str = new StringBuilder ();
+
+ if (propac.is_private) {
+ str.append ("private ");
+ }
+ else if (propac.is_public) {
+ str.append ("public ");
+ }
+ else {
+ str.append ("protected ");
+ }
+
+ if (propac.is_owned) {
+ str.append ("owned ");
+ }
+
+ if (propac.is_get ) {
+ str.append ("get ");
+ }
+ else {
+ str.append ("set ");
+ }
+
+ Span span = new Span ();
+ span.add_child (this.keyword (str.str));
+ span.add_child (new String ("; "));
+ return span;
+ }
+
+ public Div from_property (Property prop) {
+ Div api = new Div ();
+ api.add_attribute (cssapi);
+
+
+ StringBuilder str = new StringBuilder (this.symbol_accessibility (prop));
+ if (prop.is_virtual) {
+ str.append ( " virtual " );
+ }
+ else if (prop.is_abstract) {
+ str.append ( " abstract " );
+ }
+ else {
+ str.append ( " override " );
+ }
+
+ api.add_child (this.keyword (str.str));
+
+ foreach (Entry e in this.type_reference (prop.type_reference)) {
+ api.add_child (e);
+ }
+
+ api.add_child (new String(" "+prop.name+" { "));
+ if (prop.setter != null) {
+ api.add_child(from_property_accessor (prop.setter));
+ }
+
+ if (prop.getter != null) {
+ api.add_child(from_property_accessor (prop.getter));
+ }
+
+ api.add_child (new String("}"));
+ return api;
+ }
+
+ public Div from_documented_element (DocumentedElement el) {
+ if (el is Method) {
+ return this.from_method ((Method)el);
+ }
+ else if (el is Delegate) {
+ return this.from_delegate ((Delegate)el);
+ }
+ else if (el is Signal) {
+ return this.from_signal ((Signal)el);
+ }
+ else if (el is Field) {
+ return this.from_field ((Field)el);
+ }
+ else if (el is Constant) {
+ return this.from_constant ((Constant)el);
+ }
+ else if (el is Namespace) {
+ return this.from_namespace ((Namespace)el);
+ }
+ else if (el is Enum) {
+ return this.from_enum ((Enum)el);
+ }
+ else if (el is ErrorDomain) {
+ return this.from_errordomain ((ErrorDomain)el);
+ }
+ else if (el is EnumValue) {
+ return this.from_enumvalue ((EnumValue)el);
+ }
+ else if (el is ErrorCode) {
+ return this.from_errorcode ((ErrorCode)el);
+ }
+ else if (el is Struct) {
+ return this.from_struct ((Struct)el);
+ }
+ else if (el is Class) {
+ return this.from_class ((Class)el);
+ }
+ else if (el is Interface) {
+ return this.from_interface ((Interface)el);
+ }
+ else {
+ return this.from_property ((Property)el);
+ }
+ }
+}
+
+
diff --git a/src/doclets/valadoc.org/doclet/Makefile.am b/src/doclets/valadoc.org/doclet/Makefile.am
index 5953bf8..0545451 100644
--- a/src/doclets/valadoc.org/doclet/Makefile.am
+++ b/src/doclets/valadoc.org/doclet/Makefile.am
@@ -12,7 +12,7 @@ BUILT_SOURCES = libdoclet.vala.stamp
libdoclet.vala.stamp: $(libdoclet_VALASOURCES)
- $(VALAC) -C --vapidir ../../../vapi --pkg mysql --pkg valadoc-1.0 --basedir . --save-temps $^
+ $(VALAC) -C --vapidir ../../htmlhelpers/html/ --pkg htmlwriter-1.0 --vapidir ../../htmlhelpers/languages/ --pkg apiwriter-1.0 --pkg valadoc-1.0 --basedir . --save-temps $^
touch $@
@@ -31,11 +31,13 @@ libdoclet_la_SOURCES = \
-AM_CFLAGS = -g \
- -I ../../../libvaladoc/ \
- `mysql_config --cflags` \
- $(GLIB_CFLAGS) \
- $(LIBVALA_CFLAGS) \
+AM_CFLAGS = -g \
+ -I ../../../libvaladoc/ \
+ -I ../../htmlhelpers/html \
+ -I ../../htmlhelpers/languages \
+ `mysql_config --cflags` \
+ $(GLIB_CFLAGS) \
+ $(LIBVALA_CFLAGS) \
$(NULL)
@@ -44,10 +46,12 @@ libdoclet_la_LDFLAGS = -module -avoid-version \
$(NULL)
-libdoclet_la_LIBADD = \
- ../../../libvaladoc/libvaladoc.la \
- $(GLIB_LIBS) \
- $(LIBVALA_LIBS) \
+libdoclet_la_LIBADD = \
+ ../../../libvaladoc/libvaladoc.la \
+ ../../htmlhelpers/html/libhtmlwriter.la \
+ ../../htmlhelpers/languages/libapiwriter.la \
+ $(GLIB_LIBS) \
+ $(LIBVALA_LIBS) \
$(NULL)
diff --git a/src/doclets/valadoc.org/doclet/template.vala b/src/doclets/valadoc.org/doclet/template.vala
index 3669dfa..360559c 100644
--- a/src/doclets/valadoc.org/doclet/template.vala
+++ b/src/doclets/valadoc.org/doclet/template.vala
@@ -17,14 +17,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+using Valadoc.Diagrams;
+using Valadoc.Html;
using Valadoc;
-using Mysql;
using GLib;
using Gee;
public class Valadoc.HtmlDoclet : Valadoc.Doclet {
+ private Valadoc.Html.Api.Vala langwriter = new Valadoc.Html.Api.Vala ();
private Settings settings;
private FileStream file;
private bool run;
@@ -46,6 +48,10 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
}
}
+ private string get_image_path (DocumentedElement element) {
+ return Path.build_filename (this.settings.path, element.package.name, element.package.name, element.full_name () + ".png");
+ }
+
// get_type_path()
private void write_insert_into_valadoc_element_str (string name, string pkgname, string fullname) {
string fullname2 = (pkgname == fullname)? pkgname : pkgname+"/"+fullname;
@@ -81,11 +87,9 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
// get_type_path()
private void write_insert_into_code_element (DocumentedElement element) {
- string api = "foo bar foobaro";
+ string api = this.langwriter.from_documented_element (element).to_string (0, "");
string parentnodepkgname;
string parentnodename;
- string typename;
- string cname;
Basic parent = element.parent;
if (parent is DocumentedElement) {
@@ -111,6 +115,11 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
return ;
}
+ if (GLib.DirUtils.create (Path.build_filename(path, pkg.name), 0777) == -1) {
+ this.run = false;
+ return ;
+ }
+
path = Path.build_filename(path, "dump.sql");
this.file = FileStream.open (path , "w");
if (this.file == null) {
@@ -234,6 +243,8 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
}
public override void visit_interface ( Interface iface ) {
+ write_interface_diagram (iface, this.get_image_path (iface));
+
this.write_insert_into_valadoc_element (iface);
if (this.run == false) {
return ;
@@ -312,6 +323,8 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
}
public override void visit_class ( Class cl ) {
+ write_class_diagram (cl, this.get_image_path (cl));
+
this.write_insert_into_valadoc_element (cl);
if (this.run == false) {
return ;
@@ -322,6 +335,14 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
return ;
}
+ foreach (Method m in cl.get_construction_method_list ()) {
+ m.visit(this, cl);
+
+ if (this.run == false) {
+ return ;
+ }
+ }
+
foreach (Delegate del in cl.get_delegate_list()) {
del.visit(this);
@@ -406,6 +427,8 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
}
public override void visit_struct ( Struct stru ) {
+ write_struct_diagram (stru, this.get_image_path (stru));
+
this.write_insert_into_valadoc_element (stru);
if (this.run == false) {
return ;
@@ -416,6 +439,14 @@ public class Valadoc.HtmlDoclet : Valadoc.Doclet {
return ;
}
+ foreach (Method m in stru.get_construction_method_list ()) {
+ m.visit(this, stru);
+
+ if (this.run == false) {
+ return ;
+ }
+ }
+
foreach (Method m in stru.get_method_list()) {
m.visit(this, stru);
diff --git a/src/libvaladoc/apitree.vala b/src/libvaladoc/apitree.vala
index 354fd14..e608f11 100755
--- a/src/libvaladoc/apitree.vala
+++ b/src/libvaladoc/apitree.vala
@@ -611,7 +611,6 @@ public interface Valadoc.NamespaceHandler : Basic {
return ns.get_namespace_helper ( node, vnspaces, pos+1 );
}
- // TODO: Rename vars
protected Namespace get_namespace ( Vala.Symbol node ) {
Vala.Symbol vnd = ((Vala.Symbol)node).parent_symbol;
if ( vnd is Vala.Namespace == false )
@@ -1704,14 +1703,6 @@ public class Valadoc.TypeReference : Basic {
return this.is_weak_helper ( ((Vala.FormalParameter)parent).parameter_type );
}
- // return type
- if ( parent is Vala.Method == true )
- return this.is_weak_helper ( ((Vala.Method)parent).return_type );
- else if ( parent is Vala.Signal == true )
- return this.is_weak_helper ( ((Vala.Signal)parent).return_type );
- else if ( parent is Vala.Delegate == true )
- return this.is_weak_helper ( ((Vala.Delegate)parent).return_type );
-
return false;
}
}
@@ -1744,6 +1735,22 @@ public class Valadoc.TypeReference : Basic {
public bool is_weak {
get {
+ Vala.CodeNode parent = this.vtyperef.parent_node;
+
+ if (parent is Vala.FormalParameter) {
+ return false;
+ }
+
+ if (parent is Vala.Method == true) {
+ return this.is_weak_helper ( ((Vala.Method)parent).return_type );
+ }
+ else if (parent is Vala.Signal == true) {
+ return this.is_weak_helper ( ((Vala.Signal)parent).return_type );
+ }
+ else if (parent is Vala.Delegate == true) {
+ return this.is_weak_helper ( ((Vala.Delegate)parent).return_type );
+ }
+
return ( this.vtyperef.parent_node is Field )? this.is_weak_helper( this.vtyperef ) : false;
}
}
@@ -2221,11 +2228,8 @@ public class Valadoc.Method : DocumentedElement, ParameterListHandler, Exception
var vparamlst = this.vmethod.get_parameters ();
this.add_parameter_list ( vparamlst );
-// var vtparams = this.vmethod.get_type_parameters ();
-// this.set_template_parameter_list ( vtparams );
-
- //var vexceptionlst = this.vmethod.get_error_types ();
- //this.add_error_domains ( vexceptionlst );
+ var vtparams = this.vmethod.get_type_parameters ();
+ this.set_template_parameter_list ( vtparams );
}
// intern
@@ -4111,6 +4115,7 @@ public class Valadoc.Tree : Vala.CodeVisitor {
private Valadoc.Settings settings;
private CodeContext context;
private ErrorReporter reporter;
+ private Package sourcefiles = null;
public WikiPageTree? wikitree {
private set;
@@ -4233,8 +4238,8 @@ public class Valadoc.Tree : Vala.CodeVisitor {
return ;
Vala.SourceFile vfile = vcl.source_reference.file;
- Package file = this.find_file( vfile );
- Namespace ns = file.get_namespace ( vcl );
+ Package file = this.find_file(vfile);
+ Namespace ns = file.get_namespace (vcl);
ns.add_class ( vcl );
}
@@ -4448,8 +4453,15 @@ public class Valadoc.Tree : Vala.CodeVisitor {
var rpath = realpath (source);
if (source.has_suffix (".vala") || source.has_suffix (".gs")) {
var source_file = new SourceFile (context, rpath);
- Package vdpkg = new Package (this.settings, source_file, this, false);
- this.packages.add (vdpkg);
+
+
+ if (this.sourcefiles == null) {
+ this.sourcefiles = new Package (this.settings, source_file, this, false);
+ this.packages.add (this.sourcefiles);
+ }
+ else {
+ this.sourcefiles.add_file (source_file);
+ }
if (context.profile == Profile.POSIX) {
// import the Posix namespace by default (namespace of backend-specific standard library)
diff --git a/src/vapi/valadoc-1.2.0.deps b/src/vapi/valadoc-1.2.0.deps
new file mode 100644
index 0000000..5871359
--- /dev/null
+++ b/src/vapi/valadoc-1.2.0.deps
@@ -0,0 +1,2 @@
+vala-1.0
+libgvc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]