[gtk-doc] mkhtml: add more doc-snippets to test main converters



commit b26a27e5f5fc54a914acf682b9f080d2e599c5b2
Author: Stefan Sauer <ensonic users sf net>
Date:   Tue Feb 19 07:47:45 2019 +0100

    mkhtml: add more doc-snippets to test main converters
    
    Fix handling of empty index files.

 gtkdoc/mkhtml2.py |  5 +++-
 tests/mkhtml2.py  | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 80 insertions(+), 5 deletions(-)
---
diff --git a/gtkdoc/mkhtml2.py b/gtkdoc/mkhtml2.py
index fc458af..4d04ec2 100644
--- a/gtkdoc/mkhtml2.py
+++ b/gtkdoc/mkhtml2.py
@@ -1504,7 +1504,10 @@ def convert_glossary(ctx):
 def convert_index(ctx):
     node = ctx['node']
     # Get all indexdivs under indexdiv
-    indexdivs = node.xml.find('indexdiv').findall('indexdiv')
+    indexdivs = []
+    indexdiv = node.xml.find('indexdiv')
+    if indexdiv is not None:
+        indexdivs = indexdiv.findall('indexdiv')
 
     result = [
         HTML_HEADER % (node.title + ": " + node.root.title, generate_head_links(ctx)),
diff --git a/tests/mkhtml2.py b/tests/mkhtml2.py
index 187b986..8b97922 100755
--- a/tests/mkhtml2.py
+++ b/tests/mkhtml2.py
@@ -246,6 +246,14 @@ class TestConverter(unittest.TestCase):
           </bookinfo>
         </book>""")
 
+    xml_book_preface = textwrap.dedent("""\
+        <book>
+          <bookinfo>
+            <title>test Reference Manual</title>
+          </bookinfo>
+          <preface id="intro"><title>Intro</title></preface>
+        </book>""")
+
     xml_book_chapter = textwrap.dedent("""\
         <book>
           <bookinfo>
@@ -280,6 +288,65 @@ class TestConverter(unittest.TestCase):
           </chapter>
         </book>""")
 
+    xml_book_index_empty = textwrap.dedent("""\
+        <book>
+          <bookinfo>
+            <title>test Reference Manual</title>
+          </bookinfo>
+          <index id="api-index-full">
+            <title>API Index</title>
+          </index>
+        </book>""")
+
+    xml_book_index = textwrap.dedent("""\
+        <book>
+          <bookinfo>
+            <title>test Reference Manual</title>
+          </bookinfo>
+          <index id="api-index-full">
+            <title>API Index</title>
+            <indexdiv id="api-index-full">
+              <indexdiv><title>O</title>
+                <!-- we get a link warning, since we we don't include the 'refentry' -->
+                <!--indexentry>
+                  <primaryie linkends="gtkdoc-object-new">
+                    <link linkend="gtkdoc-object-new">gtkdoc_object_new</link>,
+                    function in <link linkend="GtkdocObject">GtkdocObject</link>
+                  </primaryie>
+                </indexentry-->
+              </indexdiv>
+            </indexdiv>
+          </index>
+        </book>""")
+
+    xml_book_glossary_empty = textwrap.dedent("""\
+        <book>
+          <bookinfo>
+            <title>test Reference Manual</title>
+          </bookinfo>
+          <glossary id="glossary">
+            <title>Glossary</title>
+          </glossary>
+        </book>""")
+
+    xml_book_glossary = textwrap.dedent("""\
+        <book>
+          <bookinfo>
+            <title>test Reference Manual</title>
+          </bookinfo>
+          <glossary id="glossary">
+            <title>Glossary</title>
+            <glossdiv><title>A</title>
+              <glossentry>
+                <glossterm><anchor id="glossterm-API"/>API</glossterm>
+                <glossdef>
+                  <para>Application Programming Interface</para>
+                </glossdef>
+              </glossentry>
+            </glossdiv>
+          </glossary>
+        </book>""")
+
     # def setUp(self):
     #     logging.basicConfig(
     #         level=logging.INFO,
@@ -292,10 +359,15 @@ class TestConverter(unittest.TestCase):
         return '\n'.join(mkhtml2.convert_content('test', nodes, nodes[ix], 'c'))
 
     @parameterized.expand([
-      ('book', (xml_book, 0)),
-      ('chapter', (xml_book_chapter, 1)),
-      ('part', (xml_book_part_chapter, 1)),
-      ('refentry', (xml_book_chapter_refentry, 2)),
+        ('book', (xml_book, 0)),
+        ('preface', (xml_book_preface, 1)),
+        ('chapter', (xml_book_chapter, 1)),
+        ('part', (xml_book_part_chapter, 1)),
+        ('refentry', (xml_book_chapter_refentry, 2)),
+        ('index', (xml_book_index, 1)),
+        ('index_empty', (xml_book_index_empty, 1)),
+        ('glossary', (xml_book_glossary, 1)),
+        ('glossary_empty', (xml_book_glossary_empty, 1)),
     ])
     def test_convert_produces_html(self, _, params):
         html = self.convert(params[0], params[1])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]