[valadoc] libvaladoc: Accept block content in list-items
- From: Florian Brosch <flobrosch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] libvaladoc: Accept block content in list-items
- Date: Mon, 30 Jan 2012 02:58:49 +0000 (UTC)
commit ab74858e5f4f17ac16983f7cb135edd13c72e288
Author: Florian Brosch <flo brosch gmail com>
Date: Sun Jan 29 18:49:40 2012 +0100
libvaladoc: Accept block content in list-items
src/libvaladoc/content/listitem.vala | 13 +-----
.../documentation/documentationparser.vala | 17 ++++++--
.../documentation/gtkdoccommentparser.vala | 41 +++++++-------------
src/libvaladoc/html/htmlrenderer.vala | 15 +++++++-
4 files changed, 43 insertions(+), 43 deletions(-)
---
diff --git a/src/libvaladoc/content/listitem.vala b/src/libvaladoc/content/listitem.vala
index ef5f589..98104b7 100755
--- a/src/libvaladoc/content/listitem.vala
+++ b/src/libvaladoc/content/listitem.vala
@@ -24,20 +24,15 @@
using Gee;
-public class Valadoc.Content.ListItem : InlineContent {
- public List? sub_list { get; set; }
+public class Valadoc.Content.ListItem : BlockContent {
internal ListItem () {
base ();
}
public override void check (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) {
- // Check inline content
+ // Check block content
base.check (api_root, container, file_path, reporter, settings);
-
- if (sub_list != null) {
- sub_list.check (api_root, container, file_path, reporter, settings);
- }
}
public override void accept (ContentVisitor visitor) {
@@ -46,9 +41,5 @@ public class Valadoc.Content.ListItem : InlineContent {
public override void accept_children (ContentVisitor visitor) {
base.accept_children (visitor);
-
- if (sub_list != null) {
- sub_list.accept (visitor);
- }
}
}
diff --git a/src/libvaladoc/documentation/documentationparser.vala b/src/libvaladoc/documentation/documentationparser.vala
index 5fa736a..bf79166 100755
--- a/src/libvaladoc/documentation/documentationparser.vala
+++ b/src/libvaladoc/documentation/documentationparser.vala
@@ -145,15 +145,20 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
private void new_list_item (Content.List.Bullet bullet) throws ParserError {
var new_item = _factory.create_list_item ();
+ var content = _factory.create_paragraph ();
+ new_item.content.add (content);
Content.List list = null;
if (levels.length >= 1) {
+ // Pop current content
+ pop ();
+
if (current_level > levels[levels.length - 1]) {
list = _factory.create_list ();
list.bullet = bullet;
var current_item = peek () as ListItem;
- current_item.sub_list = list;
+ current_item.content.add (list);
push (list);
levels += current_level;
@@ -191,6 +196,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
list.items.add (new_item);
push (new_item);
+ push (content);
}
private string bullet_type_string (Content.List.Bullet bullet) {
@@ -214,6 +220,9 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
}
private void finish_list () {
+ // pop content
+ pop ();
+
while (peek () is ListItem) {
pop ();
pop ();
@@ -569,7 +578,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
.set_name ("IndentedItem")
.set_start (() => { current_level = 0; })
.set_reduce (() => {
- var content_list = ((ListItem) peek ()).content;
+ var content_list = ((InlineContent) peek ()).content;
if (content_list.size > 0 && content_list.last () is Text) {
((Text) content_list.last ()).content._chomp ();
}
@@ -795,8 +804,8 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
}
#if DEBUG
- private void dump_stack () {
- message ("Dumping stack");
+ private void dump_stack (string title) {
+ message ("=== Dumping stack: %s ===", title);
foreach (Object object in _stack) {
message ("%s", object.get_type ().name ());
}
diff --git a/src/libvaladoc/documentation/gtkdoccommentparser.vala b/src/libvaladoc/documentation/gtkdoccommentparser.vala
index f3718ce..a437a66 100644
--- a/src/libvaladoc/documentation/gtkdoccommentparser.vala
+++ b/src/libvaladoc/documentation/gtkdoccommentparser.vala
@@ -549,27 +549,7 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
ListItem item = factory.create_list_item ();
while (current.type != TokenType.XML_CLOSE && current.type != TokenType.EOF) {
- if (current.type == TokenType.XML_OPEN && current.content == "para") {
- foreach (Block block in parse_docbook_para ()) {
- if (block is Paragraph) {
- if (item.content.size > 0) {
- item.content.add (factory.create_text ("\n"));
- }
-
- item.content.add_all (((Paragraph) block).content);
- } else {
- // TODO: extend me
- this.report_unexpected_token (current, "<para>|</listitem>");
- return null;
- }
- }
- } else {
- Token tmp_t = current;
- parse_inline_content ();
- if (tmp_t == current) {
- break;
- }
- }
+ item.content.add_all (parse_mixed_content ());
}
if (!check_xml_close_tag ("listitem")) {
@@ -693,7 +673,7 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
}
LinkedList<Block> lst = parse_block_content ();
- if (lst != null && run.content.size > 0) {
+ if (lst != null && lst.size > 0) {
content.add_all (lst);
continue;
}
@@ -702,9 +682,13 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
return content;
}
- private LinkedList<Block>? parse_docbook_para () {
- if (!check_xml_open_tag ("para")) {
- this.report_unexpected_token (current, "<para>");
+ private inline LinkedList<Block>? parse_docbook_simpara () {
+ return parse_docbook_para ("simpara");
+ }
+
+ private LinkedList<Block>? parse_docbook_para (string tag_name = "para") {
+ if (!check_xml_open_tag (tag_name)) {
+ this.report_unexpected_token (current, "<%s>".printf (tag_name));
return null;
}
@@ -712,8 +696,9 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
LinkedList<Block> content = parse_mixed_content ();
- if (!check_xml_close_tag ("para")) {
- this.report_unexpected_token (current, "</para>");
+ // ignore missing </para> to match gtkdocs behaviour
+ if (!check_xml_close_tag (tag_name) && current.type != TokenType.EOF) {
+ this.report_unexpected_token (current, "</%s>".printf (tag_name));
return content;
}
@@ -1225,6 +1210,8 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
this.append_block_content_not_null (content, parse_docbook_programlisting ());
} else if (current.type == TokenType.XML_OPEN && current.content == "para") {
this.append_block_content_not_null_all (content, parse_docbook_para ());
+ } else if (current.type == TokenType.XML_OPEN && current.content == "simpara") {
+ this.append_block_content_not_null_all (content, parse_docbook_simpara ());
} else if (current.type == TokenType.XML_OPEN && current.content == "informalexample") {
this.append_block_content_not_null_all (content, parse_docbook_informalexample ());
} else if (current.type == TokenType.XML_OPEN && current.content == "example") {
diff --git a/src/libvaladoc/html/htmlrenderer.vala b/src/libvaladoc/html/htmlrenderer.vala
index 153e844..4bf69d7 100755
--- a/src/libvaladoc/html/htmlrenderer.vala
+++ b/src/libvaladoc/html/htmlrenderer.vala
@@ -355,7 +355,20 @@ public class Valadoc.Html.HtmlRenderer : ContentRenderer {
public override void visit_list_item (ListItem element) {
writer.start_tag ("li");
- element.accept_children (this);
+ Paragraph? first_para = (element.content.size > 0)? element.content[0] as Paragraph : null;
+ if (first_para != null) {
+ // We do not pick up alignments in gir-files.
+ first_para.accept_children (this);
+ bool first_entry = true;
+ foreach (var item in element.content) {
+ if (!first_entry) {
+ item.accept (this);
+ }
+ first_entry = false;
+ }
+ } else {
+ element.accept_children (this);
+ }
writer.end_tag ("li");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]