File: check_header_docs.py

package info (click to toggle)
quantlib 1.40-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 41,768 kB
  • sloc: cpp: 398,987; makefile: 6,574; python: 214; sh: 150; lisp: 86
file content (34 lines) | stat: -rwxr-xr-x 808 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/python -u

import multiprocessing as mp
import sys
import os
import re

regex = re.compile(r"\\file +([a-z_]+\.hpp)")


def check(header):
    with open(header) as f:
        lines = f.readlines()
    for l in lines:
        m = regex.search(l)
        if m:
            documented = m.groups()[0]
            basename = os.path.basename(header)
            if documented == basename:
                return 0
            else:
                print(
                    f"Wrong file name ({documented}) in Doxygen \\file directive in {header}",
                    file=sys.stderr,
                )
                return 1

    return 0


if __name__ == "__main__":
    headers = [line.strip() for line in sys.stdin.readlines()]
    errors = sum(check(h) for h in headers)
    sys.exit(errors)