3 # Support both Python 2 and 3
4 from __future__ import print_function
6 import os, sys, argparse, subprocess, shutil
10 xsltproc = '@XSLTPROC@'
12 parser = argparse.ArgumentParser(description='gtkdoc-mkhtml version %s - generate documentation in html 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=[], action='append',
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='*',
21 help='MODULE DRIVER_FILE')
22 parser.add_argument('--uninstalled', action='store_true', default=False,
25 options = parser.parse_args()
30 if len(options.args) < 2:
31 sys.exit('Too few arguments')
33 module=options.args[0]
34 document=options.args[1]
39 remaining_args = options.args[2:]
41 if options.uninstalled:
42 # this does not work from buiddir!=srcdir
43 gtkdocdir = os.path.split(sys.argv[0])[0]
44 # traditional Bourne shells may not support -e here, use -f
45 if not os.path.exists(gtkdocdir + '/gtk-doc.xsl'):
46 # try to src dir (set from makefiles) too
47 if os.path.exists(os.path.environ.get("ABS_TOP_SRCDIR", '') + '/gtk-doc.xsl'):
48 gtkdocdir=os.path.environ['ABS_TOP_SRCDIR']
49 styledir=gtkdocdir + '/style'
50 #echo "uninstalled, gtkdocdir=$gtkdocdir, cwd=$PWD"
52 # the first two are needed to resolve datadir
54 datarootdir='@datarootdir@'
55 gtkdocdir='@datadir@/gtk-doc/data'
58 # We need to use a wrapper because there's no other way to conditionally pass
59 # a `--path $searchpath` argument with proper quoting for the path
60 def run_xsltproc(args):
61 # we could do "$path_option $PWD "
62 # to avoid needing rewriting entities that are copied from the header
64 if os.environ.get("GTKDOC_PROFILE", '') == '':
66 subprocess.check_call([xsltproc] + args)
68 subprocess.check_call([xsltproc, '--path'] + options.path + args)
70 if len(options.path) == 0:
71 subprocess.check_call([xsltproc, '--profile'] + args, stderr=open('profile.txt', 'w'))
73 subprocess.check_call([xsltproc ,'--profile', '--path'] + options.path + args, stderr=open('profile.txt', 'w'))
75 run_xsltproc(['--nonet',
87 'chunker.output.quiet',
88 quiet] + remaining_args + \
89 [gtkdocdir + '/gtk-doc.xsl',
93 if os.environ.get("GTKDOC_PROFILE", '') != '':
94 subprocess.check_call('cat profile.txt | gprof2dot.py -e 0.01 -n 0.01 | dot -Tpng -o profile.png', shell=True)
96 # copy navigation images and stylesheets to html directory ...
97 for f in glob(styledir + '/*.png') + glob(styledir + '/*.css'):
100 open('../html.stamp', 'w').write('timestamp')