aboutsummaryrefslogtreecommitdiff
path: root/newlib/doc/chapter-texi2docbook.py
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2016-06-24 21:50:15 +0100
committerJon Turney <jon.turney@dronecode.org.uk>2016-07-04 14:17:10 +0100
commit0b4cbd2fb82ba588a82c148bd723e46dea05d523 (patch)
treefccdea463458c2cb5536c151b839ccfa42795eb5 /newlib/doc/chapter-texi2docbook.py
parent85db21730beb3bb40723fa9b9f2dea5016fc4b4c (diff)
downloadnewlib-0b4cbd2fb82ba588a82c148bd723e46dea05d523.zip
newlib-0b4cbd2fb82ba588a82c148bd723e46dea05d523.tar.gz
newlib-0b4cbd2fb82ba588a82c148bd723e46dea05d523.tar.bz2
Make newlib manpages (v3)
Add makedocbook, a tool to process makedoc markup and output DocBook XML refentries. Process all the source files which are processed with makedoc with makedocbook as well Add chapter-texi2docbook, a tool to automatically generate DocBook XML chapter files from the chapter .texi files. For generating man pages all we care about is the content of the refentries, so all this needs to do is convert the @include of the makedoc generated .def files to xi:include of the makedocbook generated .xml files. Add skeleton Docbook XML book files, lib[cm].in.xml which include these generated chapters, which in turn include the generated files containing refentries, which is processed with xsltproc to generate the lib[cm].xml Add new make targets to generate and install man pages from lib[cm].xml
Diffstat (limited to 'newlib/doc/chapter-texi2docbook.py')
-rwxr-xr-xnewlib/doc/chapter-texi2docbook.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/newlib/doc/chapter-texi2docbook.py b/newlib/doc/chapter-texi2docbook.py
new file mode 100755
index 0000000..eb606dc
--- /dev/null
+++ b/newlib/doc/chapter-texi2docbook.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+#
+# python script to convert the handwritten chapter .texi files, which include
+# the generated files for each function, to DocBook XML
+#
+# all we care about is the content of the refentries, so all this needs to do is
+# convert the @include of the makedoc generated .def files to xi:include of the
+# makedocbook generated .xml files.
+#
+
+from __future__ import print_function
+import sys
+import re
+
+def main():
+ first_node = True
+
+ print ('<?xml version="1.0" encoding="UTF-8"?>')
+ print ('<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">')
+
+ for l in sys.stdin.readlines():
+ l = l.rstrip()
+
+ # transform @file{foo} to <filename>foo</filename>
+ l = re.sub("@file{(.*?)}", "<filename>\\1</filename>", l)
+
+ if l.startswith("@node"):
+ l = l.replace("@node", "", 1)
+ l = l.strip()
+ l = l.lower()
+ if first_node:
+ print ('<chapter id="%s" xmlns:xi="http://www.w3.org/2001/XInclude">' % l.replace(' ', '_'))
+ first_node = False
+ elif l.startswith("@chapter "):
+ l = l.replace("@chapter ", "", 1)
+ print ('<title>%s</title>' % l)
+ elif l.startswith("@include "):
+ l = l.replace("@include ", "", 1)
+ l = l.replace(".def", ".xml", 1)
+ print ('<xi:include href="%s"/>' % l.strip())
+
+ print ('</chapter>')
+
+if __name__ == "__main__" :
+ main()