8 if __name__
== "__main__":
13 _script_home
= os
.path
.abspath(os
.path
.dirname(_base
))
15 srcdir
= os
.path
.dirname(os
.path
.dirname(_script_home
))
17 EXCLUDES
= ["bitset.h", "cStringIO.h", "graminit.h", "grammar.h",
18 "longintrepr.h", "metagrammar.h",
19 "node.h", "opcode.h", "osdefs.h", "pgenheaders.h",
20 "py_curses.h", "parsetok.h", "symtable.h", "token.h"]
24 """Return a list of headers."""
25 incdir
= os
.path
.join(srcdir
, "Include")
26 return [fn
for fn
in os
.listdir(incdir
)
27 if fn
.endswith(".h") and fn
not in EXCLUDES
]
31 return re
.compile(pattern
).match
34 matcher(r
"\\begin\{cfuncdesc\}\{[^{]*\}\{(?P<sym>[^{]*)\}"),
35 matcher(r
"\\cfuncline\{[^{]*\}\{(?P<sym>[^{]*)\}"),
36 matcher(r
"\\begin\{ctypedesc\}(\[[^{]*\])?\{(?P<sym>[^{]*)\}"),
37 matcher(r
"\\begin\{cvardesc\}\{[^{]*\}\{(?P<sym>[^{]*)\}"),
38 matcher(r
"\\begin\{cmemberdesc\}\{[^{]*\}\{(?P<sym>[^{]*)\}"),
39 matcher(r
"\\cmemberline\{[^{]*\}\{(?P<sym>[^{]*)\}"),
40 matcher(r
"\\begin\{csimplemacrodesc\}\{(?P<sym>[^{]*)\}"),
44 def list_documented_items():
45 """Return a list of everything that's already documented."""
46 apidir
= os
.path
.join(srcdir
, "Doc", "api")
47 files
= [fn
for fn
in os
.listdir(apidir
) if fn
.endswith(".tex")]
50 fullname
= os
.path
.join(apidir
, fn
)
51 for line
in open(fullname
):
53 if not line
.startswith("\\"):
55 for matcher
in MATCHERS
:
58 L
.append(m
.group("sym"))
62 def split_documented(all
, documented
):
63 """Split the list of all symbols into documented and undocumented
68 if t
[0] in documented
:
74 def print_list(L
, title
=None):
75 """Dump a list to stdout."""
78 print "-" * (len(title
) + 1)
80 for sym
, filename
in L
:
86 for sym
, filename
in L
:
87 print "%-*s%s" % (w
, sym
, filename
)
98 os
.chdir(os
.path
.join(srcdir
, "Include"))
99 headers
= list_headers()
100 documented
= list_documented_items()
102 cmd
= ("ctags -f - --file-scope=no --c-types=dgpstux "
103 "-Istaticforward -Istatichere=static "
112 sym
, filename
= line
.split()[:2]
115 if not sym
.endswith("_H"):
116 L
.append((sym
, filename
))
123 documented
, undocumented
= split_documented(L
, documented
)
124 print_list(documented
, "Documented symbols")
127 print_list(undocumented
, "Undocumented symbols")
131 if e
.errno
!= errno
.EPIPE
:
135 if __name__
== "__main__":