2001-11-29 04:30:46 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
|
|
|
"""\
|
|
|
|
This script prints out a list of undocumented symbols found in
|
2001-11-09 16:50:35 +00:00
|
|
|
Python include files, prefixed by their tag kind.
|
|
|
|
|
2001-11-12 12:52:01 +00:00
|
|
|
Pass Python's include files to ctags, parse the output into a
|
|
|
|
dictionary mapping symbol names to tag kinds.
|
2001-11-09 16:50:35 +00:00
|
|
|
|
|
|
|
Then, the .tex files from Python docs are read into a giant string.
|
|
|
|
|
|
|
|
Finally all symbols not found in the docs are written to standard
|
|
|
|
output, prefixed with their tag kind.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Which kind of tags do we need?
|
2001-11-29 04:30:46 +00:00
|
|
|
TAG_KINDS = "dpst"
|
2001-11-09 16:50:35 +00:00
|
|
|
|
|
|
|
# Doc sections to use
|
2001-11-12 12:52:01 +00:00
|
|
|
DOCSECTIONS = ["api"]# ["api", "ext"]
|
2001-11-09 16:50:35 +00:00
|
|
|
|
2001-11-12 12:52:01 +00:00
|
|
|
# Only print symbols starting with this prefix,
|
2001-11-09 16:50:35 +00:00
|
|
|
# to get all symbols, use an empty string
|
2001-11-29 04:30:46 +00:00
|
|
|
PREFIXES = ("Py", "PY")
|
2001-11-09 16:50:35 +00:00
|
|
|
|
2001-11-12 12:52:01 +00:00
|
|
|
INCLUDEPATTERN = "*.h"
|
|
|
|
|
2001-11-09 16:50:35 +00:00
|
|
|
# end of customization section
|
|
|
|
|
|
|
|
|
|
|
|
# Tested with EXUBERANT CTAGS
|
|
|
|
# see http://ctags.sourceforge.net
|
|
|
|
#
|
|
|
|
# ctags fields are separated by tabs.
|
|
|
|
# The first field is the name, the last field the type:
|
|
|
|
# d macro definitions (and #undef names)
|
|
|
|
# e enumerators
|
|
|
|
# f function definitions
|
|
|
|
# g enumeration names
|
|
|
|
# m class, struct, or union members
|
|
|
|
# n namespaces
|
|
|
|
# p function prototypes and declarations
|
|
|
|
# s structure names
|
|
|
|
# t typedefs
|
|
|
|
# u union names
|
|
|
|
# v variable definitions
|
|
|
|
# x extern and forward variable declarations
|
|
|
|
|
2002-04-16 15:04:56 +00:00
|
|
|
import os, glob, re, sys
|
2001-11-09 16:50:35 +00:00
|
|
|
|
2001-11-29 04:30:46 +00:00
|
|
|
def findnames(file, prefixes=()):
|
2001-11-09 16:50:35 +00:00
|
|
|
names = {}
|
2001-11-29 04:30:46 +00:00
|
|
|
for line in file.xreadlines():
|
2001-11-09 16:50:35 +00:00
|
|
|
if line[0] == '!':
|
|
|
|
continue
|
|
|
|
fields = line.split()
|
|
|
|
name, tag = fields[0], fields[-1]
|
|
|
|
if tag == 'd' and name.endswith('_H'):
|
|
|
|
continue
|
2001-11-29 04:30:46 +00:00
|
|
|
if prefixes:
|
|
|
|
sw = name.startswith
|
|
|
|
for prefix in prefixes:
|
|
|
|
if sw(prefix):
|
|
|
|
names[name] = tag
|
|
|
|
else:
|
2001-11-09 16:50:35 +00:00
|
|
|
names[name] = tag
|
|
|
|
return names
|
|
|
|
|
2001-11-12 12:52:01 +00:00
|
|
|
def print_undoc_symbols(prefix, docdir, incdir):
|
2001-11-09 16:50:35 +00:00
|
|
|
docs = []
|
|
|
|
|
|
|
|
for sect in DOCSECTIONS:
|
2001-11-12 12:52:01 +00:00
|
|
|
for file in glob.glob(os.path.join(docdir, sect, "*.tex")):
|
2001-11-09 16:50:35 +00:00
|
|
|
docs.append(open(file).read())
|
|
|
|
|
|
|
|
docs = "\n".join(docs)
|
|
|
|
|
2001-11-12 12:52:01 +00:00
|
|
|
incfiles = os.path.join(incdir, INCLUDEPATTERN)
|
|
|
|
|
2001-11-29 04:30:46 +00:00
|
|
|
fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s"
|
|
|
|
% (TAG_KINDS, incfiles))
|
2001-11-09 16:50:35 +00:00
|
|
|
dict = findnames(fp, prefix)
|
|
|
|
names = dict.keys()
|
|
|
|
names.sort()
|
|
|
|
for name in names:
|
2002-04-16 15:04:56 +00:00
|
|
|
if not re.search("%s\\W" % name, docs):
|
2001-11-09 16:50:35 +00:00
|
|
|
print dict[name], name
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2001-11-12 12:52:01 +00:00
|
|
|
srcdir = os.path.dirname(sys.argv[0])
|
|
|
|
incdir = os.path.normpath(os.path.join(srcdir, "../../Include"))
|
|
|
|
docdir = os.path.normpath(os.path.join(srcdir, ".."))
|
2001-11-09 16:50:35 +00:00
|
|
|
|
2001-11-29 04:30:46 +00:00
|
|
|
print_undoc_symbols(PREFIXES, docdir, incdir)
|