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

Skip to content

Commit ea4d2c0

Browse files
committed
A few small changes:
- Change PREFIX to PREFIXES, which contains a sequence of prefix strings. This is useful since we want to look for both Py and PY. - Wrap a long line. - Collect struct tags as well as typedef names. Since we generally only use one of the other, that improves coverage. - Make the script executable on Unix. This could use a better approach to determine if a symbol is documented, and could easily avoid keeping the massive string in memory. That would take time to actually write more code, though, so we'll bail on that for now.
1 parent cffed4b commit ea4d2c0

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

Doc/tools/undoc_symbols.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
"""This script prints out a list of undocumented symbols found in
1+
#! /usr/bin/env python
2+
3+
"""\
4+
This script prints out a list of undocumented symbols found in
25
Python include files, prefixed by their tag kind.
36
47
Pass Python's include files to ctags, parse the output into a
@@ -11,14 +14,14 @@
1114
"""
1215

1316
# Which kind of tags do we need?
14-
TAG_KINDS = "dpt"
17+
TAG_KINDS = "dpst"
1518

1619
# Doc sections to use
1720
DOCSECTIONS = ["api"]# ["api", "ext"]
1821

1922
# Only print symbols starting with this prefix,
2023
# to get all symbols, use an empty string
21-
PREFIX = "Py"
24+
PREFIXES = ("Py", "PY")
2225

2326
INCLUDEPATTERN = "*.h"
2427

@@ -45,16 +48,21 @@
4548

4649
import os, glob, re, sys, tempfile
4750

48-
def findnames(file, prefix=""):
51+
def findnames(file, prefixes=()):
4952
names = {}
50-
for line in file.readlines():
53+
for line in file.xreadlines():
5154
if line[0] == '!':
5255
continue
5356
fields = line.split()
5457
name, tag = fields[0], fields[-1]
5558
if tag == 'd' and name.endswith('_H'):
5659
continue
57-
if name.startswith(prefix):
60+
if prefixes:
61+
sw = name.startswith
62+
for prefix in prefixes:
63+
if sw(prefix):
64+
names[name] = tag
65+
else:
5866
names[name] = tag
5967
return names
6068

@@ -69,7 +77,8 @@ def print_undoc_symbols(prefix, docdir, incdir):
6977

7078
incfiles = os.path.join(incdir, INCLUDEPATTERN)
7179

72-
fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s" % (TAG_KINDS, incfiles))
80+
fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s"
81+
% (TAG_KINDS, incfiles))
7382
dict = findnames(fp, prefix)
7483
names = dict.keys()
7584
names.sort()
@@ -82,4 +91,4 @@ def print_undoc_symbols(prefix, docdir, incdir):
8291
incdir = os.path.normpath(os.path.join(srcdir, "../../Include"))
8392
docdir = os.path.normpath(os.path.join(srcdir, ".."))
8493

85-
print_undoc_symbols(PREFIX, docdir, incdir)
94+
print_undoc_symbols(PREFIXES, docdir, incdir)

0 commit comments

Comments
 (0)