check: move arg handling to launcher
[gtk-doc.git] / gtkdoc-mkman.in
blobebb9c3ad2c9c7158110d2ebb4948ce3d7c888665
1 #!@PYTHON@
3 # Support both Python 2 and 3
4 from __future__ import print_function
6 import os, sys, argparse, subprocess
7 from glob import glob
9 version = '@VERSION@'
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,
23                     help='???')
25 options = parser.parse_args()
26 if options.version:
27     print(version)
28     sys.exit(0)
30 module=options.args[0]
31 document=options.args[1]
32 if options.verbose:
33     quiet = '0'
34 else:
35     quiet = '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"
41 else:
42     # the first vars are needed to resolve datadir
43     prefix='@prefix@'
44     datarootdir="@datarootdir@".replace('${prefix}', prefix)
45     datadir="@datadir@".replace('${datarootdir}', datarootdir)
46     gtkdocdir=os.path.join(datadir, 'gtk-doc/data')
48 # we could do "$path_option $PWD "
49 # to avoid needing rewriting entities that are copied from the header
50 # into docs under xml
51 if options.path == '':
52     path_arg=[]
53 else:
54     path_arg=[path_option, options.path]
56 # would it make sense to create man pages only for certain refentries
57 # e.g. for tools
58 # see http://bugzilla.gnome.org/show_bug.cgi?id=467488
59 subprocess.check_call([xsltproc] + path_arg +[
60     '--nonet',
61     '--xinclude',
62     '--stringparam',
63     'gtkdoc.bookname',
64     module,
65     '--stringparam',
66     'gtkdoc.version',
67     version,
68     '--stringparam',
69     'chunk.quietly ',
70     quiet,
71     '--stringparam',
72     'chunker.output.quiet',
73     quiet,
74     'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
75     document])