[gtk-doc] db2html: pass top-level 'id' to jinja



commit 2e2920d61ca9da406e0ccf4cf9d29788004b5ab0
Author: Stefan Sauer <ensonic users sf net>
Date:   Sun Dec 17 16:14:10 2017 +0100

    db2html: pass top-level 'id' to jinja
    
    This is used to generate local links.

 tools/db2html.py              |    9 ++++++++-
 tools/templates/refentry.html |    2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/tools/db2html.py b/tools/db2html.py
index f60e3ab..e01f942 100644
--- a/tools/db2html.py
+++ b/tools/db2html.py
@@ -27,7 +27,9 @@ like the xsl-stylesheets would do. For that it resolves all the xml-includes.
 TODO: convert the docbook-xml to html
 - more templates
 - refentry/index nav headers
-- for refsec, we need a 'long-title' that also contains refpurpose
+- for refsect, we need a 'long-title' that also contains refpurpose
+- figure how to deal with all the possible docbook
+  - how can we report 'unhandled' data
 
 Requirements:
 sudo pip3 install anytree jinja2 lxml
@@ -195,6 +197,11 @@ def convert(out_dir, files, node):
                 'title': node.title,
                 'nav_home': node.root,
             }
+            if 'id' in node.xml.attrib:
+                params['id'] = node.xml.attrib['id']
+            else:
+                # TODO: generate?
+                logging.warning('No top-level "id" for "%s"', node.xml.tag)
             # nav params: up, prev, next
             if node.parent:
                 params['nav_up'] = node.parent
diff --git a/tools/templates/refentry.html b/tools/templates/refentry.html
index ca0609b..7fe0be2 100644
--- a/tools/templates/refentry.html
+++ b/tools/templates/refentry.html
@@ -13,7 +13,7 @@
 <div class="refnamediv">
   <table width="100%"><tr>
     <td valign="top">
-      <h2><span class="refentrytitle"><a name="tester-GtkdocTester.top_of_page"></a>{{ title }}</span></h2>
+      <h2><span class="refentrytitle"><a name="{{ id }}.top_of_page"></a>{{ title }}</span></h2>
       <p>{{ title }} — module for gtk-doc unit test</p>
     </td>
     <td class="gallery_image" valign="top" align="right"></td>


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