[wpdev-commits] xmlscripts/documentation generate_html.py,1.7,1.8 parse.py,1.8,1.9
Brought to you by:
rip,
thiagocorrea
From: Sebastian H. <dar...@us...> - 2004-07-02 13:29:09
|
Update of /cvsroot/wpdev/xmlscripts/documentation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28554 Modified Files: generate_html.py parse.py Log Message: Another big documentation update. Constants ! Index: parse.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/documentation/parse.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** parse.py 29 Jun 2004 22:46:13 -0000 1.8 --- parse.py 2 Jul 2004 13:29:00 -0000 1.9 *************** *** 17,20 **** --- 17,21 ---- FUNCTION_NAME_PATTERN = re.compile("\\\\function\s([\w\.]+)", re.S) LINK_OBJECT_PATTERN = re.compile("<object\\s+id=\"([^\\\"]+)\">(.*?)<\\/object>", re.S) + LINK_MODULE_PATTERN = re.compile("<module\\s+id=\"([^\\\"]+)\">(.*?)<\\/module>", re.S) VERSION = "Unknown" *************** *** 46,49 **** --- 47,61 ---- replacement = '<a href="object_%s.html">%s</a>' % (link.group(1).lower(), link.group(2)) text = text[0:link.start()] + replacement + text[link.end():] + + # Replace the <module tags + while 1: + link = LINK_MODULE_PATTERN.search(text) + + if not link: + break + + # Replace + replacement = '<a href="module_%s.html">%s</a>' % (link.group(1).lower().replace('.', '_'), link.group(2)) + text = text[0:link.start()] + replacement + text[link.end():] return text *************** *** 298,301 **** --- 310,314 ---- commands = [] functions = [] + constants = [] results = pattern.finditer(content) for result in results: *************** *** 309,313 **** if function: functions.append(function) ! return (commands, [], [], [], [], functions) # --- 322,364 ---- if function: functions.append(function) ! ! # Parse Constants ! #constants = re.compile('"""\\s*(.*?)\\s*"""', re.S) # Multiline comment pattern ! constantsre = re.compile('"""[^"]+\s*\\\\constants\s+([^\s]+)\s+(.*?)\\s*"""(.*?)"""[^"]*?\\\\end[^"]*?"""', re.S) ! iterator = constantsre.finditer(content) ! for result in iterator: ! module = result.group(1) ! name = result.group(2) ! code = result.group(3) ! description = '' ! if "\n" in name: ! (name, description) = name.split("\n", 1) ! ! # Remove multiline comments and intended lines from the ! # code and start parsing constants ! removemultiline = re.compile('""".*?"""', re.S) ! while 1: ! result = removemultiline.search(code) ! if not result: ! break ! code = code[:result.start()] + code[result.end():] ! ! constant = { ! 'module': module, ! 'name': name, ! 'description': processtext(description), ! 'constants': [], ! } ! ! findconstants = re.compile('^(\w+)\s*=\s*.*?$', re.M) ! results = findconstants.finditer(code) ! for result in results: ! name = result.group(1) ! if name.upper() != name: ! continue ! constant['constants'].append(result.group(0).strip()) ! constants.append(constant) ! ! return (commands, [], [], [], [], functions, constants) # *************** *** 426,428 **** BETA = result.group(1) ! return (commands, events, objects, objectsmethods, objectsproperties, functions) --- 477,479 ---- BETA = result.group(1) ! return (commands, events, objects, objectsmethods, objectsproperties, functions, []) Index: generate_html.py =================================================================== RCS file: /cvsroot/wpdev/xmlscripts/documentation/generate_html.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** generate_html.py 1 Jul 2004 21:32:35 -0000 1.7 --- generate_html.py 2 Jul 2004 13:29:00 -0000 1.8 *************** *** 1,4 **** --- 1,6 ---- + import re import math + import urllib import time import os *************** *** 15,18 **** --- 17,21 ---- objectsproperties = [] functions = [] + constants = [] if len(paths) == 0: *************** *** 27,30 **** --- 30,34 ---- global objectsproperties global functions + global constants #print "Examining %s..." % path *************** *** 33,40 **** for file in files: if os.path.isfile(file): ! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties, newfunctions) = parsepython(file) commands += newcommands events += newevents functions += newfunctions files = glob(path + '/*.cpp') --- 37,45 ---- for file in files: if os.path.isfile(file): ! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties, newfunctions, newconstants) = parsepython(file) commands += newcommands events += newevents functions += newfunctions + constants += newconstants files = glob(path + '/*.cpp') *************** *** 42,46 **** for file in files: if os.path.isfile(file): ! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties, newfunctions) = parsecpp(file) commands += newcommands events += newevents --- 47,51 ---- for file in files: if os.path.isfile(file): ! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties, newfunctions, newconstants) = parsecpp(file) commands += newcommands events += newevents *************** *** 54,58 **** for file in files: if os.path.isfile(file): ! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties, newfunctions) = parsecpp(file) commands += newcommands events += newevents --- 59,63 ---- for file in files: if os.path.isfile(file): ! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties, newfunctions, newconstants) = parsecpp(file) commands += newcommands events += newevents *************** *** 400,403 **** --- 405,421 ---- if current not in modules: modules.append(current) + + for constant in constants: + module = constant['module'] + current = '' + fmodules = module.split('.') + for module in fmodules: + if current != '': + current += '.' + module + else: + current = module + + if current not in modules: + modules.append(current) # Create an overview *************** *** 442,446 **** if function['module'] == module: localfunctions.append(function) ! template = open('templates/module.html') text = template.read() --- 460,469 ---- if function['module'] == module: localfunctions.append(function) ! ! localconstants = [] ! for constant in constants: ! if constant['module'] == module: ! localconstants.append(constant) ! template = open('templates/module.html') text = template.read() *************** *** 464,470 **** if id < len(localfunctions): function = localfunctions[id] ! overview += '<td>- <a href="#func_%s">%s</a></td>' % (function['name'].lower(), function['name']) else: ! overview += "<td> </td>\n"; overview += "</tr>\n" --- 487,493 ---- if id < len(localfunctions): function = localfunctions[id] ! overview += '<td width="15%%">- <a href="#func_%s">%s</a></td>' % (function['name'].lower(), function['name']) else: ! overview += "<td width=\"15%\"> </td>\n"; overview += "</tr>\n" *************** *** 474,477 **** --- 497,504 ---- # Generate a list of methods overview = '' + if len(localfunctions) > 0: + overview += """<p><span class="sectiontitle">MODULE FUNCTIONS</span><br> + <br>""" + for i in range(0, len(localfunctions)): function = localfunctions[i] *************** *** 505,510 **** if i != len(localfunctions) - 1: overview += '<hr size="1">' ! text = text.replace('{MODULEFUNCTIONS}', overview) output = open('webroot/module_%s.html' % module.replace('.', '_').lower(), "wt") --- 532,623 ---- if i != len(localfunctions) - 1: overview += '<hr size="1">' ! text = text.replace('{MODULEFUNCTIONS}', overview) + + # Create a function overview first + overview = '' + cols = 4 + rows = int(math.ceil(len(localconstants) / 4.0)) + + localconstants.sort(namesort) + + for row in range(0, rows): + if row == 0: + overview += """ + <br><strong>Constants:</strong> + <table width="100%" border="0" cellspacing="0" cellpadding="2">""" + + overview += "<tr>\n" + + for col in range(0, cols): + id = col * rows + row + if id < len(localconstants): + constant = localconstants[id] + overview += '<td width="25%%">- <a href="#const_%s">%s</a></td>' % (urllib.quote(constant['name'].lower()), constant['name']) + else: + overview += "<td width=\"25%\"> </td>\n"; + + overview += "</tr>\n" + + if row == rows - 1: + overview += "</table>" + + text = text.replace('{CONSTANTSOVERVIEW}', overview) + + # Generate a list of constants + overview = '' + + if len(localconstants) > 0: + overview += """<p><span class="sectiontitle">MODULE CONSTANTS</span><br> + <br>""" + + for i in range(0, len(localconstants)): + constant = localconstants[i] + consttext = '' + + for const in constant['constants']: + # If this constant is for a number, + # color it red, otherwise color it grey + quotecolor = re.compile('((?<!\\\\)".*?(?<!\\\\)")') + curpos = 0 + while 1: + result = quotecolor.search(const, curpos) + if not result: + break + newconst = const[:result.start()] + '<font color="#008000">%s</font>' % result.group(0) + curpos = len(newconst) + newconst += const[result.end():] + const = newconst + + quotecolor = re.compile('\\#.*') + curpos = 0 + while 1: + result = quotecolor.search(const, curpos) + if not result: + break + newconst = const[:result.start()] + '<font color="#008000">%s</font>' % result.group(0) + curpos = len(newconst) + newconst += const[result.end():] + const = newconst + + consttext += const + consttext += "<br>\n" + + if len(constant['description']) > 0: + constant['description'] += '<br>' + + overview += "<a name=\"const_%(anchor)s\"></a><b><code style=\"font-size: 12px\">%(name)s</code></b><br />\ + %(description)s<br/><code>%(constants)s</code>\n\ + <br /><a href=\"#top\">Back to top</a>\n" % { + 'name': constant['name'], + 'description': constant['description'], + 'anchor': urllib.quote(constant['name'].lower()), + 'constants': consttext + } + + if i != len(localconstants) - 1: + overview += '<hr size="1">' + + text = text.replace('{MODULECONSTANTS}', overview) output = open('webroot/module_%s.html' % module.replace('.', '_').lower(), "wt") |