From: Florian Brosch Date: Sun, 29 Jan 2012 21:10:24 +0000 (+0100) Subject: gtkdoc-importer: Add support for variablelist X-Git-Tag: 0.37.1~3^2~218 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d4cee8d2dd6edc2cae5d22fbb3d672e5bd38bf3;p=thirdparty%2Fvala.git gtkdoc-importer: Add support for variablelist --- diff --git a/src/libvaladoc/documentation/gtkdoccommentparser.vala b/src/libvaladoc/documentation/gtkdoccommentparser.vala index a91e1f508..af547f4be 100644 --- a/src/libvaladoc/documentation/gtkdoccommentparser.vala +++ b/src/libvaladoc/documentation/gtkdoccommentparser.vala @@ -1185,9 +1185,12 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { return table; } - private LinkedList parse_docbook_section () { + private LinkedList? parse_docbook_section () { if (!check_xml_open_tag ("section")) { + this.report_unexpected_token (current, "
"); + return null; } + string id = current.attributes.get ("id"); next (); @@ -1202,6 +1205,166 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { return content; } + private ListItem? parse_docbook_member () { + if (!check_xml_open_tag ("member")) { + this.report_unexpected_token (current, ""); + return null; + } + next (); + + parse_docbook_spaces (); + + ListItem item = factory.create_list_item (); + Paragraph para = factory.create_paragraph (); + item.content.add (para); + + para.content.add (parse_inline_content ()); + + parse_docbook_spaces (); + + if (!check_xml_close_tag ("member")) { + this.report_unexpected_token (current, ""); + return item; + } + + next (); + return item; + } + + private Content.List? parse_docbook_simplelist () { + if (!check_xml_open_tag ("simplelist")) { + this.report_unexpected_token (current, ""); + return null; + } + next (); + + parse_docbook_spaces (); + + Content.List list = factory.create_list (); + + while (current.type == TokenType.XML_OPEN && current.content == "member") { + ListItem item = parse_docbook_member (); + if (item == null) { + break; + } + + list.items.add (item); + parse_docbook_spaces (); + } + + + if (!check_xml_close_tag ("simplelist")) { + this.report_unexpected_token (current, ""); + return list; + } + + next (); + return list; + } + + private Paragraph? parse_docbook_term () { + if (!check_xml_open_tag ("term")) { + this.report_unexpected_token (current, ""); + return null; + } + next (); + + parse_docbook_spaces (); + + Paragraph? p = factory.create_paragraph (); + Run run = parse_inline_content (); + run.style = Run.Style.ITALIC; + p.content.add (run); + + if (!check_xml_close_tag ("term")) { + this.report_unexpected_token (current, ""); + return p; + } + + next (); + return p; + } + + private ListItem? parse_docbook_varlistentry () { + if (!check_xml_open_tag ("varlistentry")) { + this.report_unexpected_token (current, ""); + return null; + } + next (); + + parse_docbook_spaces (); + + if (current.type != TokenType.XML_OPEN || current.content != "term") { + return null; + } + + Paragraph? term = parse_docbook_term (); + if (term == null) { + return null; + } + + parse_docbook_spaces (); + ListItem? desc = parse_docbook_listitem (); + if (desc == null) { + return null; + } + + parse_docbook_spaces (); + + Content.ListItem listitem = factory.create_list_item (); + Content.List list = factory.create_list (); + + listitem.content.add (term); + listitem.content.add (list); + list.items.add (desc); + + if (!check_xml_close_tag ("varlistentry")) { + this.report_unexpected_token (current, ""); + return listitem; + } + + next (); + return listitem; + } + + private LinkedList? parse_docbook_variablelist () { + if (!check_xml_open_tag ("variablelist")) { + this.report_unexpected_token (current, ""); + return null; + } + next (); + + parse_docbook_spaces (); + + LinkedList content = new LinkedList (); + + if (current.type == TokenType.XML_OPEN && current.content == "title") { + append_block_content_not_null (content, parse_docbook_title ()); + parse_docbook_spaces (); + } + + Content.List list = factory.create_list (); + content.add (list); + + while (current.type == TokenType.XML_OPEN && current.content == "varlistentry") { + ListItem item = parse_docbook_varlistentry (); + if (item == null) { + break; + } + + list.items.add (item); + parse_docbook_spaces (); + } + + if (!check_xml_close_tag ("variablelist")) { + this.report_unexpected_token (current, ""); + return content; + } + + next (); + return content; + } + private LinkedList parse_block_content () { LinkedList content = new LinkedList (); @@ -1210,6 +1373,10 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { if (current.type == TokenType.XML_OPEN && current.content == "itemizedlist") { this.append_block_content_not_null (content, parse_docbook_itemizedlist ()); + } else if (current.type == TokenType.XML_OPEN && current.content == "variablelist") { + this.append_block_content_not_null_all (content, parse_docbook_variablelist ()); + } else if (current.type == TokenType.XML_OPEN && current.content == "simplelist") { + this.append_block_content_not_null (content, parse_docbook_simplelist ()); } else if (current.type == TokenType.XML_OPEN && current.content == "informaltable") { this.append_block_content_not_null (content, parse_docbook_informaltable ()); } else if (current.type == TokenType.XML_OPEN && current.content == "programlisting") {