File: check-API-refs.py

package info (click to toggle)
patsy 0.4.1%2Bgit34-ga5b54c2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,444 kB
  • ctags: 884
  • sloc: python: 8,797; makefile: 130; sh: 15
file content (48 lines) | stat: -rw-r--r-- 1,216 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env python

# NB: this currently works on both Py2 and Py3, and should be kept that way.

import sys
import re
from os.path import dirname, abspath

root = dirname(dirname(abspath(__file__)))
patsy_ref = root + "/doc/API-reference.rst"

doc_re = re.compile("^\.\. (.*):: ([^\(]*)")
def _documented(rst_path):
    documented = set()
    for line in open(rst_path):
        match = doc_re.match(line.rstrip())
        if match:
            directive = match.group(1)
            symbol = match.group(2)
            if directive not in ["module", "ipython"]:
                documented.add(symbol)
    return documented

try:
    import patsy
except ImportError:
    sys.path.append(root)
    import patsy

documented = set(_documented(patsy_ref))
#print(documented)
exported = set(patsy.__all__)
missed = exported.difference(documented)
extra = documented.difference(exported)
if missed:
    print("DOCS MISSING FROM %s:" % (patsy_ref,))
    for m in sorted(missed):
        print("  %s" % (m,))
if extra:
    print("EXTRA DOCS IN %s:" % (patsy_ref,))
    for m in sorted(extra):
        print("  %s" % (m,))

if missed or extra:
    sys.exit(1)
else:
    print("Reference docs look good.")
    sys.exit(0)