summaryrefslogtreecommitdiff
path: root/cmake/list-manpage-dependencies.py
blob: 67e79ad50acd9504f976098d396c2155bf9decd2 (plain)
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
#!/usr/bin/env python

# Find manual page dependencies
# argv1 = doc dir containing conf.py

import importlib.util
import os.path
import pathlib
import sys

if __name__ == "__main__":

    if len(sys.argv) != 2:
        sys.exit("Usage: %s sphinx-srcdir" % (sys.argv[0]))

    conf_dir = os.path.abspath(sys.argv[1])
    conf_path = os.path.join(conf_dir, 'conf.py')
    spec = importlib.util.spec_from_file_location('conf', conf_path)
    conf = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(conf)

    if hasattr(conf, 'man_pages'):
        for man in conf.man_pages:
            man_path = os.path.join(sys.argv[1], "{}{}".format(man[0], '.rst'))
            man_path_posix = pathlib.PureWindowsPath(man_path).as_posix()
            print(man_path_posix)

    print(pathlib.PureWindowsPath(conf_path).as_posix())