mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
First day's progress on documentation
This commit is contained in:
parent
ce575bac5e
commit
76f42ac512
3 changed files with 588 additions and 0 deletions
30
Tools/compiler/doc/astdocgen.py
Normal file
30
Tools/compiler/doc/astdocgen.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Lame substitute for a fine script to generate the table from ast.txt
|
||||
|
||||
from compiler import astgen
|
||||
|
||||
AST_DEF = '../compiler/ast.txt'
|
||||
|
||||
def sort(l):
|
||||
l = l[:]
|
||||
l.sort(lambda a, b: cmp(a.name, b.name))
|
||||
return l
|
||||
|
||||
def main():
|
||||
nodes = astgen.parse_spec(AST_DEF)
|
||||
print "\\begin{longtableiii}{lll}{class}{Node type}{Attribute}{Value}"
|
||||
print
|
||||
for node in sort(nodes):
|
||||
if node.argnames:
|
||||
print "\\lineiii{%s}{%s}{}" % (node.name, node.argnames[0])
|
||||
else:
|
||||
print "\\lineiii{%s}{}{}" % node.name
|
||||
|
||||
for arg in node.argnames[1:]:
|
||||
print "\\lineiii{}{%s}{}" % arg
|
||||
print "\\hline", "\n"
|
||||
print "\\end{longtableiii}"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue