Commit ea4d2c02 authored by Fred Drake's avatar Fred Drake

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.
parent cffed4bc
"""This script prints out a list of undocumented symbols found in
#! /usr/bin/env python
"""\
This script prints out a list of undocumented symbols found in
Python include files, prefixed by their tag kind.
Pass Python's include files to ctags, parse the output into a
......@@ -11,14 +14,14 @@ output, prefixed with their tag kind.
"""
# Which kind of tags do we need?
TAG_KINDS = "dpt"
TAG_KINDS = "dpst"
# Doc sections to use
DOCSECTIONS = ["api"]# ["api", "ext"]
# Only print symbols starting with this prefix,
# to get all symbols, use an empty string
PREFIX = "Py"
PREFIXES = ("Py", "PY")
INCLUDEPATTERN = "*.h"
......@@ -45,16 +48,21 @@ INCLUDEPATTERN = "*.h"
import os, glob, re, sys, tempfile
def findnames(file, prefix=""):
def findnames(file, prefixes=()):
names = {}
for line in file.readlines():
for line in file.xreadlines():
if line[0] == '!':
continue
fields = line.split()
name, tag = fields[0], fields[-1]
if tag == 'd' and name.endswith('_H'):
continue
if name.startswith(prefix):
if prefixes:
sw = name.startswith
for prefix in prefixes:
if sw(prefix):
names[name] = tag
else:
names[name] = tag
return names
......@@ -69,7 +77,8 @@ def print_undoc_symbols(prefix, docdir, incdir):
incfiles = os.path.join(incdir, INCLUDEPATTERN)
fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s" % (TAG_KINDS, incfiles))
fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s"
% (TAG_KINDS, incfiles))
dict = findnames(fp, prefix)
names = dict.keys()
names.sort()
......@@ -82,4 +91,4 @@ if __name__ == '__main__':
incdir = os.path.normpath(os.path.join(srcdir, "../../Include"))
docdir = os.path.normpath(os.path.join(srcdir, ".."))
print_undoc_symbols(PREFIX, docdir, incdir)
print_undoc_symbols(PREFIXES, docdir, incdir)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment