]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Various cleanups
authorFlorian Brosch <flo.brosch@gmail.com>
Thu, 1 Sep 2011 15:29:22 +0000 (17:29 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Thu, 1 Sep 2011 15:29:22 +0000 (17:29 +0200)
14 files changed:
configure.in
src/driver/0.10.x/treebuilder.vala
src/driver/0.11.0/treebuilder.vala
src/driver/0.11.x/treebuilder.vala
src/driver/0.12.x/treebuilder.vala
src/driver/0.13.x/treebuilder.vala
src/libvaladoc/ctyperesolver.vala
src/libvaladoc/documentation/documentationparser.vala
src/libvaladoc/html/basicdoclet.vala
src/libvaladoc/html/linkhelper.vala
src/libvaladoc/importer/valadocdocumentationimporter.vala
src/libvaladoc/markupreader.vala
src/libvaladoc/markuptokentype.vala
src/libvaladoc/taglets/tagletlink.vala

index 0fa3cd4f21aaa52039fdc7c85a7a4d6a85cc4c39..40cafa4b57adcab80887593036526f7af77c5c90 100755 (executable)
@@ -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
index 19b544f56e1b5e3e2f2b1e7d907f7ef75ffba900..c3543a52eed0a166dd18c6572e6454b3d836ec35 100644 (file)
@@ -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) {
index 93c5f3c4a08438d842ba65b52686ad0a3f01fc30..6ebc8713a4bcc4c4d82cfd7f41989a2eeb126938 100644 (file)
@@ -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));
index d64c2c92385231fd64d730ae2a37930d918d50e9..f297a1eda541aa16ce7e2aa8472fcf073b4037c6 100644 (file)
@@ -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));
index 3099ceb23be05f202855df53019b81dfb983e01a..455a0e67ec5eb0cd864b377d77d9435e62224c4c 100644 (file)
@@ -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));
index ba4ca7cc6bbfeeb964441866541092fc7c4c0da3..74f42c5e690b13b860f9ccc1f6fb0d330c45b135 100644 (file)
@@ -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));
index e34d695bf0cb823a25083bf263d0cc1f162ebe61..87fc6f3442d3013f0e3901edc6e804344f0eca01 100755 (executable)
@@ -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);
        }
 
index ddafabcd3555ee1255a42819f91c762193450993..92aa69865b8d6009077709fc7e85910cdc5c1a86 100755 (executable)
@@ -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 })
                                })
index 0e7734b31ac0f85737427191fa79bbe5f871368a..aa1c3e4a0b902e5f33d1afab01d5be122516f067 100755 (executable)
@@ -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);
index 1915182d82694b79ddbad928c7f18acc63f92c32..2d2968668739560c24cbc062da94edbecf97f398 100755 (executable)
@@ -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;
                }
 
index 43e83aa77fdd957559a964889a95ad1a5964b679..d0cdb84e758e1b658506bf18ff4f383191a138be 100755 (executable)
@@ -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 ;
                }
 
index b4bf82fb27d0a299631c46d46008ee310b958da6..626508e1a2d1081fedd2c80b487ba7e1325df982 100644 (file)
@@ -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);
                                }
index 5bd86d9bf47b52916d95f4d57ef7d1b3e5814637..d2dcad74fad051ec30be62ad68663921dee6bdf3 100644 (file)
@@ -23,6 +23,7 @@
 
 public enum Valadoc.MarkupTokenType {
        NONE,
+       COMMENT,
        START_ELEMENT,
        END_ELEMENT,
        TEXT,
index b0b395071d61f5d86098851c383f11f8e2c295e8..93ba7ab6e65fd9b06823341a1429473de39898da 100755 (executable)
@@ -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);