[gtk-doc] db2html: improve chunking



commit 5497c6e0c95f813aa15ffd889addd2da84333f6f
Author: Stefan Sauer <ensonic users sf net>
Date:   Wed Feb 21 21:47:53 2018 +0100

    db2html: improve chunking
    
    Add more chunk settings. Make local-title the default xpath.

 tools/db2html.py |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/tools/db2html.py b/tools/db2html.py
index 2cb4b8f..db2d1ba 100644
--- a/tools/db2html.py
+++ b/tools/db2html.py
@@ -104,18 +104,20 @@ class ChunkParams(object):
 
 # TODO: look up the abbrevs and hierarchy for other tags
 # http://www.sagehill.net/docbookxsl/Chunking.html#GeneratedFilenames
+# https://github.com/oreillymedia/HTMLBook/blob/master/htmlbook-xsl/chunk.xsl#L33
 CHUNK_PARAMS = {
+    'appendix': ChunkParams('app', 'book'),
     'book': ChunkParams('bk'),
     'chapter': ChunkParams('ch', 'book'),
     'index': ChunkParams('ix', 'book'),
+    'part': ChunkParams('part', 'book'),
     'sect1': ChunkParams('s', 'chapter'),
     'section': ChunkParams('s', 'chapter'),
 }
 
 TITLE_XPATHS = {
+    '_': (etree.XPath('./title'), None),
     'book': (etree.XPath('./bookinfo/title'), None),
-    'chapter': (etree.XPath('./title'), None),
-    'index': (etree.XPath('./title'), None),
     'refentry': (
         etree.XPath('./refmeta/refentrytitle'),
         etree.XPath('./refnamediv/refpurpose')
@@ -150,15 +152,11 @@ def gen_chunk_name(node):
 def get_chunk_titles(node):
     tag = node.tag
     if tag not in TITLE_XPATHS:
-        logging.warning('Add TITLE_XPATHS for "%s"', tag)
-        # TODO: should we try './title/text()' as a default?
-        return {
-            'title': '',
-            'title_tag': tag,
-            'subtitle': None
-        }
+        # Use defaults
+        (title, subtitle) = TITLE_XPATHS['_']
+    else:
+        (title, subtitle) = TITLE_XPATHS[tag]
 
-    (title, subtitle) = TITLE_XPATHS[tag]
     xml = title(node)[0]
     result = {
         'title': xml.text


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