|
1 | 1 | """This script prints out a list of undocumented symbols found in |
2 | 2 | Python include files, prefixed by their tag kind. |
3 | 3 |
|
4 | | -First, a temporary file is written which contains all Python include |
5 | | -files, with DL_IMPORT simply removed. This file is passed to ctags, |
6 | | -and the output is parsed into a dictionary mapping symbol names to tag |
7 | | -kinds. |
| 4 | +Pass Python's include files to ctags, parse the output into a |
| 5 | +dictionary mapping symbol names to tag kinds. |
8 | 6 |
|
9 | 7 | Then, the .tex files from Python docs are read into a giant string. |
10 | 8 |
|
|
16 | 14 | TAG_KINDS = "dpt" |
17 | 15 |
|
18 | 16 | # Doc sections to use |
19 | | -DOCSECTIONS = ["api", "ext"] |
| 17 | +DOCSECTIONS = ["api"]# ["api", "ext"] |
20 | 18 |
|
21 | | -# Only print symbols starting with this prefix |
| 19 | +# Only print symbols starting with this prefix, |
22 | 20 | # to get all symbols, use an empty string |
23 | 21 | PREFIX = "Py" |
24 | 22 |
|
| 23 | +INCLUDEPATTERN = "*.h" |
| 24 | + |
25 | 25 | # end of customization section |
26 | 26 |
|
27 | 27 |
|
@@ -58,40 +58,28 @@ def findnames(file, prefix=""): |
58 | 58 | names[name] = tag |
59 | 59 | return names |
60 | 60 |
|
61 | | -def print_undoc_symbols(prefix): |
62 | | - incfile = tempfile.mktemp(".h") |
63 | | - |
64 | | - fp = open(incfile, "w") |
65 | | - |
66 | | - for file in glob.glob(os.path.join(INCDIR, "*.h")): |
67 | | - text = open(file).read() |
68 | | - # remove all DL_IMPORT, they will confuse ctags |
69 | | - text = re.sub("DL_IMPORT", "", text) |
70 | | - fp.write(text) |
71 | | - fp.close() |
72 | | - |
| 61 | +def print_undoc_symbols(prefix, docdir, incdir): |
73 | 62 | docs = [] |
74 | 63 |
|
75 | 64 | for sect in DOCSECTIONS: |
76 | | - for file in glob.glob(os.path.join(DOCDIR, sect, "*.tex")): |
| 65 | + for file in glob.glob(os.path.join(docdir, sect, "*.tex")): |
77 | 66 | docs.append(open(file).read()) |
78 | 67 |
|
79 | 68 | docs = "\n".join(docs) |
80 | 69 |
|
81 | | - fp = os.popen("ctags --c-types=%s -f - %s" % (TAG_KINDS, incfile)) |
| 70 | + incfiles = os.path.join(incdir, INCLUDEPATTERN) |
| 71 | + |
| 72 | + fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s" % (TAG_KINDS, incfiles)) |
82 | 73 | dict = findnames(fp, prefix) |
83 | 74 | names = dict.keys() |
84 | 75 | names.sort() |
85 | 76 | for name in names: |
86 | 77 | if docs.find(name) == -1: |
87 | 78 | print dict[name], name |
88 | | - os.remove(incfile) |
89 | 79 |
|
90 | 80 | if __name__ == '__main__': |
91 | | - global INCDIR |
92 | | - global DOCDIR |
93 | | - SRCDIR = os.path.dirname(sys.argv[0]) |
94 | | - INCDIR = os.path.normpath(os.path.join(SRCDIR, "../../Include")) |
95 | | - DOCDIR = os.path.normpath(os.path.join(SRCDIR, "..")) |
| 81 | + srcdir = os.path.dirname(sys.argv[0]) |
| 82 | + incdir = os.path.normpath(os.path.join(srcdir, "../../Include")) |
| 83 | + docdir = os.path.normpath(os.path.join(srcdir, "..")) |
96 | 84 |
|
97 | | - print_undoc_symbols(PREFIX) |
| 85 | + print_undoc_symbols(PREFIX, docdir, incdir) |
0 commit comments