From: Florian Brosch Date: Fri, 16 Nov 2012 18:49:01 +0000 (+0100) Subject: libvaladoc: .valadoc-importer: Add support for ::append and ::prepend X-Git-Tag: 0.37.1~3^2~123 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce8c758c79ea399fd6e3d70f8a24586fa67ea50c;p=thirdparty%2Fvala.git libvaladoc: .valadoc-importer: Add support for ::append and ::prepend --- diff --git a/src/libvaladoc/importer/valadocdocumentationimporter.vala b/src/libvaladoc/importer/valadocdocumentationimporter.vala index 4f63d48cc..b005217f7 100644 --- a/src/libvaladoc/importer/valadocdocumentationimporter.vala +++ b/src/libvaladoc/importer/valadocdocumentationimporter.vala @@ -115,9 +115,28 @@ public class Valadoc.Importer.ValadocDocumentationImporter : DocumentationImport _parser.set_root_rule (file); } - private void add_documentation (string symbol_name, StringBuilder? comment, string filename, SourceLocation src_ref) { + private enum InsertionMode { + APPEND, + PREPEND, + REPLACE + } + + private void add_documentation (string _symbol_name, StringBuilder? comment, string filename, SourceLocation src_ref) { Api.Node? symbol = null; + InsertionMode insertion_mode; + string symbol_name; + if (_symbol_name.has_suffix ("::append")) { + symbol_name = _symbol_name.substring (0, _symbol_name.length - 8); + insertion_mode = InsertionMode.APPEND; + } else if (_symbol_name.has_suffix ("::prepend")) { + symbol_name = _symbol_name.substring (0, _symbol_name.length - 9); + insertion_mode = InsertionMode.PREPEND; + } else { + symbol_name = _symbol_name; + insertion_mode = InsertionMode.REPLACE; + } + if (symbol_name.has_prefix ("c::")) { symbol = tree.search_symbol_cstr (null, symbol_name.substring (3)); } else { @@ -135,11 +154,28 @@ public class Valadoc.Importer.ValadocDocumentationImporter : DocumentationImport if (comment != null) { var docu = _doc_parser.parse_comment_str (symbol, comment.str, filename, src_ref.line, src_ref.column); if (docu != null) { - symbol.documentation = docu; + if (symbol.documentation == null || insertion_mode == InsertionMode.REPLACE) { + if (insertion_mode == InsertionMode.APPEND) { + docu.content.insert (0, factory.create_paragraph ()); + } + symbol.documentation = docu; + } else if (insertion_mode == InsertionMode.APPEND) { + symbol.documentation.content.add_all (docu.content); + merge_taglets (symbol.documentation, docu); + } else if (insertion_mode == InsertionMode.PREPEND) { + symbol.documentation.content.insert_all (0, docu.content); + merge_taglets (symbol.documentation, docu); + } } } } + private void merge_taglets (Comment comment, Comment imported) { + foreach (Taglet taglet in imported.taglets) { + imported.taglets.add (taglet); + } + } + public override void process (string filename) { try { _filename = filename;