#NEWLINE# def main( ) : #NEWLINE# #INDENT# docs = 'Common AST' #NEWLINE# docs += ( ( '\n' + ( '=' * len ( docs ) ) ) + '\n\n' ) #NEWLINE# docs += '.. automodule:: commonast\n\n' #NEWLINE# docs += '.. autofunction:: commonast.parse\n\n' #NEWLINE# docs += '----\n\n' #NEWLINE# docs += 'The nodes\n---------\n\n' #NEWLINE# docs += '.. autoclass:: commonast.Node\n    :members:\n\n' #NEWLINE# code = open ( commonast . __file__ , 'rb' ) . read ( ) . decode ( ) #NEWLINE# status = 0 #NEWLINE# for line in code . splitlines ( ) : #NEWLINE# #INDENT# if ( status == 0 ) : #NEWLINE# #INDENT# if line . startswith ( '## --' ) : #NEWLINE# #INDENT# status = 1 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( status == 1 ) : #NEWLINE# #INDENT# if line . startswith ( '## --' ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if line . startswith ( '## ' ) : #NEWLINE# #INDENT# title = line [ 3 : ] . strip ( ) #NEWLINE# docs += ( '%s\n%s\n\n' % ( title , ( '-' * len ( title ) ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if line . startswith ( 'class ' ) : #NEWLINE# #INDENT# clsname = line [ 6 : ] . split ( '(' ) [ 0 ] #NEWLINE# docs += ( '.. autoclass:: %s\n\n' % ( 'commonast.' + clsname ) ) #NEWLINE# cls = getattr ( commonast , clsname ) #NEWLINE# cls . __doc__ = ( '%s()\n%s' % ( clsname , cls . __doc__ ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# filename = os . path . join ( OUTPUT_DIR , 'commonast.rst' ) #NEWLINE# created_files . append ( filename ) #NEWLINE# open ( filename , 'wt' , encoding = 'utf-8' ) . write ( docs ) #NEWLINE# print ( '  generated commonast page' )