Debian Codegraph @

texk/xdvipsk/thirdparty/libtiff/cmake/list-manpages.py

raw
1 #!/usr/bin/env python
2
3 # Find manual pages to be generated
4 # argv1 = doc dir containing conf.py
5 # argv2 = manpage directory to contain generated manpages
6
7 import importlib.util
8 import os.path
9 import pathlib
10 import sys
11
12 if __name__ == "__main__":
13
14 if len(sys.argv) != 3:
15 print("Usage: {} sphinx-srcdir sphinx-builddir".format(sys.argv[0]), file=sys.stderr)
16 sys.exit(2)
17
18 conf_dir = os.path.abspath(sys.argv[1])
19 conf_path = os.path.join(conf_dir, 'conf.py')
20 spec = importlib.util.spec_from_file_location('conf', conf_path)
21 conf = importlib.util.module_from_spec(spec)
22 spec.loader.exec_module(conf)
23
24 if hasattr(conf, 'man_pages'):
25 for man in conf.man_pages:
26 man_path = os.path.join(sys.argv[2], "%s.%s" % (man[1], man[4]))
27 man_path_posix = pathlib.PureWindowsPath(man_path).as_posix()
28 print(man_path_posix)
29 else:
30 print("No man_pages array in {}".format(conf_path), file=sys.stderr)
31 sys.exit(3)