]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Improve {@inheritDoc}
authorFlorian Brosch <flo.brosch@gmail.com>
Mon, 1 Oct 2012 23:50:26 +0000 (01:50 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Mon, 1 Oct 2012 23:50:26 +0000 (01:50 +0200)
31 files changed:
src/libvaladoc/content/blockcontent.vala
src/libvaladoc/content/comment.vala
src/libvaladoc/content/contentelement.vala
src/libvaladoc/content/embedded.vala
src/libvaladoc/content/headline.vala
src/libvaladoc/content/inlinecontent.vala
src/libvaladoc/content/inlinetaglet.vala
src/libvaladoc/content/link.vala
src/libvaladoc/content/list.vala
src/libvaladoc/content/listitem.vala
src/libvaladoc/content/note.vala
src/libvaladoc/content/page.vala
src/libvaladoc/content/paragraph.vala
src/libvaladoc/content/run.vala
src/libvaladoc/content/sourcecode.vala
src/libvaladoc/content/symbollink.vala
src/libvaladoc/content/table.vala
src/libvaladoc/content/tablecell.vala
src/libvaladoc/content/tablerow.vala
src/libvaladoc/content/taglet.vala
src/libvaladoc/content/text.vala
src/libvaladoc/content/warning.vala
src/libvaladoc/content/wikilink.vala
src/libvaladoc/taglets/tagletdeprecated.vala
src/libvaladoc/taglets/tagletinheritdoc.vala
src/libvaladoc/taglets/tagletlink.vala
src/libvaladoc/taglets/tagletparam.vala
src/libvaladoc/taglets/tagletreturn.vala
src/libvaladoc/taglets/tagletsee.vala
src/libvaladoc/taglets/tagletsince.vala
src/libvaladoc/taglets/tagletthrows.vala

index d3d8a984ab5a86dd58427c3ba2188efd1197226f..54d9e567a4130cc57f6874a4bbbe0717c8057902 100644 (file)
@@ -37,6 +37,7 @@ public abstract class Valadoc.Content.BlockContent : ContentElement {
 
        public override void check (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) {
                foreach (Block element in _content) {
+                       element.parent = this;
                        element.check (api_root, container, file_path, reporter, settings);
                }
        }
index 0c6f4496fe97e98bdffb6b875dd7a26d2370e3bc..6f036c0ba9c3f6c843c15aa3a6ef18deaaa9eb3d 100644 (file)
  *     Didier 'Ptitjes Villevalois <ptitjes@free.fr>
  */
 
+using Valadoc.Taglets;
 using Gee;
 
 
 public class Valadoc.Content.Comment : BlockContent {
-       public Gee.List<Taglet> taglets { get { return _taglets; } }
+       private Gee.LinkedList<InheritDoc> inheritdocs = new Gee.LinkedList<InheritDoc> ();
 
+       public Gee.List<Taglet> taglets { get { return _taglets; } }
        private Gee.List<Taglet> _taglets;
 
        internal Comment () {
@@ -34,6 +36,10 @@ 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) {
        }
 
@@ -41,8 +47,13 @@ public class Valadoc.Content.Comment : BlockContent {
                base.check (api_root, container, file_path, reporter, settings);
 
                foreach (Taglet element in _taglets) {
+                       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) {
@@ -70,5 +81,24 @@ public class Valadoc.Content.Comment : BlockContent {
 
                return selected_taglets;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               assert (new_parent == null);
+
+               Comment comment = new Comment ();
+               comment.parent = new_parent;
+
+               foreach (Block element in content) {
+                       Block copy = element.copy (comment) as Block;
+                       comment.content.add (copy);
+               }
+
+               foreach (Taglet taglet in _taglets) {
+                       Taglet copy = taglet.copy (comment) as Taglet;
+                       comment.taglets.add (copy);
+               }
+
+               return comment;
+       }
 }
 
index be15e5bbddcbbac758b2fe1d3d335a1e2698c995..dbec72d1035178c673d58f4fa63c996068dfcaa3 100644 (file)
@@ -25,6 +25,10 @@ using GLib;
 
 
 public abstract class Valadoc.Content.ContentElement : Object {
+       public ContentElement parent { get; internal set; }
+
+       public abstract ContentElement copy (ContentElement? new_parent = null);
+
 
        public virtual void configure (Settings settings, ResourceLocator locator) {
        }
index d287ca7ccf742d87dd6396cf2c003617f3b3264d..bdfdbb6c3a9e500c5067c5e43710aebe5038e02b 100644 (file)
@@ -70,4 +70,19 @@ public class Valadoc.Content.Embedded : ContentElement, Inline, StyleAttributes
        public override bool is_empty () {
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Embedded embedded = new Embedded ();
+               embedded.parent = new_parent;
+
+               embedded.horizontal_align = horizontal_align;
+               embedded.vertical_align = vertical_align;
+               embedded._locator = _locator;
+               embedded.caption = caption;
+               embedded.package = package;
+               embedded.style = style;
+               embedded.url = url;
+
+               return embedded;
+       }
 }
index 36b19c23b04074f95f7894b4708e22039270c520..3f7150c4550047aa7ebf9d33b0a73c6b410172f9 100644 (file)
@@ -24,7 +24,7 @@
 using Gee;
 
 
-public class Valadoc.Content.Headline : Block, InlineContent {
+public class Valadoc.Content.Headline : InlineContent, Block {
        public int level { get; set; }
 
        internal Headline () {
@@ -44,9 +44,21 @@ public class Valadoc.Content.Headline : Block, InlineContent {
                visitor.visit_headline (this);
        }
 
-
        public override bool is_empty () {
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Headline headline = new Headline ();
+               headline.parent = new_parent;
+               headline.level = level;
+
+               foreach (Inline element in content) {
+                       Inline copy = element.copy (headline) as Inline;
+                       headline.content.add (copy);
+               }
+
+               return headline;
+       }
 }
 
index 119f0569d82841624f0ada0bb0214c7aa11d9723..f3c47f1640e4e1a79c904b72d66813178680845b 100644 (file)
@@ -38,6 +38,7 @@ public abstract class Valadoc.Content.InlineContent : ContentElement {
 
        public override void check (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) {
                foreach (Inline element in _content) {
+                       element.parent = this;
                        element.check (api_root, container, file_path, reporter, settings);
                }
        }
index 151395095f75a1c453197fe5d34f0a67e4aff849..6b7e81786c796e2dda0955b70ebb8eddf24e89eb 100644 (file)
@@ -51,6 +51,8 @@ public abstract class Valadoc.Content.InlineTaglet : ContentElement, Taglet, Inl
 
        public override void check (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) {
                ContentElement element = get_content ();
+               element.parent = this;
+
                element.check (api_root, container, file_path, reporter, settings);
        }
 
index e2648981ad52decdec07420b73dd1d2b028630fe..20fd095e993d1fba656e41882ffed6a138e8c253 100644 (file)
@@ -35,6 +35,7 @@ public class Valadoc.Content.Link : InlineContent, Inline {
        }
 
        public override void check (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) {
+               base.check (api_root, container, file_path, reporter, settings);
                //TODO: check url
        }
 
@@ -45,4 +46,17 @@ public class Valadoc.Content.Link : InlineContent, Inline {
        public override bool is_empty () {
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Link link = new Link ();
+               link.parent = new_parent;
+               link.url = url;
+
+               foreach (Inline element in content) {
+                       Inline copy = element.copy (link) as Inline;
+                       link.content.add (copy);
+               }
+
+               return link;
+       }
 }
index e55489fe1e157364923f8dcb07847281e7b8d773..0b04c03c79014bee7ea4f0e156a8a4996c06f00a 100644 (file)
@@ -112,6 +112,7 @@ public class Valadoc.Content.List : ContentElement, Block {
        public override void check (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) {
                // Check individual list items
                foreach (ListItem element in _items) {
+                       element.parent = this;
                        element.check (api_root, container, file_path, reporter, settings);
                }
        }
@@ -129,4 +130,17 @@ public class Valadoc.Content.List : ContentElement, Block {
        public override bool is_empty () {
                return _items.size == 0;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Content.List list = new Content.List ();
+               list.parent = new_parent;
+               list.bullet = bullet;
+
+               foreach (ListItem item in items) {
+                       ListItem copy = item.copy (list) as ListItem;
+                       list.items.add (copy);
+               }
+
+               return list;
+       }
 }
index 98104b767b4ed88924af35b0a487f6a8797f7046..00a112a89472656a93dc541ca567a47bffd68984 100644 (file)
@@ -42,4 +42,16 @@ public class Valadoc.Content.ListItem : BlockContent {
        public override void accept_children (ContentVisitor visitor) {
                base.accept_children (visitor);
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               ListItem item = new ListItem ();
+               item.parent = new_parent;
+
+               foreach (Block block in content) {
+                       Block copy = block.copy (item) as Block;
+                       item.content.add (copy);
+               }
+
+               return item;
+       }
 }
index 40bb93019820b8b62e33cc217a8765d52e9774b5..c8b24e47b4bfffdbd67532d24afb16f51758bbe0 100644 (file)
@@ -37,5 +37,17 @@ public class Valadoc.Content.Note : BlockContent, Block {
        public override void accept (ContentVisitor visitor) {
                visitor.visit_note (this);
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Note note = new Note ();
+               note.parent = new_parent;
+
+               foreach (Block block in content) {
+                       Block copy = block.copy (note) as Block;
+                       note.content.add (copy);
+               }
+
+               return note;
+       }
 }
 
index c01bd88b9f7b1bbe4b5ff3feb16e9ae9d45641ba..662ee89710ef76b41cb43ef4b0e784d33efce354 100644 (file)
@@ -31,5 +31,19 @@ public class Valadoc.Content.Page : BlockContent {
        public override void accept (ContentVisitor visitor) {
                visitor.visit_page (this);
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               assert (new_parent == null);
+
+               Content.Page page = new Content.Page ();
+               page.parent = new_parent;
+
+               foreach (Block block in content) {
+                       Block copy = block.copy (page) as Block;
+                       page.content.add (copy);
+               }
+
+               return page;
+       }
 }
 
index 4998952d408624f4fac01b3755d432092596064f..d50859d0bff0ec11aad4f0ebf0f47752b01f4a67 100644 (file)
@@ -41,5 +41,21 @@ public class Valadoc.Content.Paragraph : InlineContent, Block, StyleAttributes {
        public override void accept (ContentVisitor visitor) {
                visitor.visit_paragraph (this);
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Paragraph p = new Paragraph ();
+               p.parent = new_parent;
+
+               p.horizontal_align = horizontal_align;
+               p.vertical_align = vertical_align;
+               p.style = style;
+
+               foreach (Inline element in content) {
+                       Inline copy = element.copy (p) as Inline;
+                       p.content.add (copy);
+               }
+
+               return p;
+       }
 }
 
index 146d9c29e268aec6a26be80680e2a47f24b06e0d..15a9501e07cde8176fdc4bd92471cc41d3070c9c 100644 (file)
@@ -126,5 +126,17 @@ public class Valadoc.Content.Run : InlineContent, Inline {
        public override void accept (ContentVisitor visitor) {
                visitor.visit_run (this);
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Run run = new Run (style);
+               run.parent = new_parent;
+
+               foreach (Inline element in content) {
+                       Inline copy = element.copy (run) as Inline;
+                       run.content.add (copy);
+               }
+
+               return run;
+       }
 }
 
index 70851d3f88c8d859525183f21fb04ff68a3c994e..86ad66fd80f9607edf145cebbc4706ac2c3b870f 100644 (file)
@@ -154,4 +154,14 @@ public class Valadoc.Content.SourceCode : ContentElement, Inline {
                // empty source blocks are visible as well
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               SourceCode source_code = new SourceCode ();
+               source_code.parent = new_parent;
+
+               source_code.language = language;
+               source_code.code = code;
+
+               return source_code;
+       }
 }
index aff9476e2639f799bc7a2d15e3d8a3cafae5d4aa..a73b4880d642b149974c7564657031880e656dab 100644 (file)
@@ -47,5 +47,11 @@ public class Valadoc.Content.SymbolLink : ContentElement, Inline {
        public override bool is_empty () {
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               SymbolLink link = new SymbolLink (symbol, label);
+               link.parent = new_parent;
+               return link;
+       }
 }
 
index 17fa589e8b4ceea3006de45231fa0ca7e22baf0f..962b063ec277ecc2be759e20076e7e201d166724 100644 (file)
@@ -39,6 +39,7 @@ public class Valadoc.Content.Table : ContentElement, Block {
 
                // Check individual rows
                foreach (var row in _rows) {
+                       row.parent = this;
                        row.check (api_root, container, file_path, reporter, settings);
                }
        }
@@ -56,5 +57,17 @@ public class Valadoc.Content.Table : ContentElement, Block {
        public override bool is_empty () {
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Table table = new Table ();
+               table.parent = new_parent;
+
+               foreach (var row in _rows) {
+                       TableRow copy = row.copy (table) as TableRow;
+                       table.rows.add (copy);
+               }
+
+               return table;
+       }
 }
 
index 733aad1ca622e87b195b128af7a77650e704cc08..bf83e7d301b5f185e432292fd210fa1654746c24 100644 (file)
@@ -50,5 +50,23 @@ public class Valadoc.Content.TableCell : InlineContent, StyleAttributes {
                // empty cells are displayed as well
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               TableCell cell = new TableCell ();
+               cell.parent = new_parent;
+
+               cell.horizontal_align = horizontal_align;
+               cell.vertical_align = vertical_align;
+               cell.colspan = colspan;
+               cell.rowspan = rowspan;
+               cell.style = style;
+
+               foreach (Inline element in content) {
+                       Inline copy = element.copy (cell) as Inline;
+                       cell.content.add (copy);
+               }
+
+               return cell;
+       }
 }
 
index 5cd59fd4bb9542adf88bfd3b3c85549a4845616c..1ab62ccd8eb1be17faed21e9feffa3eeb5fe5a1a 100644 (file)
@@ -37,6 +37,7 @@ public class Valadoc.Content.TableRow : ContentElement {
        public override void check (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) {
                // Check individual cells
                foreach (var cell in _cells) {
+                       cell.parent = this;
                        cell.check (api_root, container, file_path, reporter, settings);
                }
        }
@@ -54,5 +55,17 @@ public class Valadoc.Content.TableRow : ContentElement {
        public override bool is_empty () {
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               TableRow row = new TableRow ();
+               row.parent = new_parent;
+
+               foreach (TableCell cell in _cells) {
+                       TableCell copy = cell.copy (row) as TableCell;
+                       row.cells.add (copy);
+               }
+
+               return row;
+       }
 }
 
index 503cb7c4ca3e226b00d896bc7709efe2665c97f2..a8fc4f144af91f56675bf08378051f0a8ec0126e 100644 (file)
@@ -26,5 +26,13 @@ using Gee;
 public interface Valadoc.Content.Taglet : ContentElement {
 
        public abstract Rule? get_parser_rule (Rule run_rule);
+
+       public virtual Gee.List<Inline>? get_inheritable_documentation () {
+               return null;
+       }
+
+       public virtual bool inheritable (Taglet taglet) {
+               return false;
+       }
 }
 
index 6d3877e87e0100e5bda7976228099c293f4f7d2f..d1639399ac2b3efb41e7fc0412959a2a8c2115cc 100644 (file)
@@ -48,5 +48,11 @@ public class Valadoc.Content.Text : ContentElement, Inline {
        public override bool is_empty () {
                return content == "";
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Text text = new Text (content);
+               text.parent = new_parent;
+               return text;
+       }
 }
 
index 3ab9b3c7365d24e0978a9d3234af70efd7c0927b..d98fbd765fba64f6b7ba38f4d26b9592c6996cbd 100644 (file)
@@ -37,5 +37,17 @@ public class Valadoc.Content.Warning : BlockContent, Block {
        public override void accept (ContentVisitor visitor) {
                visitor.visit_warning (this);
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Warning warning = new Warning ();
+               warning.parent = new_parent;
+
+               foreach (Block block in content) {
+                       Block copy = block.copy (warning) as Block;
+                       warning.content.add (copy);
+               }
+
+               return warning;
+       }
 }
 
index 5d0d22c4e32ea85df2a4e329b9553ef90414f34e..2592b879f150c0f6465cbd2480e49d77d23554dd 100644 (file)
@@ -25,17 +25,16 @@ using Gee;
 
 
 public class Valadoc.Content.WikiLink : InlineContent, Inline {
-       public WikiPage page { get; private set; }
+       public WikiPage page { get; internal set; }
        public string name { get; set; }
 
        internal WikiLink () {
                base ();
        }
 
-       public override void configure (Settings settings, ResourceLocator locator) {
-       }
-
        public override void check (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) {
+               base.check (api_root, container, file_path, reporter, settings);
+
                page = api_root.wikitree.search (name);
                if (page == null) {
                        string node_segment = (container is Api.Package)? "" : container.get_full_name () + ": ";
@@ -48,8 +47,22 @@ public class Valadoc.Content.WikiLink : InlineContent, Inline {
                visitor.visit_wiki_link (this);
        }
 
-
        public override bool is_empty () {
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               WikiLink link = new WikiLink ();
+               link.parent = new_parent;
+
+               link.page = page;
+               link.name = name;
+
+               foreach (Inline element in content) {
+                       Inline copy = element.copy (link) as Inline;
+                       link.content.add (copy);
+               }
+
+               return link;
+       }
 }
index 0d3c19290d94f5cd2aa410b011dd86b622cd78ae..49636cafb2b1f723bb9bed9620edbcd0300be6fa 100644 (file)
@@ -41,5 +41,17 @@ public class Valadoc.Taglets.Deprecated : InlineContent, Taglet, Block {
        public override bool is_empty () {
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Deprecated deprecated = new Deprecated ();
+               deprecated.parent = new_parent;
+
+               foreach (Inline element in content) {
+                       Inline copy = element.copy (deprecated) as Inline;
+                       deprecated.content.add (copy);
+               }
+
+               return deprecated;
+       }
 }
 
index 653a448a10f31927ca5e5df137f0a694a08900fc..e2e7fdd3e7fbbb9491008f364b04ee90de71f136 100644 (file)
@@ -25,12 +25,37 @@ using Gee;
 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 override Rule? get_parser_rule (Rule run_rule) {
                return null;
        }
 
+       private Taglet? find_parent_taglet () {
+               if (_inherited == null || _inherited.documentation == null) {
+                       return null;
+               }
+
+               ContentElement pos;
+               for (pos = this.parent; pos != null && pos is Taglet == false; pos = pos.parent);
+               if (pos is Taglet) {
+                       return (Taglet) pos;
+               }
+
+               return null;
+       }
+
        public override void check (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) {
                // TODO Check that the container is an override of an abstract symbol
                // Also retrieve that abstract symbol _inherited
@@ -49,6 +74,12 @@ public class Valadoc.Taglets.InheritDoc : InlineTaglet {
                        api_root.push_unbrowsable_documentation_dependency (_inherited);
                }
 
+               parent_taglet = find_parent_taglet ();
+               if (parent_taglet == null) {
+                       root.register_inheritdoc (this);
+               }
+
+
                // TODO report error if inherited is null
 
                // TODO postpone check after complete parse of the api tree comments
@@ -56,15 +87,133 @@ public class Valadoc.Taglets.InheritDoc : InlineTaglet {
                //base.check (api_root, container, reporter);
        }
 
-       public override ContentElement produce_content () {
-               if (_inherited != null && _inherited.documentation != null) {
-                       Paragraph inherited_paragraph = _inherited.documentation.content.get (0) as Paragraph;
+       private Run[]? split_run (Inline? separator) {
+               if (separator == null) {
+                       return null;
+               }
 
-                       Run paragraph = new Run (Run.Style.NONE);
-                       foreach (var element in inherited_paragraph.content) {
-                               paragraph.content.add (element);
+               ContentElement parent = separator.parent;
+               Gee.List<Inline> parent_content = null;
+
+               if (parent is Run && ((Run) parent).style == Run.Style.NONE) {
+                       parent_content = ((Run) parent).content;
+               } else if (parent is Paragraph) {
+                       parent_content = ((Paragraph) parent).content;
+               }
+
+               if (parent_content != null) {
+                       Run right_run = new Run (Run.Style.NONE);
+                       Run left_run = new Run (Run.Style.NONE);
+                       bool separated = false;
+
+                       foreach (var current in parent_content) {
+                               if (current == separator) {
+                                       separated = true;
+                               } else if (separated) {
+                                       right_run.content.add (current);
+                                       current.parent = right_run;
+                               } else {
+                                       left_run.content.add (current);
+                                       current.parent = left_run;
+                               }
+                       }
+
+                       return { left_run, right_run };
+               }
+
+               return null;
+       }
+
+       internal void transform (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) {
+               ContentElement separator = this;
+               Run right_run = null;
+               Run left_run = null;
+               Run[]? parts;
+
+               while ((parts = split_run (separator as Inline)) != null) {
+                       if (left_run != null) {
+                               parts[0].content.add (left_run);
+                               left_run.parent = parts[0];
+                       }
+
+                       if (right_run != null) {
+                               parts[1].content.insert (0, right_run);
+                               right_run.parent = parts[1];
+                       }
+
+                       separator = separator.parent;
+                       right_run = parts[1];
+                       left_run = parts[0];
+               }
+
+               if (separator is Paragraph == false || separator.parent is Comment == false) {
+                       reporter.simple_error ("%s: %s: @inheritDoc: error: Parent documentation can't be copied to this location.", file_path, container.get_full_name ());
+                       return ;
+               }
+
+               Comment comment = separator.parent as Comment;
+               assert (comment != null);
+
+               int insert_pos = comment.content.index_of ((Paragraph) separator);
+               int start_pos = insert_pos;
+               assert (insert_pos >= 0);
+
+               foreach (Block block in _inherited.documentation.content) {
+                       comment.content.insert (insert_pos, (Block) block.copy (comment));
+                       insert_pos++;
+               }
+
+               if (right_run != null) {
+                       if (comment.content[insert_pos - 1] is Paragraph) {
+                               ((Paragraph) comment.content[insert_pos - 1]).content.add (right_run);
+                               right_run.parent = comment.content[insert_pos - 1];
+                       } else {
+                               Paragraph p = new Paragraph ();
+                               p.content.add (right_run);
+                               right_run.parent = p;
+                               p.parent = comment;
+                               comment.content.insert (insert_pos, p);
+                       }
+               }
+
+               if (left_run != null) {
+                       if (comment.content[start_pos] is Paragraph) {
+                               ((Paragraph) comment.content[start_pos]).content.insert (0, left_run);
+                               left_run.parent = comment.content[start_pos];
+                       } else {
+                               Paragraph p = new Paragraph ();
+                               p.content.add (left_run);
+                               left_run.parent = p;
+                               p.parent = comment;
+                               comment.content.insert (start_pos, p);
+                       }
+               }
+
+               comment.content.remove ((Paragraph) separator);
+       }
+
+       private Run content_copy (Gee.List<Inline>? content) {
+               Run run = new Run (Run.Style.NONE);
+               run.parent = this;
+
+               if (content != null) {
+                       foreach (Inline item in content) {
+                               run.content.add ((Inline) item.copy (this));
+                       }
+               }
+
+               return run;
+       }
+
+       public override ContentElement produce_content () {
+               if (_inherited != null && _inherited.documentation != null && parent_taglet != null) {
+                       Gee.List<Taglet> parent_taglets = _inherited.documentation.find_taglets (null, parent_taglet.get_type ());
+                       foreach (Taglet parent in parent_taglets) {
+                               // we only care about the first match:
+                               if (parent.inheritable (parent_taglet)) {
+                                       return content_copy (parent.get_inheritable_documentation ());
+                               }
                        }
-                       return paragraph;
                }
                return new Text ("");
        }
@@ -72,4 +221,16 @@ public class Valadoc.Taglets.InheritDoc : InlineTaglet {
        public override bool is_empty () {
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               InheritDoc doc = new InheritDoc ();
+               doc.parent = new_parent;
+
+               doc.settings = settings;
+               doc.locator = locator;
+
+               doc._inherited = _inherited;
+
+               return doc;
+       }
 }
index d49aa4b84e2103d01bd4cd110647b61a8ca41608..39e4948b5ede545456ad0fb4b7dbfaf73d65214c 100644 (file)
@@ -106,4 +106,18 @@ public class Valadoc.Taglets.Link : InlineTaglet {
        public override bool is_empty () {
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Link link = new Link ();
+               link.parent = new_parent;
+
+               link.settings = settings;
+               link.locator = locator;
+
+               link.symbol_name = symbol_name;
+               link._context = _context;
+               link._symbol = _symbol;
+
+               return link;
+       }
 }
index 78e9d163d39f8f415588ab7f0b956244b0401af6..277d9b6aa3ba1b9ff96230947f221ce1b160189c 100644 (file)
@@ -104,4 +104,33 @@ public class Valadoc.Taglets.Param : InlineContent, Taglet, Block {
        public override void accept (ContentVisitor visitor) {
                visitor.visit_taglet (this);
        }
+
+       public Gee.List<ContentElement>? get_inheritable_documentation () {
+               return content;
+       }
+
+       public bool inheritable (Taglet taglet) {
+               if (taglet is Taglets.Param == false) {
+                       return false;
+               }
+
+               Taglets.Param t = (Taglets.Param) taglet;
+               return (parameter == t.parameter || parameter_name == t.parameter_name);
+       }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Param param = new Param ();
+               param.parent = new_parent;
+
+               param.parameter_name = parameter_name;
+               param.parameter = parameter;
+               param.position = position;
+
+               foreach (Inline element in content) {
+                       Inline copy = element.copy (param) as Inline;
+                       param.content.add (copy);
+               }
+
+               return param;
+       }
 }
index e616791f645e98b0aa8e5853cbc82dca9fe07f0a..d447e6eb5d48308ebb5ce02a879240d7ce85f635 100644 (file)
@@ -53,4 +53,24 @@ public class Valadoc.Taglets.Return : InlineContent, Taglet, Block {
        public override void accept (ContentVisitor visitor) {
                visitor.visit_taglet (this);
        }
+
+       public Gee.List<ContentElement>? get_inheritable_documentation () {
+               return content;
+       }
+
+       public bool inheritable (Taglet taglet) {
+               return taglet is Taglets.Return;
+       }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Return ret = new Return ();
+               ret.parent = new_parent;
+
+               foreach (Inline element in content) {
+                       Inline copy = element.copy (ret) as Inline;
+                       ret.content.add (copy);
+               }
+
+               return ret;
+       }
 }
index fe8f799b58422836e11013779637b8309b3997bb..2d019988fae22e64833bedde7e9f478cf0ccd943 100644 (file)
@@ -63,4 +63,13 @@ public class Valadoc.Taglets.See : ContentElement, Taglet, Block {
        public override bool is_empty () {
                return false;
        }
-}
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               See see = new See ();
+               see.parent = new_parent;
+
+               see.symbol_name = symbol_name;
+               see.symbol = symbol;
+
+               return see;
+       }}
index 49acafbc0d8958199db340e83fde079a890e7c40..10b87b93b3d8faf38475541d36158762668d84c1 100644 (file)
@@ -48,4 +48,14 @@ public class Valadoc.Taglets.Since : ContentElement, Taglet, Block {
        public override bool is_empty () {
                return false;
        }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Since since = new Since ();
+               since.parent = new_parent;
+
+               since.version = version;
+
+               return since;
+       }
 }
+
index 2ba7fa0ce55cc08cc5e0bf5e648192963edf2082..242328710776cb55f088cf7be6ccffff30a54421 100644 (file)
@@ -81,5 +81,33 @@ public class Valadoc.Taglets.Throws : InlineContent, Taglet, Block {
        public override void accept (ContentVisitor visitor) {
                visitor.visit_taglet (this);
        }
+
+       public Gee.List<ContentElement>? get_inheritable_documentation () {
+               return content;
+       }
+
+       public bool inheritable (Taglet taglet) {
+               if (taglet is Taglets.Throws == false) {
+                       return false;
+               }
+
+               Taglets.Throws t = (Taglets.Throws) taglet;
+               return (error_domain == t.error_domain || error_domain_name == t.error_domain_name);
+       }
+
+       public override ContentElement copy (ContentElement? new_parent = null) {
+               Throws tr = new Throws ();
+               tr.parent = new_parent;
+
+               tr.error_domain_name = error_domain_name;
+               tr.error_domain = error_domain;
+
+               foreach (Inline element in content) {
+                       Inline copy = element.copy (tr) as Inline;
+                       tr.content.add (copy);
+               }
+
+               return tr;
+       }
 }