3 # Support both Python 2 and 3
4 from __future__ import print_function
6 import os, sys, argparse, subprocess
10 xsltproc = '@XSLTPROC@'
12 parser = argparse.ArgumentParser(description='gtkdoc-mkman version %s - generate documentation in man format' % version)
14 parser.add_argument('--verbose', default=False, action='store_true',
15 help='Print extra output while processing')
16 parser.add_argument('--path', default='',
17 help='Extra source directories')
18 parser.add_argument('version', default=False, action='store_true',
19 help='Print the version of this program')
20 parser.add_argument('args', nargs=2,
21 help='MODULE DRIVER_FILE')
22 parser.add_argument('--uninstalled', action='store_true', default=False,
25 options = parser.parse_args()
30 module=options.args[0]
31 document=options.args[1]
37 if options.uninstalled:
38 # this does not work from buiddir!=srcdir
39 gtkdocdir=os.path.split(sys.argv[0])[0]
40 #echo "uninstalled, gtkdocdir=$gtkdocdir"
42 # the first two are needed to resolve datadir
44 datarootdir='@datarootdir@'
45 gtkdocdir='@datadir@/gtk-doc/data'
47 if "<?xml" in open(document).readline():
52 path_option='--directory'
55 # we could do "$path_option $PWD "
56 # to avoid needing rewriting entities that are copied from the header
58 if options.path == '':
61 path_arg=[path_option, options.path]
63 # would it make sens to create man pages only for certain refentries
66 # see http://bugzilla.gnome.org/show_bug.cgi?id=467488
67 subprocess.check_call([xsltproc] + path_arg +[
80 'chunker.output.quiet',
82 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
85 for i in glob('sgml/*.sgml'):
86 j = os.path.split(i)[1].replace('.sgml', '.man')
87 print("converting ", i, j)
88 subproject.check_call(['docbook-to-man', i],
90 stderr=open('man/%s.log' % j))