[gtk-doc] db2html: change id generator to be based on the xml-tree



commit 18f6c53608ef904c81ec4aebc5ee4e0258a77028
Author: Stefan Sauer <ensonic users sf net>
Date:   Thu Feb 22 21:09:10 2018 +0100

    db2html: change id generator to be based on the xml-tree

 tools/db2html.py |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/tools/db2html.py b/tools/db2html.py
index 1cc3180..639ed46 100644
--- a/tools/db2html.py
+++ b/tools/db2html.py
@@ -685,18 +685,17 @@ def get_id(node):
         return node_id
 
     logging.warning('%d: No "id" attribute on "%s"', xml.sourceline, xml.tag)
-    # Generate the 'id'. We need to walk up the tree and check the positions
-    # for each sibling.
-    # TODO(ensonic): we're doing it on the chunk level, do we need to do this on
-    # the xml tree? For one example we expect 'id-1.2' but generated 'id-1'
-    # See docbook-xsl/common/common.xsl:468
     ix = []
-    while node.parent:
-        children = node.parent.children
-        ix.insert(0, str(children.index(node) + 1))
-        node = node.parent
-    # logging.warning('indexes: %s', str(ix))
-    return 'id-' + '.'.join(ix)
+    # Generate the 'id'. We need to walk up the xml-tree and check the positions
+    # for each sibling.
+    parent = xml.getparent()
+    while parent is not None:
+        children = parent.getchildren()
+        ix.insert(0, str(children.index(xml) + 1))
+        xml = parent
+        parent = xml.getparent()
+    # logging.warning('%s: id indexes: %s', node.filename, str(ix))
+    return 'id-1.' + '.'.join(ix)
 
 # docbook chunks
 


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