summaryrefslogtreecommitdiff
path: root/scripts/check_manfile.py
blob: 5e477adab2b52933bad1e8120751a0ab700070fd (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
29
30
31
32
33
#!/usr/bin/env python
#
# CI runs this script to verify that options appearing in XTools' ggo.in files also appear in their .ronn files.
# It does not check that `make manpages` has actually been run.
#
# This script assumes it's being run from the root of the xmap repository.
#

import sys

checks = [
    ("xopt.ggo.in", "xmap.1.ronn")
]

failures = False

for ggo, ronn in checks:
    options = []
    with open("src/" + ggo) as fd:
        for l in fd:
            if l.startswith("option "):
                option = l.split()[1].lstrip('"').rstrip('"')
                options.append(option)

    man = open("src/" + ronn).read()

    for option in options:
        if option not in man:
            failures = True
            sys.stderr.write("option %s is present in %s but missing from man file %s\n" % (option, ggo, ronn))

if failures:
    sys.exit(1)