[gtk-doc] mkhtml2: add boilerplate to generate the devhelp2 files



commit 278b9f354aab6c991f4818b8fffc74695a4adcde
Author: Stefan Sauer <ensonic users sf net>
Date:   Fri Mar 2 22:22:06 2018 +0100

    mkhtml2: add boilerplate to generate the devhelp2 files

 gtkdoc-mkhtml2.in |    4 ++--
 gtkdoc/mkhtml2.py |   41 +++++++++++++++++++++++++++++++++++------
 2 files changed, 37 insertions(+), 8 deletions(-)
---
diff --git a/gtkdoc-mkhtml2.in b/gtkdoc-mkhtml2.in
index b532a30..8928678 100644
--- a/gtkdoc-mkhtml2.in
+++ b/gtkdoc-mkhtml2.in
@@ -30,10 +30,10 @@ if __name__ == '__main__':
         description='gtkdoc-mkhtml version %s - generate documentation in html format' % config.version)
     parser.add_argument('--version', action='version', version=config.version)
     parser.add_argument('args', nargs='*',
-                        help='DRIVER_FILE')
+                        help='MODULE DRIVER_FILE')
 
     options = parser.parse_args()
-    if len(options.args) != 1:
+    if len(options.args) != 2:
         sys.exit('Too few arguments')
 
     common.setup_logging()
diff --git a/gtkdoc/mkhtml2.py b/gtkdoc/mkhtml2.py
index 975a577..6a0fe7f 100644
--- a/gtkdoc/mkhtml2.py
+++ b/gtkdoc/mkhtml2.py
@@ -848,7 +848,36 @@ def convert(out_dir, files, node):
             logging.warning('Add converter/template for "%s"', node.name)
 
 
-def main(index_file):
+def create_devhelp2(out_dir, module, xml):
+    with open(os.path.join(out_dir, module + '.devhelp2'), 'wt') as idx:
+        bookinfo_nodes = xml.xpath('/book/bookinfo')
+        title = ''
+        if bookinfo_nodes is not None:
+            bookinfo = bookinfo_nodes[0]
+            title = bookinfo.xpath('./title/text()')[0]
+            online_url = bookinfo.xpath('./releaseinfo/ulink[@role="online-location"]/@url')[0]
+            # TODO: support author too (see devhelp2.xsl)
+        # TODO: fixxref uses '--src-lang' to set the language
+        result = [
+            """<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<book xmlns="http://www.devhelp.net/book"; title="%s" link="index.html" author="" name="%s" version="2" 
language="c" online="%s">
+  <chapters>
+""" % (title, module, online_url)
+        ]
+        # TODO: toc under 'chapter'
+        result.append("""  </chapters>
+  <functions>
+""")
+        # TODO: keywords under 'functions' from all refsect2 and refsect3
+
+        result.append("""  </functions>
+</book>
+""")
+        for line in result:
+            idx.write(line)
+
+
+def main(module, index_file):
     tree = etree.parse(index_file)
     tree.xinclude()
 
@@ -879,12 +908,12 @@ def main(index_file):
     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
+    # 3) create a xxx.devhelp2 file
+    create_devhelp2(out_dir, module, tree.getroot())
 
 
 def run(options):
     logging.info('options: %s', str(options.__dict__))
-    document = options.args[0]
-    sys.exit(main(document))
+    module = options.args[0]
+    document = options.args[1]
+    sys.exit(main(module, document))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]