import os import sys from xml.dom.minidom import parse siteDocs = False if len(sys.argv) > 1: if sys.argv[1] == "site": siteDocs = True globalHeaderMain = "" if siteDocs == True: header_f = open("site_header.html", 'r') globalHeaderMain = header_f.read() globalHeader = globalHeaderMain footer_f = open("site_footer.html", 'r') globalFooter = footer_f.read() else: header_f = open("local_header.html", 'r') globalHeaderMain = header_f.read() globalHeader = globalHeaderMain footer_f = open("local_footer.html", 'r') globalFooter = footer_f.read() def createMethods(className, item, static): numStatic = 0 numRegular = 0 for subitem in item.getElementsByTagName('method'): if subitem.hasAttribute("static") == True: numStatic = numStatic + 1 else: numRegular = numRegular + 1 if static == True and numStatic == 0: return "" if static == False and numRegular == 0: return "" html = "" html += "\t\t\t\t\t
\n" if static == True: html += "\t\t\t\t\t\t

Static Functions

\n" else: html += "\t\t\t\t\t\t

Functions

\n" html += "\t\t\t\t\t\t
\n" for subitem in item.getElementsByTagName('method'): if static == True and subitem.hasAttribute("static") == False: continue if static == False and subitem.hasAttribute("static") == True: continue paramList = "" paramIndex = 0 if len(subitem.getElementsByTagName('param')) > 0: for param in subitem.getElementsByTagName('param'): if paramIndex != 0: paramList += ", " paramList += "%s " % (param.attributes["name"].value) paramIndex = paramIndex + 1 if static == True: html += "\t\t\t\t\t\t\t\t

%s %s.%s (%s)

\n" % (subitem.attributes["return_type"].value, className, subitem.attributes["name"].value, paramList) else: html += "\t\t\t\t\t\t\t\t

%s %s (%s)

\n" % (subitem.attributes["return_type"].value, subitem.attributes["name"].value, paramList) desc = subitem.getElementsByTagName('desc') descText = "No description." if len(desc) > 0: descText = desc[0].childNodes[0].data html += "\t\t\t\t\t\t\t\t

%s

\n" % (descText) if len(subitem.getElementsByTagName('param')) > 0: for param in subitem.getElementsByTagName('param'): desc = param.getElementsByTagName('desc') descText = "No description." if len(desc) > 0: if len(desc[0].childNodes) > 0: descText = desc[0].childNodes[0].data html += "\t\t\t\t\t\t\t\t\t

%s %s - %s

\n" % ( param.attributes["type"].value, param.attributes["name"].value, descText) html += "\t\t\t\t\t\t
\n" html += "\t\t\t\t\t
\n" return html def makePage(item, classList, classListPlain, moduleName): html = globalHeader html += classList html += "\t
" if item.hasAttribute("extends"): extendModulePrefix = moduleName if item.attributes["extends"].value not in classListPlain: extendModulePrefix = "Polycode" html += "\t\t\t\t\t

%s (extends %s)

\n" % (item.attributes["name"].value, extendModulePrefix, item.attributes["extends"].value, item.attributes["extends"].value) else: html += "\t\t\t\t\t

%s

\n" % (item.attributes["name"].value) desc = item.getElementsByTagName('desc') descText = "No description." if len(desc) > 0: descText = desc[0].childNodes[0].data html += "\t\t\t\t\t

%s

\n" % descText classNotes = item.getElementsByTagName('class_notes') for nn in classNotes: html += "\t\t\t\t\t
%s
\n" % nn.childNodes[0].data if len(item.getElementsByTagName('static_member')) > 0: html += "\t\t\t\t\t
\n" html += "\t\t\t\t\t\t

Static Properties

\n" html += "\t\t\t\t\t\t
\n" for subitem in item.getElementsByTagName('static_member'): html += "\t\t\t\t\t\t\t\t
%s.%s = %s
\n" % (item.attributes["name"].value, subitem.attributes["name"].value, subitem.attributes["value"].value) desc = subitem.getElementsByTagName('desc') descText = "No description." if len(desc) > 0: descText = desc[0].childNodes[0].data html += "\t\t\t\t\t\t\t\t

%s %s

\n" % (subitem.attributes["type"].value, descText) html += "\t\t\t\t\t\t
\n" html += "\t\t\t\t\t
\n" if len(item.getElementsByTagName('member')) > 0: html += "\t\t\t\t\t
\n" html += "\t\t\t\t\t\t

Properties

\n" html += "\t\t\t\t\t\t
\n" for subitem in item.getElementsByTagName('member'): html += "\t\t\t\t\t\t\t\t
%s
\n" % (subitem.attributes["name"].value) desc = subitem.getElementsByTagName('desc') descText = "No description." if len(desc) > 0: descText = desc[0].childNodes[0].data html += "\t\t\t\t\t\t\t\t

%s %s

\n" % (subitem.attributes["type"].value, descText) html += "\t\t\t\t\t\t
\n" html += "\t\t\t\t\t
\n" html += createMethods(item.attributes["name"].value, item, True) html += createMethods(item.attributes["name"].value, item, False) html += "\t\t\t\t
\n" return html def makeHTML(fileName, moduleName): print ("Parsing %s\n" % fileName) sourceXML = open(fileName) dom = parse(sourceXML) sourceXML.close() classList = "" classList += "\t
" classList += "\t\n" classList += "\t\t\t
\n" classList += "\n" if siteDocs == True: directory = "../site_html/%s" % (moduleName) else: directory = "../html/%s" % (moduleName) if not os.path.exists(directory): os.makedirs(directory) html = globalHeader html += classList html += globalFooter if siteDocs == True: f = open("../site_html/%s/index.html" % (moduleName), 'w') else: f = open("../html/%s/index.html" % (moduleName), 'w') f.write(html) f.close() for item in dom.documentElement.getElementsByTagName('class'): if siteDocs == True: f = open("../site_html/%s/%s.html" % (moduleName, item.attributes["name"].value), 'w') else: f = open("../html/%s/%s.html" % (moduleName, item.attributes["name"].value), 'w') html = makePage(item, classList, classListPlain, moduleName) f.write(html) f.close() dirList = os.listdir("../xml") indexhtml = globalHeaderMain indexhtml += "\t
" indexhtml += "\t\n" indexhtml += "\t
\n" if siteDocs == True: f = open("../site_html/index.html", 'w') else: f = open("../html/index.html", 'w') f.write(indexhtml) f.close() indexhtml += globalFooter