[valadoc] libvaladoc: Add support for single line documentation comments
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] libvaladoc: Add support for single line documentation comments
- Date: Thu, 11 Jan 2018 10:32:14 +0000 (UTC)
commit fa9912982ddb2b2b2126decb35fe1a1a479c3cc2
Author: Michael James Gratton <mike vee net>
Date: Tue Jan 9 12:30:50 2018 +1100
libvaladoc: Add support for single line documentation comments
This is useful for example in annotating properties:
/** Returns the current state of the frobnocator. */
public State frob { get; set; };
* libvaladoc/documentation/documentationparser.vala
(DocumentationParser.init_valadoc_rules): Split Comment rule up into
single and multi-line versions. Duplication Paragraph creation and
cleanup for single-line comments.
https://bugzilla.gnome.org/show_bug.cgi?id=736483
.../documentation/documentationparser.vala | 37 ++++++++++++++-----
1 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/src/libvaladoc/documentation/documentationparser.vala
b/src/libvaladoc/documentation/documentationparser.vala
index 27c3b06..6f54b63 100644
--- a/src/libvaladoc/documentation/documentationparser.vala
+++ b/src/libvaladoc/documentation/documentationparser.vala
@@ -549,6 +549,16 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
// Block rules
+ Rule.Action reduce_paragraph = () => {
+ var head = (Paragraph) pop ();
+ ((BlockContent) peek ()).content.add (head);
+
+ Text last_element = head.content.last () as Text;
+ if (last_element != null) {
+ last_element.content._chomp ();
+ }
+ };
+
Rule paragraph =
Rule.seq ({
Rule.option ({
@@ -564,15 +574,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
})
.set_name ("Paragraph")
.set_start (() => { push (_factory.create_paragraph ()); })
- .set_reduce (() => {
- var head = (Paragraph) pop ();
- ((BlockContent) peek ()).content.add (head);
-
- Text last_element = head.content.last () as Text;
- if (last_element != null) {
- last_element.content._chomp ();
- }
- });
+ .set_reduce (reduce_paragraph);
Rule warning =
Rule.seq ({
@@ -877,7 +879,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
((Comment) peek ()).taglets.add (head);
});
- Rule comment =
+ Rule ml_comment =
Rule.seq ({
TokenType.EOL,
Rule.option ({
@@ -887,6 +889,21 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
Rule.many ({ taglet })
})
})
+ .set_name ("MultiLineComment");
+
+ Rule sl_comment =
+ Rule.seq ({
+ run
+ })
+ .set_start (() => { push (_factory.create_paragraph ()); })
+ .set_reduce (reduce_paragraph)
+ .set_name ("SingleLineComment");
+
+ Rule comment =
+ Rule.one_of ({
+ ml_comment,
+ sl_comment
+ })
.set_name ("Comment")
.set_start (() => { push (_factory.create_comment ()); });
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]