From 3be46ab1e1fd42bb35d62f2e35c813a083a14229 Mon Sep 17 00:00:00 2001
From: Stefan Sauer
Date: Thu, 11 Jan 2018 18:44:05 +0100
Subject: [PATCH] db2html: add more content
Also recurse for unknown tags. Only warn once for them.
---
tools/db2html.py | 18 ++++++++++++++----
tools/templates/refentry.html | 2 ++
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/tools/db2html.py b/tools/db2html.py
index ab485d2..fac82cd 100644
--- a/tools/db2html.py
+++ b/tools/db2html.py
@@ -191,13 +191,22 @@ def chunk(xml_node, parent=None):
def convert__inner(xml):
result = ''
for child in xml:
- result += convert_tags.get(child.tag)(child)
+ result += convert_tags.get(child.tag, convert__unknown)(child)
return result
+missing_tags = {}
+
+
def convert__unknown(xml):
- logging.warning('Add tag converter for "%s"', xml.tag)
- return '\n'
+ # TODO: warn only once
+ if xml.tag not in missing_tags:
+ logging.warning('Add tag converter for "%s"', xml.tag)
+ missing_tags[xml.tag] = True
+ result = '\n'
+ result += convert__inner(xml)
+ result += '\n'
+ return result
def convert_para(xml):
@@ -207,7 +216,7 @@ def convert_para(xml):
if xml.text:
result += xml.text
result += convert__inner(xml)
- result += '\n
'
+ result += ''
if xml.tail:
result += xml.tail
return result
@@ -243,6 +252,7 @@ def convert(out_dir, files, node):
template = TEMPLATES[node.name]
template.globals['convert_para'] = convert_para
+ template.globals['convert_inner'] = convert__inner
params = {
'xml': node.xml,
'title': node.title,
diff --git a/tools/templates/refentry.html b/tools/templates/refentry.html
index 152e798..9ec4e51 100644
--- a/tools/templates/refentry.html
+++ b/tools/templates/refentry.html
@@ -24,6 +24,8 @@
{%- for sect in xml.findall('refsect1') %}
{{ sect.findtext('title') }}
+{# TODO: can we remove title so that we don't copy this again #}
+{{ convert_inner(sect) }}
{%- endfor %}
--
2.11.4.GIT