/
gtkdoc-mkman.in
91 lines (78 loc) · 2.58 KB
/
gtkdoc-mkman.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!@PYTHON@
# Support both Python 2 and 3
from __future__ import print_function
import os, sys, argparse, subprocess
from glob import glob
version = '@VERSION@'
xsltproc = '@XSLTPROC@'
parser = argparse.ArgumentParser(description='gtkdoc-mkman version %s - generate documentation in man format' % version)
parser.add_argument('--verbose', default=False, action='store_true',
help='Print extra output while processing')
parser.add_argument('--path', default='',
help='Extra source directories')
parser.add_argument('version', default=False, action='store_true',
help='Print the version of this program')
parser.add_argument('args', nargs=2,
help='MODULE DRIVER_FILE')
parser.add_argument('--uninstalled', action='store_true', default=False,
help='???')
options = parser.parse_args()
if options.version:
print(version)
sys.exit(0)
module=options.args[0]
document=options.args[1]
if options.verbose:
quiet = '0'
else:
quiet = '1'
if options.uninstalled:
# this does not work from buiddir!=srcdir
gtkdocdir=os.path.split(sys.argv[0])[0]
#echo "uninstalled, gtkdocdir=$gtkdocdir"
else:
# the first two are needed to resolve datadir
prefix='@prefix@'
datarootdir='@datarootdir@'
gtkdocdir='@datadir@/gtk-doc/data'
if "<?xml" in open(document).readline():
is_xml=True
path_option='--path'
else:
is_xml=False
path_option='--directory'
# we could do "$path_option $PWD "
# to avoid needing rewriting entities that are copied from the header
# into docs under xml
if options.path == '':
path_arg=[]
else:
path_arg=[path_option, options.path]
# would it make sens to create man pages only for certain refentries
# e.g. for tools
if is_xml:
# see http://bugzilla.gnome.org/show_bug.cgi?id=467488
subprocess.check_call([xsltproc] + path_arg +[
'--nonet',
'--xinclude',
'--stringparam',
'gtkdoc.bookname',
module,
'--stringparam',
'gtkdoc.version',
version,
'--stringparam',
'chunk.quietly ',
'quiet',
'--stringparam',
'chunker.output.quiet',
quiet,
'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
document])
else:
for i in glob('sgml/*.sgml'):
j = os.path.split(i)[1].replace('.sgml', '.man')
print("converting ", i, j)
subproject.check_call(['docbook-to-man', i],
stdout=open('man'+j),
stderr=open('man/%s.log' % j))