]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
gtkdoc-parser: Add a helper for mixed content
authorFlorian Brosch <flo.brosch@gmail.com>
Sun, 29 Jan 2012 03:04:47 +0000 (04:04 +0100)
committerFlorian Brosch <flo.brosch@gmail.com>
Sun, 29 Jan 2012 03:06:47 +0000 (04:06 +0100)
src/libvaladoc/documentation/gtkdoccommentparser.vala

index c3f24c5b6fd05ca6152525a570dc793ef8751ecb..c6b16c0eb7905fc9b359d69840be2b9c64c8e531 100644 (file)
@@ -676,17 +676,10 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
                return p;
        }
 
-       private LinkedList<Paragraph>? parse_docbook_para () {
-               if (!check_xml_open_tag ("para")) {
-                       this.report_unexpected_token (current, "<para>");
-                       return null;
-               }
-
-               next ();
-
-               LinkedList<Paragraph> content = new LinkedList<Paragraph> ();
-
+       private LinkedList<Block> parse_mixed_content () {
+               LinkedList<Block> content = new LinkedList<Block> ();
                Token tmp = null;
+
                while (tmp != current) {
                        tmp = current;
                        parse_docbook_spaces ();
@@ -706,6 +699,19 @@ 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>");
+                       return null;
+               }
+
+               next ();
+
+               LinkedList<Block> content = parse_mixed_content ();
+
                if (!check_xml_close_tag ("para")) {
                        this.report_unexpected_token (current, "</para>");
                        return content;
@@ -896,23 +902,27 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
                        parse_docbook_spaces ();
                }
 
+
+               content.add_all (parse_mixed_content ());
+
+               /*
                while (current.type == TokenType.XML_OPEN) {
-                       if (current.content == "inlinegraphic") {
+                       if (current.type == TokenType.XML_OPEN && current.content == "inlinegraphic") {
                                Paragraph p = factory.create_paragraph ();
                                while (current.type == TokenType.XML_OPEN && current.content == "inlinegraphic") {
                                        p.content.add (parse_docbook_inlinegraphic ());
-                                       next ();
                                        parse_docbook_spaces ();
                                }
-                       } else if (current.content == "programlisting") {
+                       } else if (current.type == TokenType.XML_OPEN && current.content == "programlisting") {
                                append_block_content_not_null (content, parse_docbook_programlisting ());
-                               next ();
+                       } else if (current.type == TokenType.XML_OPEN && current.content == "para") {
+                               this.append_block_content_not_null_all (content, parse_docbook_para ());
                        } else {
                                break;
                        }
 
                        parse_docbook_spaces ();
-               }
+               } */
 
                if (!check_xml_close_tag (tag_name)) {
                        this.report_unexpected_token (current, "</%s>".printf (tag_name));
@@ -977,12 +987,10 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
 
                                while (current.type == TokenType.XML_OPEN && current.content == "inlinegraphic") {
                                        p.content.add (parse_docbook_inlinegraphic ());
-                                       next ();
                                        parse_docbook_spaces ();
                                }
                        } else if (current.content == "graphic") {
                                append_block_content_not_null (content, parse_docbook_graphic ());
-                               next ();
                        } else {
                                break;
                        }
@@ -1012,25 +1020,7 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
                LinkedList<Block> content = new LinkedList<Block> ();
                this.footnotes.add (content);
 
-               Token tmp = null;
-               while (tmp != current) {
-                       tmp = current;
-                       parse_docbook_spaces ();
-
-                       Run? run = parse_inline_content ();
-                       if (run != null && run.content.size > 0) {
-                               Paragraph p = factory.create_paragraph ();
-                               p.content.add (run);
-                               content.add (p);
-                               continue;
-                       }
-
-                       LinkedList<Block> lst = parse_block_content ();
-                       if (lst != null && run.content.size > 0) {
-                               content.add_all (lst);
-                               continue;
-                       }
-               }
+               content.add_all (parse_mixed_content ());
 
                Paragraph? first = (content.is_empty)? null : content.first () as Paragraph;
                if (first == null) {