<s> """<STR_LIT>""" <EOL> import os <EOL> from types import ModuleType <EOL> from flexx import ui , app <EOL> THIS_DIR = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> DOC_DIR = os . path . abspath ( os . path . join ( THIS_DIR , '<STR_LIT:..>' ) ) <EOL> OUTPUT_DIR = os . path . join ( DOC_DIR , '<STR_LIT>' ) <EOL> created_files = [ ] <EOL> def main ( ) : <EOL> pages = { } <EOL> class_names = [ ] <EOL> layouts = set ( ) <EOL> namespace = { } ; namespace . update ( ui . __dict__ ) ; namespace . update ( ui . layouts . __dict__ ) ; namespace . update ( ui . widgets . __dict__ ) <EOL> for mod in namespace . values ( ) : <EOL> if isinstance ( mod , ModuleType ) : <EOL> classes = [ ] <EOL> for w in mod . __dict__ . values ( ) : <EOL> if isinstance ( w , type ) and issubclass ( w , ui . Widget ) : <EOL> if w . __module__ == mod . __name__ : <EOL> classes . append ( w ) <EOL> if issubclass ( w , ui . Layout ) : <EOL> layouts . add ( w . __name__ ) <EOL> if classes : <EOL> classes . sort ( key = lambda x : x . __name__ ) <EOL> classes . sort ( key = lambda x : len ( x . mro ( ) ) ) <EOL> class_names . extend ( [ w . __name__ for w in classes ] ) <EOL> pages [ mod . __name__ ] = classes <EOL> for module_name , classes in sorted ( pages . items ( ) ) : <EOL> page_name = module_name . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:1> ] . strip ( '<STR_LIT:_>' ) . capitalize ( ) <EOL> docs = '<STR_LIT>' % ( page_name , '<STR_LIT:->' * len ( page_name ) ) <EOL> docs += '<STR_LIT>' % module_name <EOL> docs += '<STR_LIT>' <EOL> for cls in classes : <EOL> name = cls . __name__ <EOL> if '<STR_LIT>' not in cls . __doc__ : <EOL> bases = [ ] <EOL> for bcls in cls . __bases__ : <EOL> if getattr ( ui , bcls . __name__ , None ) : <EOL> bases . append ( '<STR_LIT>' % ( bcls . __name__ , bcls . __name__ ) ) <EOL> elif getattr ( app , bcls . __name__ , None ) : <EOL> bases . append ( '<STR_LIT>' % ( bcls . __name__ , bcls . __name__ ) ) <EOL> else : <EOL> bases . append ( '<STR_LIT>' % ( bcls . __name__ , bcls . __module__ , bcls . __name__ ) ) <EOL> line = '<STR_LIT>' + '<STR_LIT:U+002CU+0020>' . join ( bases ) <EOL> cls . __doc__ = line + '<STR_LIT>' + ( cls . __doc__ or '<STR_LIT>' ) . lstrip ( ) <EOL> if getattr ( ui , name , None ) : <EOL> docs += '<STR_LIT>' % name <EOL> else : <EOL> docs += '<STR_LIT>' % ( module_name , name ) <EOL> docs += '<STR_LIT>' <EOL> filename = os . path . join ( OUTPUT_DIR , page_name . lower ( ) + '<STR_LIT>' ) <EOL> created_files . append ( filename ) <EOL> open ( filename , '<STR_LIT>' , encoding = '<STR_LIT:utf-8>' ) . write ( docs ) <EOL> docs = '<STR_LIT>' <EOL> docs += '<STR_LIT:\n>' + '<STR_LIT:=>' * len ( docs ) + '<STR_LIT>' <EOL> docs += '<STR_LIT>' <EOL> docs += '<STR_LIT>' <EOL> docs += '<STR_LIT>' <EOL> docs += '<STR_LIT>' <EOL> docs += '<STR_LIT>' <EOL> if True : <EOL> docs += '<STR_LIT>' % ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> docs += '<STR_LIT>' <EOL> for name in [ n for n in sorted ( class_names ) if n in layouts if getattr ( ui , n , None ) ] : <EOL> docs += '<STR_LIT>' % ( name , name ) <EOL> docs += '<STR_LIT>' <EOL> for name in [ n for n in sorted ( class_names ) if n not in layouts if getattr ( ui , n , None ) ] : <EOL> docs += '<STR_LIT>' % ( name , name ) <EOL> docs += '<STR_LIT>' <EOL> for module_name in sorted ( pages . keys ( ) ) : <EOL> docs += '<STR_LIT>' % module_name . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:1> ] . strip ( '<STR_LIT:_>' ) . lower ( ) <EOL> filename = os . path . join ( OUTPUT_DIR , '<STR_LIT>' ) <EOL> created_files . append ( filename ) <EOL> open ( filename , '<STR_LIT>' , encoding = '<STR_LIT:utf-8>' ) . write ( docs ) <EOL> print ( '<STR_LIT>' % ( len ( pages ) , len ( class_names ) ) ) <EOL> def clean ( ) : <EOL> while created_files : <EOL> filename = created_files . pop ( ) <EOL> if os . path . isfile ( filename ) : <EOL> os . remove ( filename ) </s>
