summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2017-12-20 10:42:42 +0100
committerStefan Sauer <ensonic@users.sf.net>2017-12-20 10:42:42 +0100
commit1e1117e5f5d00a2e3ac4132255e4e3911da03746 (patch)
tree4534711f812a4c6d0dd68afc9ee4fdd40d090544 /tools
parent06baafc09e244a7f3e5e8f9849e83c5d6c6783d4 (diff)
downloadgtk-doc-1e1117e5f5d00a2e3ac4132255e4e3911da03746.tar.gz
db2html: more work toward making content to show up
Refsects now have the basic structure. Some content shows up on index.html too.
Diffstat (limited to 'tools')
-rw-r--r--tools/db2html.py20
-rw-r--r--tools/templates/book.html4
-rw-r--r--tools/templates/refentry.html8
3 files changed, 29 insertions, 3 deletions
diff --git a/tools/db2html.py b/tools/db2html.py
index e01f942..c1a3e33 100644
--- a/tools/db2html.py
+++ b/tools/db2html.py
@@ -30,6 +30,10 @@ TODO: convert the docbook-xml to html
- 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
+
+OPTIONAL:
+- minify html: https://pypi.python.org/pypi/htmlmin/
Requirements:
sudo pip3 install anytree jinja2 lxml
@@ -188,12 +192,18 @@ def convert(out_dir, files, node):
# TODO: ideally precomiple common xpath exprs once:
# func = etree.XPath('//b')
# func(xml_node)[0]
- def lxml_xpath(expr):
- return node.xml.xpath(expr, smart_strings=False)[0]
+ # unused, we can call api :)
+ # def lxml_xpath_str0(xml, expr):
+ # return xml.xpath(expr, smart_strings=False)[0]
+ #
+ # def lxml_xpath(xml, expr):
+ # return xml.xpath(expr)
template = TEMPLATES[node.name]
- template.globals['xpath'] = lxml_xpath
+ # template.globals['xpath'] = lxml_xpath
+ # template.globals['xpath_str0'] = lxml_xpath_str0
params = {
+ 'xml': node.xml,
'title': node.title,
'nav_home': node.root,
}
@@ -215,6 +225,10 @@ def convert(out_dir, files, node):
# 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
html.write(template.render(**params))
else:
diff --git a/tools/templates/book.html b/tools/templates/book.html
index ce37a3f..8546bb2 100644
--- a/tools/templates/book.html
+++ b/tools/templates/book.html
@@ -11,6 +11,10 @@
<div class="book">
<div class="titlepage">
{{ navigation_main(title) }}
+{% set releaseinfo=xml.find('bookinfo/releaseinfo') %}
+{% if releaseinfo %}
+{{ releaseinfo.text }}
+{% endif %}
<hr>
</div>
<div class="toc">
diff --git a/tools/templates/refentry.html b/tools/templates/refentry.html
index 7fe0be2..1e4bb74 100644
--- a/tools/templates/refentry.html
+++ b/tools/templates/refentry.html
@@ -10,6 +10,7 @@
<body>
{{ navigation_ref(nav_home, nav_up, nav_prev, nav_next) }}
<div class="refentry">
+<a name="{{ id }}"></a>
<div class="refnamediv">
<table width="100%"><tr>
<td valign="top">
@@ -19,6 +20,13 @@
<td class="gallery_image" valign="top" align="right"></td>
</tr></table>
</div>
+
+{%- for sect in xml.findall('refsect1') %}
+<div class="refsect1">
+<a name="{{ sect.attrib['id'] }}"></a><h2>{{ sect.findtext('title') }}</h2>
+</div>
+{%- endfor %}
+
</div>
</body>
</html> \ No newline at end of file