Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64cdb48

Browse files
author
Thomas Heller
committed
No need to preprocess the header files - use ctags -I flag instead to
remove DL_IMPORT.
1 parent bfeeeee commit 64cdb48

1 file changed

Lines changed: 15 additions & 27 deletions

File tree

Doc/tools/undoc_symbols.py

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"""This script prints out a list of undocumented symbols found in
22
Python include files, prefixed by their tag kind.
33
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.
86
97
Then, the .tex files from Python docs are read into a giant string.
108
@@ -16,12 +14,14 @@
1614
TAG_KINDS = "dpt"
1715

1816
# Doc sections to use
19-
DOCSECTIONS = ["api", "ext"]
17+
DOCSECTIONS = ["api"]# ["api", "ext"]
2018

21-
# Only print symbols starting with this prefix
19+
# Only print symbols starting with this prefix,
2220
# to get all symbols, use an empty string
2321
PREFIX = "Py"
2422

23+
INCLUDEPATTERN = "*.h"
24+
2525
# end of customization section
2626

2727

@@ -58,40 +58,28 @@ def findnames(file, prefix=""):
5858
names[name] = tag
5959
return names
6060

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):
7362
docs = []
7463

7564
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")):
7766
docs.append(open(file).read())
7867

7968
docs = "\n".join(docs)
8069

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))
8273
dict = findnames(fp, prefix)
8374
names = dict.keys()
8475
names.sort()
8576
for name in names:
8677
if docs.find(name) == -1:
8778
print dict[name], name
88-
os.remove(incfile)
8979

9080
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, ".."))
9684

97-
print_undoc_symbols(PREFIX)
85+
print_undoc_symbols(PREFIX, docdir, incdir)

0 commit comments

Comments
 (0)