]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Allow to inherit from imported docs
authorFlorian Brosch <flo.brosch@gmail.com>
Sat, 23 Aug 2014 18:09:08 +0000 (20:09 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Fri, 29 Aug 2014 13:52:37 +0000 (15:52 +0200)
src/libvaladoc/api/node.vala
src/libvaladoc/api/tree.vala
src/libvaladoc/content/comment.vala
src/libvaladoc/documentation/documentationparser.vala
src/libvaladoc/documentation/wiki.vala
src/libvaladoc/taglets/tagletinheritdoc.vala
src/libvaladoc/taglets/tagletlink.vala
src/valadoc/valadoc.vala

index 2cbfe7c6abff50aab1d77a43317d61c9bb26c7c8..d3ed2bdd49521f71abb76d9d8a8dd24609327848 100644 (file)
@@ -28,7 +28,7 @@ using Gee;
  * Represents a node in the api tree.
  */
 public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Comparable<Node> {
-       protected bool do_document { private set; get; default = false; }
+       protected bool do_document = false;
        private SourceFile file;
 
        /**
index e21770186a5454660b6d04e9be6d8ce5688baa5b..59f87d3b7a2e8d7674b374069ab05345d805d81a 100644 (file)
@@ -29,7 +29,7 @@ using Gee;
  * The root of the code tree.
  */
 public class Valadoc.Api.Tree {
-       private Deque<Node> unbrowsable_documentation_dependencies = new LinkedList<Node>();
+       private Deque<InheritDocContainer> inheritdocs = new LinkedList<InheritDocContainer> ();
        private ArrayList<string> external_c_files = new ArrayList<string>();
        private ArrayList<Package> packages = new ArrayList<Package>();
        private Package source_package = null;
@@ -38,6 +38,18 @@ public class Valadoc.Api.Tree {
        private CTypeResolver _cresolver = null;
        private Package _source_package;
 
+
+       private class InheritDocContainer {
+               public unowned Taglets.InheritDoc taglet;
+               public unowned Api.Node taglet_container;
+
+               public InheritDocContainer (Api.Node taglet_container, Taglets.InheritDoc taglet) {
+                       this.taglet_container = taglet_container;
+                       this.taglet = taglet;
+               }
+       }
+
+
        public void add_package(Package package) {
                this.packages.add (package);
        }
@@ -78,10 +90,6 @@ public class Valadoc.Api.Tree {
                return this.packages.read_only_view;
        }
 
-       internal bool push_unbrowsable_documentation_dependency (Api.Node node) {
-               return unbrowsable_documentation_dependencies.offer_head (node);
-       }
-
        private void add_dependencies_to_source_package () {
                if ( this.source_package != null ) {
                        ArrayList<Package> deplst = new ArrayList<Package> ();
@@ -246,11 +254,6 @@ public class Valadoc.Api.Tree {
                return _source_package;
        }
 
-       public void process_comments (DocumentationParser docparser) {
-               parse_comments (docparser);
-               check_comments (docparser);
-       }
-
        private void parse_wiki (DocumentationParser docparser) {
                this.wikitree = new WikiPageTree ();
                var pkg = get_source_package ();
@@ -260,13 +263,13 @@ public class Valadoc.Api.Tree {
        }
 
        private void check_wiki (DocumentationParser docparser) {
-               var pkg = get_source_package ();
+               Package pkg = get_source_package ();
                if (pkg != null) {
                        wikitree.check (settings, docparser, pkg);
                }
        }
 
-       private void parse_comments (DocumentationParser docparser) {
+       public void parse_comments (DocumentationParser docparser) {
                parse_wiki (docparser);
 
                foreach (Package pkg in this.packages) {
@@ -276,24 +279,30 @@ public class Valadoc.Api.Tree {
                }
        }
 
-       private void check_comments (DocumentationParser docparser) {
+       public void check_comments (DocumentationParser docparser) {
                check_wiki (docparser);
 
                foreach (Package pkg in this.packages) {
                        if (pkg.is_browsable (settings)) {
                                pkg.check_comments (settings, docparser);
+                               postprocess_inheritdoc (docparser);
                        }
                }
+       }
 
+       internal void register_inheritdoc (Api.Node container, Taglets.InheritDoc taglet) {
+               inheritdocs.add (new InheritDocContainer (container, taglet));
+       }
+
+       private void postprocess_inheritdoc (DocumentationParser docparser) {
+               while (!this.inheritdocs.is_empty) {
+                       InheritDocContainer container = this.inheritdocs.poll_head ();
 
-               // Parse & check inherited non-public comments:
-               while (!this.unbrowsable_documentation_dependencies.is_empty) {
-                       var node = this.unbrowsable_documentation_dependencies.poll_head ();
-                       node.parse_comments (settings, docparser);
-                       node.check_comments (settings, docparser);
+                       docparser.transform_inheritdoc (container.taglet_container, container.taglet);
                }
        }
 
+
        /**
         * Import documentation from various sources
         *
@@ -301,7 +310,7 @@ public class Valadoc.Api.Tree {
         * @param packages sources
         * @param import_directories List of directories where to find the files
         */
-       public void import_documentation (DocumentationImporter[] importers, string[] packages,
+       public void import_comments (DocumentationImporter[] importers, string[] packages,
                                                                          string[] import_directories)
        {
                HashSet<string> processed = new HashSet<string> ();
index f1f1d4169b5c9d3188a124b5e5e8debde4330fcd..f4ba4a09faf8a086ffbe730e3c8cc20435b30714 100644 (file)
@@ -26,8 +26,6 @@ using Gee;
 
 
 public class Valadoc.Content.Comment : BlockContent {
-       private Gee.LinkedList<InheritDoc> inheritdocs = new Gee.LinkedList<InheritDoc> ();
-
        public Gee.List<Taglet> taglets { get { return _taglets; } }
        private Gee.List<Taglet> _taglets;
 
@@ -39,10 +37,6 @@ public class Valadoc.Content.Comment : BlockContent {
                _taglets = new ArrayList<Taglet> ();
        }
 
-       internal void register_inheritdoc (InheritDoc taglet) {
-               inheritdocs.add (taglet);
-       }
-
        public override void configure (Settings settings, ResourceLocator locator) {
        }
 
@@ -62,10 +56,6 @@ public class Valadoc.Content.Comment : BlockContent {
                        element.parent = this;
                        element.check (api_root, container, file_path, reporter, settings);
                }
-
-               foreach (InheritDoc element in inheritdocs) {
-                       element.transform (api_root, container, file_path, reporter, settings);
-               }
        }
 
        public override void accept (ContentVisitor visitor) {
index d94af81c31c0d9bb0bbb4799e328c78b3a3e2748..3dde0b886dfdfa0e6d05f1fb8de6493315b7e6b7 100644 (file)
@@ -138,8 +138,25 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                comment.check (_tree, element, element.get_source_file ().get_name (), _reporter, _settings);
        }
 
-       public void check_wikipage (Api.Package package, Page page) {
-               page.check (_tree, package, package.get_source_file ().get_name (), _reporter, _settings);
+       public void check_wikipage (Api.Package package, WikiPage page) {
+               page.documentation.check (_tree, package, page.get_filename (), _reporter, _settings);
+       }
+
+       public void transform_inheritdoc (Api.Node taglet_owner, Taglets.InheritDoc taglet) {
+               if (taglet.inherited == null) {
+                       return ;
+               }
+
+
+               taglet.inherited.parse_comments (_settings, this);
+               if (taglet.inherited.documentation == null) {
+                       return ;
+               }
+
+
+               taglet.inherited.check_comments (_settings, this);
+
+               taglet.transform (_tree, taglet_owner, taglet_owner.get_source_file ().get_name (), _reporter, _settings);
        }
 
        private GirMetaData get_metadata_for_comment (Api.GirSourceComment gir_comment) {
index 56227a4412ecfa204a0d233523a080b011d874d4..fac10e54f6029d1a7cede4ba5788411b9136feb4 100644 (file)
@@ -79,10 +79,6 @@ public class Valadoc.WikiPage : Object, Documentation {
        public void parse (DocumentationParser docparser, Api.Package pkg) {
                documentation = docparser.parse_wikipage (pkg, this);
        }
-
-       public void check (DocumentationParser docparser, Api.Package pkg) {
-               docparser.check_wikipage (pkg, documentation);
-       }
 }
 
 
@@ -155,7 +151,7 @@ public class Valadoc.WikiPageTree : Object {
                }
 
                foreach (WikiPage page in this.wikipages) {
-                       page.check (docparser, pkg);
+                       docparser.check_wikipage (pkg, page);
                }
        }
 }
index 54c90d70137b51928271b6951b98ac668fdbe02f..1f32bad67e158c9316ced8cb0cbbbe046a0658d4 100644 (file)
@@ -26,18 +26,13 @@ using Valadoc.Content;
 
 public class Valadoc.Taglets.InheritDoc : InlineTaglet {
        private Taglet? parent_taglet = null;
-       private Api.Node? _inherited;
-
-       private Comment root {
-               get {
-                       ContentElement pos;
-                       for (pos = this; pos.parent != null; pos = pos.parent);
-                       // inheritDoc is only allowed in source comments
-                       assert (pos is Comment);
-                       return (Comment) pos;
-               }
+
+       public Api.Node? inherited {
+               private set;
+               get;
        }
 
+
        public override Rule? get_parser_rule (Rule run_rule) {
                return null;
        }
@@ -72,13 +67,9 @@ public class Valadoc.Taglets.InheritDoc : InlineTaglet {
                        _inherited = (Api.Node) ((Api.Struct) container).base_type.data_type;
                }
 
-               if (_inherited != null) {
-                       api_root.push_unbrowsable_documentation_dependency (_inherited);
-               }
-
                parent_taglet = find_parent_taglet ();
-               if (parent_taglet == null && _inherited != null && _inherited.documentation != null) {
-                       root.register_inheritdoc (this);
+               if (parent_taglet == null && _inherited != null) {
+                       api_root.register_inheritdoc (container, this);
                }
 
 
index 72ed12a5f20f90a6b7b5bef48158763257b07972..82a41baef14729a455655510bd7585a8ca8002dc 100644 (file)
@@ -176,6 +176,8 @@ public class Valadoc.Taglets.Link : InlineTaglet {
                link.locator = locator;
 
                link.symbol_name = symbol_name;
+               link.c_accept_plural = c_accept_plural;
+               link.c_is_plural = c_is_plural;
                link._context = _context;
                link._symbol = _symbol;
 
index 9f6256fcc0cb257ba59f3b185e60ad4ca1c8095a..9d7a9822e2ef6e38510d9ecc9c124d5c41b2a9d3 100644 (file)
@@ -1,7 +1,6 @@
 /* valadoc.vala
  *
- * Copyright (C) 2008-2009 Florian Brosch
- * Copyright (C) 2011      Florian Brosch
+ * Copyright (C) 2008-2014 Florian Brosch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -265,17 +264,22 @@ public class ValaDoc : Object {
                        return quit (reporter);
                }
 
-               doctree.process_comments (docparser);
-               if (reporter.errors > 0) {
-                       return quit (reporter);
-               }
-
                DocumentationImporter[] importers = {
                        new ValadocDocumentationImporter (doctree, docparser, modules, settings, reporter),
                        new GirDocumentationImporter (doctree, docparser, modules, settings, reporter)
                };
 
-               doctree.import_documentation (importers, import_packages, import_directories);
+               doctree.parse_comments (docparser);
+               if (reporter.errors > 0) {
+                       return quit (reporter);
+               }
+
+               doctree.import_comments (importers, import_packages, import_directories);
+               if (reporter.errors > 0) {
+                       return quit (reporter);
+               }
+
+               doctree.check_comments (docparser);
                if (reporter.errors > 0) {
                        return quit (reporter);
                }