| 1 | #! /usr/bin/env python
|
|---|
| 2 | from __future__ import with_statement
|
|---|
| 3 | import errno
|
|---|
| 4 | import os
|
|---|
| 5 | import re
|
|---|
| 6 | import sys
|
|---|
| 7 | import string
|
|---|
| 8 |
|
|---|
| 9 | if __name__ == "__main__":
|
|---|
| 10 | _base = sys.argv[0]
|
|---|
| 11 | else:
|
|---|
| 12 | _base = __file__
|
|---|
| 13 |
|
|---|
| 14 | _script_home = os.path.abspath(os.path.dirname(_base))
|
|---|
| 15 |
|
|---|
| 16 | srcdir = os.path.dirname(os.path.dirname(_script_home))
|
|---|
| 17 |
|
|---|
| 18 | EXCLUDES = ["bitset.h", "cStringIO.h", "graminit.h", "grammar.h",
|
|---|
| 19 | "longintrepr.h", "metagrammar.h",
|
|---|
| 20 | "node.h", "opcode.h", "osdefs.h", "pgenheaders.h",
|
|---|
| 21 | "py_curses.h", "parsetok.h", "symtable.h", "token.h"]
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | def list_headers():
|
|---|
| 25 | """Return a list of headers."""
|
|---|
| 26 | incdir = os.path.join(srcdir, "Include")
|
|---|
| 27 | return [os.path.join(incdir, fn) for fn in os.listdir(incdir)
|
|---|
| 28 | if fn.endswith(".h") and fn not in EXCLUDES]
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | def matcher(pattern):
|
|---|
| 32 | return re.compile(pattern).search
|
|---|
| 33 |
|
|---|
| 34 | MATCHERS = [
|
|---|
| 35 | # XXX this should also deal with ctypedesc, cvardesc and cmemberdesc
|
|---|
| 36 | matcher(r"\\begin\{cfuncdesc\}\{(?P<result>[^}]*)\}\{(?P<sym>[^}]*)\}{(?P<params>[^}]*)\}"),
|
|---|
| 37 | matcher(r"\\cfuncline\{(?P<result>[^})]*)\}\{(?P<sym>[^}]*)\}{(?P<params>[^}]*)\}"),
|
|---|
| 38 | ]
|
|---|
| 39 |
|
|---|
| 40 | def list_documented_items():
|
|---|
| 41 | """Return a list of everything that's already documented."""
|
|---|
| 42 | apidir = os.path.join(srcdir, "Doc", "api")
|
|---|
| 43 | files = [fn for fn in os.listdir(apidir) if fn.endswith(".tex")]
|
|---|
| 44 | L = []
|
|---|
| 45 | for fn in files:
|
|---|
| 46 | fullname = os.path.join(apidir, fn)
|
|---|
| 47 | data = open(fullname).read()
|
|---|
| 48 | for matcher in MATCHERS:
|
|---|
| 49 | pos = 0
|
|---|
| 50 | while 1:
|
|---|
| 51 | m = matcher(data, pos)
|
|---|
| 52 | if not m: break
|
|---|
| 53 | pos = m.end()
|
|---|
| 54 | sym = m.group("sym")
|
|---|
| 55 | result = m.group("result")
|
|---|
|
|---|