3 # python script to convert the handwritten chapter .texi files, which include
4 # the generated files for each function, to DocBook XML
6 # all we care about is the content of the refentries, so all this needs to do is
7 # convert the @include of the makedoc generated .def files to xi:include of the
8 # makedocbook generated .xml files.
11 from __future__
import print_function
19 print('<?xml version="1.0" encoding="UTF-8"?>')
20 print('<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">')
22 for l
in sys
.stdin
.readlines():
25 # transform @file{foo} to <filename>foo</filename>
26 l
= re
.sub("@file{(.*?)}", "<filename>\\1</filename>", l
)
28 if l
.startswith("@node"):
29 l
= l
.replace("@node", "", 1)
32 print('<chapter id="%s_chapter" xmlns:xi="http://www.w3.org/2001/XInclude">' % l
.lower().replace(' ', '_'))
37 print('<section id="%s">' % l
)
39 elif l
.startswith("@chapter "):
40 l
= l
.replace("@chapter ", "", 1)
41 print('<title>%s</title>' % l
)
42 elif l
.startswith("@section "):
43 l
= l
.replace("@section ", "", 1)
44 print('<title>%s</title>' % l
)
45 elif l
.startswith("@include "):
46 l
= l
.replace("@include ", "", 1)
47 l
= l
.replace(".def", ".xml", 1)
48 print('<xi:include href="%s"/>' % l
.strip())
54 if __name__
== "__main__":