[valadoc] Various cleanups
- From: Florian Brosch <flobrosch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] Various cleanups
- Date: Thu, 3 Nov 2011 02:37:14 +0000 (UTC)
commit 0e90facc5014282a641fa99df3439bfa3fc8b3c9
Author: Florian Brosch <flo brosch gmail com>
Date: Thu Sep 1 17:29:22 2011 +0200
Various cleanups
configure.in | 2 +-
src/driver/0.10.x/treebuilder.vala | 9 ++-
src/driver/0.11.0/treebuilder.vala | 10 ++-
src/driver/0.11.x/treebuilder.vala | 10 ++-
src/driver/0.12.x/treebuilder.vala | 10 ++-
src/driver/0.13.x/treebuilder.vala | 10 ++-
src/libvaladoc/ctyperesolver.vala | 109 ++++++++++++++++++--
.../documentation/documentationparser.vala | 5 +-
src/libvaladoc/html/basicdoclet.vala | 3 +-
src/libvaladoc/html/linkhelper.vala | 20 +++--
.../importer/valadocdocumentationimporter.vala | 5 +-
src/libvaladoc/markupreader.vala | 17 +++
src/libvaladoc/markuptokentype.vala | 1 +
src/libvaladoc/taglets/tagletlink.vala | 12 ++-
14 files changed, 197 insertions(+), 26 deletions(-)
---
diff --git a/configure.in b/configure.in
index 0fa3cd4..40cafa4 100755
--- a/configure.in
+++ b/configure.in
@@ -18,7 +18,7 @@ AC_PROG_LIBTOOL
## Settings:
##
-VALA_REQUIRED=0.13.1.56
+VALA_REQUIRED=0.13.2
LIBGEE_REQUIRED=0.5
LIBGVC_REQUIRED=2.16
GLIB_REQUIRED=2.12.0
diff --git a/src/driver/0.10.x/treebuilder.vala b/src/driver/0.10.x/treebuilder.vala
index 19b544f..c3543a5 100644
--- a/src/driver/0.10.x/treebuilder.vala
+++ b/src/driver/0.10.x/treebuilder.vala
@@ -479,11 +479,18 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
//
private bool add_package (Vala.CodeContext context, string pkg) {
+ // ignore multiple occurences of the same package
if (context.has_package (pkg)) {
- // ignore multiple occurences of the same package
return true;
}
+ string vapi_name = pkg + ".vapi";
+ foreach (string source_file in settings.source_files) {
+ if (Path.get_basename (source_file) == vapi_name) {
+ return true;
+ }
+ }
+
var package_path = context.get_package_path (pkg, settings.vapi_directories) ?? context.get_gir_path (pkg, settings.vapi_directories);
if (package_path == null) {
diff --git a/src/driver/0.11.0/treebuilder.vala b/src/driver/0.11.0/treebuilder.vala
index 93c5f3c..6ebc871 100644
--- a/src/driver/0.11.0/treebuilder.vala
+++ b/src/driver/0.11.0/treebuilder.vala
@@ -481,11 +481,19 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
//
private bool add_package (Vala.CodeContext context, string pkg) {
+ // ignore multiple occurences of the same package
if (context.has_package (pkg)) {
- // ignore multiple occurences of the same package
return true;
}
+ string vapi_name = pkg + ".vapi";
+ foreach (string source_file in settings.source_files) {
+ if (Path.get_basename (source_file) == vapi_name) {
+ return true;
+ }
+ }
+
+
var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg);
if (package_path == null) {
Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg));
diff --git a/src/driver/0.11.x/treebuilder.vala b/src/driver/0.11.x/treebuilder.vala
index d64c2c9..f297a1e 100644
--- a/src/driver/0.11.x/treebuilder.vala
+++ b/src/driver/0.11.x/treebuilder.vala
@@ -432,11 +432,19 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
//
private bool add_package (Vala.CodeContext context, string pkg) {
+ // ignore multiple occurences of the same package
if (context.has_package (pkg)) {
- // ignore multiple occurences of the same package
return true;
}
+ string vapi_name = pkg + ".vapi";
+ foreach (string source_file in settings.source_files) {
+ if (Path.get_basename (source_file) == vapi_name) {
+ return true;
+ }
+ }
+
+
var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg);
if (package_path == null) {
Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg));
diff --git a/src/driver/0.12.x/treebuilder.vala b/src/driver/0.12.x/treebuilder.vala
index 3099ceb..455a0e6 100644
--- a/src/driver/0.12.x/treebuilder.vala
+++ b/src/driver/0.12.x/treebuilder.vala
@@ -481,11 +481,19 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
//
private bool add_package (Vala.CodeContext context, string pkg) {
+ // ignore multiple occurences of the same package
if (context.has_package (pkg)) {
- // ignore multiple occurences of the same package
return true;
}
+ string vapi_name = pkg + ".vapi";
+ foreach (string source_file in settings.source_files) {
+ if (Path.get_basename (source_file) == vapi_name) {
+ return true;
+ }
+ }
+
+
var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg);
if (package_path == null) {
Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg));
diff --git a/src/driver/0.13.x/treebuilder.vala b/src/driver/0.13.x/treebuilder.vala
index ba4ca7c..74f42c5 100644
--- a/src/driver/0.13.x/treebuilder.vala
+++ b/src/driver/0.13.x/treebuilder.vala
@@ -600,11 +600,19 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
//
private bool add_package (Vala.CodeContext context, string pkg) {
+ // ignore multiple occurences of the same package
if (context.has_package (pkg)) {
- // ignore multiple occurences of the same package
return true;
}
+ string vapi_name = pkg + ".vapi";
+ foreach (string source_file in settings.source_files) {
+ if (Path.get_basename (source_file) == vapi_name) {
+ return true;
+ }
+ }
+
+
var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg);
if (package_path == null) {
Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg));
diff --git a/src/libvaladoc/ctyperesolver.vala b/src/libvaladoc/ctyperesolver.vala
index e34d695..87fc6f3 100755
--- a/src/libvaladoc/ctyperesolver.vala
+++ b/src/libvaladoc/ctyperesolver.vala
@@ -40,13 +40,40 @@ public class Valadoc.CTypeResolver : Visitor {
* @param name a C-name
* @return the resolved node or null
*/
- public Api.Node? resolve_symbol (string name) {
- return nodes.get (name);
+ public Api.Node? resolve_symbol (string _name) {
+ string name = _name.replace ("-", "_");
+
+ Api.Node? node = nodes.get (name);
+ if (node != null) {
+ return node;
+ }
+
+ var name_length = name.length;
+ if (name_length > 5 && name.has_suffix ("Class")) {
+ return nodes.get (name.substring (0, name_length - 5));
+ }
+
+ /*
+ for (int i = 0; name[i] != '\0' ; i++) {
+ if (name[i] == ':' && name[i+1] == ':') {
+ string first_part = name.substring (0, i - 1);
+ string second_part = name.substring (i + 2, -1);
+ string nick = first_part + ":" + second_part;
+ return nodes.get (nick);
+ } else if (name[i] == ':') {
+ string first_part = name.substring (0, i);
+ string second_part = name.substring (i + 1, -1);
+ string nick = first_part + "::" + second_part;
+ return nodes.get (nick);
+ }
+ } */
+
+ return null;
}
private void register_symbol (string? name, Api.Node node) {
if (name != null) {
- nodes.set (name, node);
+ nodes.set (name.replace ("-", "_"), node);
}
}
@@ -118,8 +145,29 @@ public class Valadoc.CTypeResolver : Visitor {
*/
public override void visit_property (Property item) {
string parent_cname = get_parent_type_cname (item);
- if (parent_cname != null) {
- register_symbol (parent_cname+":"+item.get_cname (), item);
+ assert (parent_cname != null);
+
+ string cname = item.get_cname ();
+ register_symbol (parent_cname+":"+cname, item);
+
+
+ Collection<Interface> interfaces = null;
+ Collection<Class> classes = null;
+
+ if (item.parent is Interface) {
+ interfaces = ((Api.Interface) item.parent).get_known_related_interfaces ();
+ classes = ((Api.Interface) item.parent).get_known_implementations ();
+ } else if (item.parent is Class) {
+ interfaces = ((Api.Class) item.parent).get_known_derived_interfaces ();
+ classes = ((Api.Class) item.parent).get_known_child_classes ();
+ }
+
+ foreach (Interface iface in interfaces) {
+ register_symbol (iface.get_cname () + ":" + cname, item);
+ }
+
+ foreach (Class cl in classes) {
+ register_symbol (cl.get_cname () + ":" + cname, item);
}
}
@@ -127,7 +175,7 @@ public class Valadoc.CTypeResolver : Visitor {
* { inheritDoc}
*/
public override void visit_field (Field item) {
- if (item is Namespace) {
+ if (item.parent is Namespace || item.is_static) {
register_symbol (item.get_cname (), item);
} else {
string parent_cname = get_parent_type_cname (item);
@@ -156,8 +204,29 @@ public class Valadoc.CTypeResolver : Visitor {
*/
public override void visit_signal (Api.Signal item) {
string parent_cname = get_parent_type_cname (item);
- if (parent_cname != null) {
- register_symbol (parent_cname+"::"+item.get_cname (), item);
+ assert (parent_cname != null);
+
+ string cname = item.get_cname ();
+ register_symbol (parent_cname+"::"+cname, item);
+
+
+ Collection<Interface> interfaces = null;
+ Collection<Class> classes = null;
+
+ if (item.parent is Interface) {
+ interfaces = ((Api.Interface) item.parent).get_known_related_interfaces ();
+ classes = ((Api.Interface) item.parent).get_known_implementations ();
+ } else if (item.parent is Class) {
+ interfaces = ((Api.Class) item.parent).get_known_derived_interfaces ();
+ classes = ((Api.Class) item.parent).get_known_child_classes ();
+ }
+
+ foreach (Interface iface in interfaces) {
+ register_symbol (iface.get_cname () + "::" + cname, item);
+ }
+
+ foreach (Class cl in classes) {
+ register_symbol (cl.get_cname () + "::" + cname, item);
}
}
@@ -165,6 +234,30 @@ public class Valadoc.CTypeResolver : Visitor {
* { inheritDoc}
*/
public override void visit_method (Method item) {
+ if (item.is_abstract || item.is_virtual || item.is_override) {
+ string parent_cname = get_parent_type_cname (item);
+ register_symbol (parent_cname + "->" + item.name, item);
+
+ Collection<Interface> interfaces = null;
+ Collection<Class> classes = null;
+
+ if (item.parent is Interface) {
+ interfaces = ((Api.Interface) item.parent).get_known_related_interfaces ();
+ classes = ((Api.Interface) item.parent).get_known_implementations ();
+ } else if (item.parent is Class) {
+ interfaces = ((Api.Class) item.parent).get_known_derived_interfaces ();
+ classes = ((Api.Class) item.parent).get_known_child_classes ();
+ }
+
+ foreach (Interface iface in interfaces) {
+ register_symbol (iface.get_cname () + "->" + item.name, item);
+ }
+
+ foreach (Class cl in classes) {
+ register_symbol (cl.get_cname () + "->" + item.name, item);
+ }
+ }
+
register_symbol (item.get_cname (), item);
}
diff --git a/src/libvaladoc/documentation/documentationparser.vala b/src/libvaladoc/documentation/documentationparser.vala
index ddafabc..92aa698 100755
--- a/src/libvaladoc/documentation/documentationparser.vala
+++ b/src/libvaladoc/documentation/documentationparser.vala
@@ -270,6 +270,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
TokenType.BREAK.action ((token) => { add_content_string ("\n"); }),
TokenType.CLOSED_BRACE.action (add_text),
TokenType.MINUS.action (add_text),
+ TokenType.ALIGN_BOTTOM.action (add_text),
TokenType.ALIGN_TOP.action (add_text),
TokenType.GREATER_THAN.action (add_text),
TokenType.LESS_THAN.action (add_text),
@@ -713,7 +714,9 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
Rule comment =
Rule.seq ({
TokenType.EOL,
- description,
+ Rule.option ({
+ description
+ }),
Rule.option ({
Rule.many ({ taglet })
})
diff --git a/src/libvaladoc/html/basicdoclet.vala b/src/libvaladoc/html/basicdoclet.vala
index 0e7734b..aa1c3e4 100755
--- a/src/libvaladoc/html/basicdoclet.vala
+++ b/src/libvaladoc/html/basicdoclet.vala
@@ -34,6 +34,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
protected Html.CssClassResolver cssresolver;
protected Charts.Factory image_factory;
+ protected string package_list_link = "../index.html";
// CSS:
private const string css_inline_navigation = "navi_inline";
@@ -238,7 +239,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
Gee.ArrayList<Api.Node> lst = new Gee.ArrayList<Api.Node> ();
Api.Node pos = element;
- this.write_top_element_template ("../index.html");
+ this.write_top_element_template (package_list_link);
while (pos != null) {
lst.add (pos);
diff --git a/src/libvaladoc/html/linkhelper.vala b/src/libvaladoc/html/linkhelper.vala
index 1915182..2d29686 100755
--- a/src/libvaladoc/html/linkhelper.vala
+++ b/src/libvaladoc/html/linkhelper.vala
@@ -27,8 +27,14 @@ using Gee;
public class Valadoc.Html.LinkHelper : Object {
private Settings _settings = null;
+ public bool enable_browsable_check {
+ default = true;
+ get;
+ set;
+ }
+
public string? get_package_link (Api.Package package, Settings settings) {
- if (!package.is_browsable (settings)) {
+ if (enable_browsable_check && !package.is_browsable (settings)) {
return null;
}
@@ -85,7 +91,7 @@ public class Valadoc.Html.LinkHelper : Object {
protected virtual string? from_package_to_package (Api.Package from, Api.Package to) {
- if (!to.is_browsable(_settings)) {
+ if (enable_browsable_check && !to.is_browsable(_settings)) {
return null;
}
@@ -105,7 +111,7 @@ public class Valadoc.Html.LinkHelper : Object {
}
protected virtual string? from_package_to_node (Api.Package from, Api.Node to) {
- if (!to.is_browsable(_settings) || !to.package.is_browsable (_settings)) {
+ if (enable_browsable_check && (!to.is_browsable(_settings) || !to.package.is_browsable (_settings))) {
return null;
}
@@ -119,7 +125,7 @@ public class Valadoc.Html.LinkHelper : Object {
protected virtual string? from_wiki_to_package (WikiPage from, Api.Package to) {
- if (!to.is_browsable(_settings)) {
+ if (enable_browsable_check && !to.is_browsable(_settings)) {
return null;
}
@@ -143,7 +149,7 @@ public class Valadoc.Html.LinkHelper : Object {
}
protected virtual string? from_wiki_to_node (WikiPage from, Api.Node to) {
- if (!to.is_browsable(_settings) || !to.package.is_browsable (_settings)) {
+ if (enable_browsable_check && (!to.is_browsable(_settings) || !to.package.is_browsable (_settings))) {
return null;
}
@@ -157,7 +163,7 @@ public class Valadoc.Html.LinkHelper : Object {
protected virtual string? from_node_to_package (Api.Node from, Api.Package to) {
- if (!to.is_browsable (_settings)) {
+ if (enable_browsable_check && !to.is_browsable (_settings)) {
return null;
}
@@ -177,7 +183,7 @@ public class Valadoc.Html.LinkHelper : Object {
}
protected virtual string? from_node_to_node (Api.Node from, Api.Node to) {
- if (!to.is_browsable(_settings) || !to.package.is_browsable (_settings)) {
+ if (enable_browsable_check && (!to.is_browsable(_settings) || !to.package.is_browsable (_settings))) {
return null;
}
diff --git a/src/libvaladoc/importer/valadocdocumentationimporter.vala b/src/libvaladoc/importer/valadocdocumentationimporter.vala
index 43e83aa..d0cdb84 100755
--- a/src/libvaladoc/importer/valadocdocumentationimporter.vala
+++ b/src/libvaladoc/importer/valadocdocumentationimporter.vala
@@ -122,7 +122,10 @@ public class Valadoc.Importer.ValadocDocumentationImporter : DocumentationImport
}
if (symbol == null) {
- reporter.simple_warning ("%s does not exist", symbol_name);
+ if (settings.verbose) {
+ reporter.simple_warning ("Node %s does not exist", symbol_name);
+ }
+
return ;
}
diff --git a/src/libvaladoc/markupreader.vala b/src/libvaladoc/markupreader.vala
index b4bf82f..626508e 100644
--- a/src/libvaladoc/markupreader.vala
+++ b/src/libvaladoc/markupreader.vala
@@ -58,6 +58,18 @@ public class Valadoc.MarkupReader : Object {
private ErrorReporter reporter;
+ public MarkupReader.from_string (string filename, string content, ErrorReporter reporter) {
+ this.filename = filename;
+ this.reporter = reporter;
+
+ begin = content;
+ end = begin + content.size ();
+ current = begin;
+
+ column = 1;
+ line = 1;
+ }
+
public MarkupReader (string filename, ErrorReporter reporter) {
this.filename = filename;
this.reporter = reporter;
@@ -258,6 +270,11 @@ public class Valadoc.MarkupReader : Object {
content.append_c ('>');
current += 4;
text_begin = current;
+ } else if (((string) next_pos).has_prefix ("percnt;")) {
+ content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
+ content.append_c ('>');
+ current += 8;
+ text_begin = current;
} else {
current += u.to_utf8 (null);
}
diff --git a/src/libvaladoc/markuptokentype.vala b/src/libvaladoc/markuptokentype.vala
index 5bd86d9..d2dcad7 100644
--- a/src/libvaladoc/markuptokentype.vala
+++ b/src/libvaladoc/markuptokentype.vala
@@ -23,6 +23,7 @@
public enum Valadoc.MarkupTokenType {
NONE,
+ COMMENT,
START_ELEMENT,
END_ELEMENT,
TEXT,
diff --git a/src/libvaladoc/taglets/tagletlink.vala b/src/libvaladoc/taglets/tagletlink.vala
index b0b3950..93ba7ab 100755
--- a/src/libvaladoc/taglets/tagletlink.vala
+++ b/src/libvaladoc/taglets/tagletlink.vala
@@ -32,7 +32,15 @@ public class Valadoc.Taglets.Link : InlineTaglet {
public override Rule? get_parser_rule (Rule run_rule) {
return Rule.seq ({
Rule.option ({ Rule.many ({ TokenType.SPACE }) }),
- TokenType.any_word ().action ((token) => { symbol_name = token.to_string (); })
+ TokenType.any_word ().action ((token) => { symbol_name = token.to_string (); }),
+ Rule.option ({
+ Rule.many ({
+ Rule.one_of ({
+ TokenType.any_word ().action ((token) => { symbol_name += token.to_string (); }),
+ TokenType.MINUS.action ((token => { symbol_name += token.to_string (); }))
+ })
+ })
+ })
});
}
@@ -49,7 +57,7 @@ public class Valadoc.Taglets.Link : InlineTaglet {
if (_symbol == null) {
// TODO use ContentElement's source reference
- reporter.simple_warning ("%s does not exist", symbol_name);
+ reporter.simple_warning ("%s: %s does not exist", container.get_full_name (), symbol_name);
}
base.check (api_root, container, reporter, settings);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]