[gtk-doc] db2html: more work toward making content to show up
- From: Stefan Sauer <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] db2html: more work toward making content to show up
- Date: Wed, 20 Dec 2017 09:44:07 +0000 (UTC)
commit 1e1117e5f5d00a2e3ac4132255e4e3911da03746
Author: Stefan Sauer <ensonic users sf net>
Date: Wed Dec 20 10:42:42 2017 +0100
db2html: more work toward making content to show up
Refsects now have the basic structure. Some content shows up on index.html
too.
tools/db2html.py | 20 +++++++++++++++++---
tools/templates/book.html | 4 ++++
tools/templates/refentry.html | 8 ++++++++
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]