migratetmpl: also remove the migration tool
[gtk-doc.git] / gtkdoc-mkman.in
blob6667301704fe1cc0d058658644a7e964cd23dbae
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 two are needed to resolve datadir
43     prefix='@prefix@'
44     datarootdir='@datarootdir@'
45     gtkdocdir='@datadir@/gtk-doc/data'
47 if "<?xml" in open(document).readline():
48     is_xml=True
49     path_option='--path'
50 else:
51     is_xml=False
52     path_option='--directory'
55 # we could do "$path_option $PWD "
56 # to avoid needing rewriting entities that are copied from the header
57 # into docs under xml
58 if options.path == '':
59     path_arg=[]
60 else:
61     path_arg=[path_option, options.path]
63 # would it make sens to create man pages only for certain refentries
64 # e.g. for tools
65 if is_xml:
66     # see http://bugzilla.gnome.org/show_bug.cgi?id=467488
67     subprocess.check_call([xsltproc] + path_arg +[
68         '--nonet',
69         '--xinclude',
70         '--stringparam',
71         'gtkdoc.bookname',
72         module,
73         '--stringparam',
74         'gtkdoc.version',
75         version,
76         '--stringparam',
77         'chunk.quietly ',
78         'quiet',
79         '--stringparam',
80         'chunker.output.quiet',
81         quiet,
82         'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
83         document])
84 else:
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],
89                                stdout=open('man'+j),
90                                stderr=open('man/%s.log' % j))