summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2018-01-14 12:41:08 +0100
committerStefan Sauer <ensonic@users.sf.net>2018-01-14 13:02:02 +0100
commita713f437fd7088c8c1b0749517912d24cd19ccb4 (patch)
treea1ebeff47b30cac094e1e927db8d153d20b8435f /tools
parentc28aed340b59c9505dc5124fe21dd30788f75666 (diff)
downloadgtk-doc-a713f437fd7088c8c1b0749517912d24cd19ccb4.tar.gz
db2html: avoid some string concats for performance
Diffstat (limited to 'tools')
-rw-r--r--tools/db2html.py22
1 files changed, 6 insertions, 16 deletions
diff --git a/tools/db2html.py b/tools/db2html.py
index 4e3eab4..6e1d023 100644
--- a/tools/db2html.py
+++ b/tools/db2html.py
@@ -25,17 +25,8 @@ The tool loaded the main xml document (<module>-docs.xml) and chunks it
like the xsl-stylesheets would do. For that it resolves all the xml-includes.
TODO: convert the docbook-xml to html
-- more templates
+- more templates or maybe don't use the templates at all
- refentry/index nav headers
-- 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
-- we need a generic transform for everything in a para (and others like
- releaseinfo)
- - this will walk the tree and replace nodes to convert from docbook to html
- - we can start with 1:1, but most likely each transform will be a function
- that mangles the sub tree and recurses for certain children (kind of what
- xslt does)
OPTIONAL:
- minify html: https://pypi.python.org/pypi/htmlmin/
@@ -193,10 +184,10 @@ def chunk(xml_node, parent=None):
def convert__inner(xml):
- result = ''
+ result = []
for child in xml:
- result += convert_tags.get(child.tag, convert__unknown)(child)
- return result
+ result.append(convert_tags.get(child.tag, convert__unknown)(child))
+ return ''.join(result)
def convert_ignore(xml):
@@ -298,10 +289,9 @@ def convert_phrase(xml):
result += xml.tail
return result
-# TODO: encode entities
-
def convert_programlisting(xml):
+ # TODO: encode entities
result = '<pre class="programlisting">'
if xml.text:
result += xml.text
@@ -367,7 +357,7 @@ def convert(out_dir, files, node):
logging.info('Writing: %s', node.filename)
with open(os.path.join(out_dir, node.filename), 'wt') as html:
if node.name in TEMPLATES:
- # TODO: ideally precomiple common xpath exprs once:
+ # TODO: ideally precompile common xpath exprs once:
# func = etree.XPath('//b')
# func(xml_node)[0]
# unused, we can call api :)