From ab167080ada8e6bc871a337903e0b326b9ea6a2d Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Wed, 14 Feb 2018 07:51:44 +0100 Subject: [PATCH] db2html: some cleanup and planning Reuse the nav_home var and remove the page specific vars. Add some comments for further refinement. --- tools/db2html.py | 23 +++++++++++++---------- tools/templates/book.html | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/db2html.py b/tools/db2html.py index 968c1e4..c8c9121 100644 --- a/tools/db2html.py +++ b/tools/db2html.py @@ -530,14 +530,12 @@ def convert(out_dir, files, node): if ix < len(files) - 1: params['nav_next'] = files[ix + 1] - # page specific vars - # TODO: extract into functions? - if node.name == 'book': - params['toc'] = node.root - elif node.name == 'refsect': - # TODO: toc params from xml - # all refsect1 + refsect1/title/text() from xml - pass + # TODO: call a top-level python converter instead + # generate_{book,chapter,index,refentry}(files, node) + # xml is node.xml + # We need to rewrite all other converters to take + # (xml, files, node) or (xml, params) + # where params is sort of like what we have above html.write(template.render(**params)) else: @@ -562,15 +560,20 @@ def main(index_file): if e.errno != errno.EEXIST: raise - # We need two passes: + # We need multiple passes: # 1) recursively walk the tree and chunk it into a python tree so that we - # can generate navigation and link tags + # can generate navigation and link tags. + # also collect all 'id' attributes on the way and build map of + # id:rel-link (in fixxref is is Links[]) files = chunk(tree.getroot()) # 2) iterate the tree and output files # TODO: use multiprocessing files = list(PreOrderIter(files)) for node in files: convert(out_dir, files, node) + # 3) create a devhelp2.xsl + # - toc under 'chapter' + # - keywords under 'functions' from all refsect2 and refsect3 if __name__ == '__main__': diff --git a/tools/templates/book.html b/tools/templates/book.html index 58e32f3..df315ae 100644 --- a/tools/templates/book.html +++ b/tools/templates/book.html @@ -19,7 +19,7 @@
- {%- for item in toc.children recursive %} + {%- for item in nav_home.children recursive %}
{{ item.title }} {%- if item.children -%}
{{ loop(item.children) }}
-- 2.11.4.GIT