[valadoc] libvaladoc: .valadoc-importer: Add support for ::append and ::prepend
- From: Florian Brosch <flobrosch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] libvaladoc: .valadoc-importer: Add support for ::append and ::prepend
- Date: Mon, 19 Nov 2012 01:45:56 +0000 (UTC)
commit ce8c758c79ea399fd6e3d70f8a24586fa67ea50c
Author: Florian Brosch <flo brosch gmail com>
Date: Fri Nov 16 19:49:01 2012 +0100
libvaladoc: .valadoc-importer: Add support for ::append and ::prepend
.../importer/valadocdocumentationimporter.vala | 40 +++++++++++++++++++-
1 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/src/libvaladoc/importer/valadocdocumentationimporter.vala b/src/libvaladoc/importer/valadocdocumentationimporter.vala
index 4f63d48..b005217 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]