Update of /cvsroot/wpdev/xmlscripts/documentation
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8268
Modified Files:
generate.py generate_html.py parse.py
Log Message:
generation of module information
Index: parse.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/documentation/parse.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** parse.py 6 Apr 2004 18:24:24 -0000 1.5
--- parse.py 26 Jun 2004 21:51:28 -0000 1.6
***************
*** 13,18 ****
CALLCONDITION_PATTERN = re.compile('\\\\condition\s+(.*?)(?=\Z|[\s\n]+\\\\\w)', re.S)
EVENT_NAME_PATTERN = re.compile("\\\\event\s(\w+)", re.S)
! PARAM_PATTERN = re.compile('\\\\param\s+(\w+)\s+(.*?)(?=\Z|[\s\n]+\\\\\w)', re.S)
INHERIT_PATTERN = re.compile('\\\\inherit\s+(\w+)\s*(?=\Z|[\s\n]+\\\\\w)', re.S)
VERSION = "Unknown"
--- 13,19 ----
CALLCONDITION_PATTERN = re.compile('\\\\condition\s+(.*?)(?=\Z|[\s\n]+\\\\\w)', re.S)
EVENT_NAME_PATTERN = re.compile("\\\\event\s(\w+)", re.S)
! PARAM_PATTERN = re.compile('\\\\param\s+(\w+)\s+([^\\\\]*?)\s*(?=\Z|[\s\n]+\\\\\w)', re.S)
INHERIT_PATTERN = re.compile('\\\\inherit\s+(\w+)\s*(?=\Z|[\s\n]+\\\\\w)', re.S)
+ FUNCTION_NAME_PATTERN = re.compile("\\\\function\s([\w\.]+)", re.S)
VERSION = "Unknown"
***************
*** 155,158 ****
--- 156,216 ----
'prototype': processtext(prototype),
}
+
+ #
+ # Parse an object function comment
+ #
+ def parsefunction(text):
+ module = ''
+ name = ''
+ description = ''
+ prototype = ''
+ parameters = ''
+ returnvalue = ''
+
+ # Get the object name we're documenting
+ result = FUNCTION_NAME_PATTERN.search(text)
+ if not result:
+ return None
+ else:
+ name = result.group(1).split('.')
+ if len(name) < 2:
+ return None
+ else:
+ module = '.'.join(name[:len(name)-1])
+ name = name[len(name) - 1]
+
+ # Search for the description
+ result = DESCRIPTION_PATTERN.search(text)
+ if result:
+ description = result.group(1)
+
+ # Search for the returnvalue
+ result = RETURNVALUE_PATTERN.search(text)
+ if result:
+ returnvalue = result.group(1)
+
+ parameters = [] # Generate a list of parameters
+ paramnames = []
+
+ results = PARAM_PATTERN.findall(text)
+ for result in results:
+ param = result[0].strip()
+ desc = result[1].strip()
+ if len(desc) > 0:
+ desc += "\n"
+ parameters.append("- <i>%s</i>\n%s" % (param, desc))
+ paramnames.append(param)
+
+ # Generate the prototype
+ prototype = "%s.%s(%s)" % (module, name, ', '.join(paramnames))
+
+ return {
+ 'module': processtext(module),
+ 'name': processtext(name),
+ 'description': processtext(description),
+ 'returnvalue': processtext(returnvalue),
+ 'parameters': processtext("\n".join(parameters)),
+ 'prototype': processtext(prototype),
+ }
#
***************
*** 222,225 ****
--- 280,284 ----
commands = []
+ functions = []
results = pattern.finditer(content)
for result in results:
***************
*** 229,233 ****
if command:
commands.append(command)
! return (commands, [], [], [], [])
#
--- 288,296 ----
if command:
commands.append(command)
! elif text.startswith('\\function'):
! function = parsefunction(text)
! if function:
! functions.append(function)
! return (commands, [], [], [], [], functions)
#
***************
*** 245,248 ****
--- 308,312 ----
events = []
objects = []
+ functions = []
objectsmethods = []
objectsproperties = []
***************
*** 267,270 ****
--- 331,338 ----
if method:
objectsmethods.append(method)
+ elif text.startswith('\\function'):
+ function = parsefunction(text)
+ if function:
+ functions.append(function)
elif text.startswith('\\property '):
text = text[10:]
***************
*** 341,343 ****
BETA = result.group(1)
! return (commands, events, objects, objectsmethods, objectsproperties)
--- 409,411 ----
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.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** generate_html.py 26 Jun 2004 18:57:35 -0000 1.2
--- generate_html.py 26 Jun 2004 21:51:28 -0000 1.3
***************
*** 14,27 ****
objectsmethods = []
objectsproperties = []
if len(paths) == 0:
! print "Usage: python generate_html.py path1[,path2,...]"
sys.exit()
- try:
- os.mkdir('output')
- except:
- pass
-
def examine(path):
global commands
--- 14,23 ----
objectsmethods = []
objectsproperties = []
+ functions = []
if len(paths) == 0:
! print "Usage: python generate.py path1[,path2,...]"
sys.exit()
def examine(path):
global commands
***************
*** 30,33 ****
--- 26,30 ----
global objectsmethods
global objectsproperties
+ global functions
#print "Examining %s..." % path
***************
*** 36,42 ****
for file in files:
if os.path.isfile(file):
! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties) = parsepython(file)
commands += newcommands
events += newevents
files = glob(path + '/*.cpp')
--- 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')
***************
*** 44,48 ****
for file in files:
if os.path.isfile(file):
! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties) = parsecpp(file)
commands += newcommands
events += newevents
--- 42,46 ----
for file in files:
if os.path.isfile(file):
! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties, newfunctions) = parsecpp(file)
commands += newcommands
events += newevents
***************
*** 50,53 ****
--- 48,52 ----
objectsmethods += newobjectsmethods
objectsproperties += newobjectsproperties
+ functions += newfunctions
files = glob(path + '/*.h')
***************
*** 55,59 ****
for file in files:
if os.path.isfile(file):
! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties) = 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
***************
*** 61,64 ****
--- 60,64 ----
objectsmethods += newobjectsmethods
objectsproperties += newobjectsproperties
+ functions += newfunctions
# Get subdirectories and process them
***************
*** 67,74 ****
if os.path.isdir(entry):
examine(entry)
!
for path in paths:
examine(path)
!
def quote(text):
return text.replace("'", "\\'")
--- 67,74 ----
if os.path.isdir(entry):
examine(entry)
!
for path in paths:
examine(path)
!
def quote(text):
return text.replace("'", "\\'")
***************
*** 78,96 ****
generated = time.strftime("%d.%m.%Y %H:%M")
- # Generate index page
- template = open('templates/index.html')
- text = template.read()
- template.close()
-
- text = text.replace('{GENERATED}', generated)
- text = text.replace('{VERSION}', version)
- text = text.replace('{COMMANDS}', str(len(commands)))
- text = text.replace('{OBJECTS}', str(len(objects)))
- text = text.replace('{EVENTS}', str(len(events)))
-
- output = open('output/index.html', "wt")
- output.write(text)
- output.close()
-
def namesort(a, b):
return cmp(a['name'], b['name'])
--- 78,81 ----
***************
*** 312,316 ****
for col in range(0, cols):
id = col * rows + row
! if id < len(methods):
property = properties[id]
overview += '<td>- <a href="#prop_%s">%s</a></td>' % (property['property'].lower(), property['property'])
--- 297,301 ----
for col in range(0, cols):
id = col * rows + row
! if id < len(properties):
property = properties[id]
overview += '<td>- <a href="#prop_%s">%s</a></td>' % (property['property'].lower(), property['property'])
***************
*** 396,405 ****
output.write(text)
output.close()
! #print "INSERT INTO documentation_objects VALUES('%s', '%s');" % (quote(object['object']), quote(object['description']))
! #for method in objectsmethods:
! #print "INSERT INTO documentation_objects_methods VALUES('%s', '%s', '%s', '%s', '%s', '%s');" % (quote(method['object']), quote(method['method']), quote(method['prototype']), quote(method['parameters']), quote(method['returnvalue']), quote(method['description']))
! #for property in objectsproperties:
! #print "INSERT INTO documentation_objects_properties VALUES('%s', '%s', '%s', '%s');" % (quote(property['object']), quote(property['property']), quote(property['description']), quote(property['readonly']))
--- 381,523 ----
output.write(text)
output.close()
+
+ # Generate a module list
+ modules = []
+
+ for function in functions:
+ module = function['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
! # Compile a command overview
! overview = ''
! cols = 7
! rows = int(math.ceil(len(modules) / 7.0))
! modules.sort()
!
! for row in range(0, rows):
! overview += "<tr>\n"
!
! for col in range(0, cols):
! id = col * rows + row
! if id < len(modules):
! module = modules[id]
! overview += '<td>- <a href="module_%s.html">%s</a></td>' % (module.replace('.', '_').lower(), module)
! else:
! overview += "<td> </td>\n";
!
! overview += "</tr>\n"
!
! # Write an index file for the objects.
! template = open('templates/modules.html')
! text = template.read()
! template.close()
!
! text = text.replace('{OVERVIEW}', overview)
! text = text.replace('{GENERATED}', generated)
! text = text.replace('{VERSION}', version)
!
! output = open('output/modules.html', "wt")
! output.write(text)
! output.close()
!
! # Find every function for the module and write
! # a module index file.
! for module in modules:
! # Create a list of functions for this module
! localfunctions = []
! for function in functions:
! if function['module'] == module:
! localfunctions.append(function)
!
! template = open('templates/module.html')
! text = template.read()
! template.close()
! text = text.replace('{GENERATED}', generated)
! text = text.replace('{VERSION}', version)
! # Create a function overview first
! overview = ''
! cols = 7
! rows = int(math.ceil(len(localfunctions) / 7.0))
!
! for row in range(0, rows):
! overview += "<tr>\n"
!
! for col in range(0, cols):
! id = col * rows + row
! 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"
!
! text = text.replace('{FUNCTIONOVERVIEW}', overview)
!
! # Generate a list of methods
! overview = ''
! for i in range(0, len(localfunctions)):
! function = localfunctions[i]
!
! parameters = ''
! if len(function['parameters']) > 0:
! parameters = "%s<br/><br/>\n" % function['parameters']
!
! returnvalue = ''
! if len(function['returnvalue']) > 0:
! returnvalue = "<span class=\"style2\">Return Value:</span><br/>%s<br/><br/>\n" % function['returnvalue']
!
! description = ''
! if len(function['description']) > 0:
! description = "<span class=\"style2\">Description:</span><br />%s<br />\n" % function['description']
!
! overview += "<a name=\"func_%(lowername)s\"></a> \
! <b><code style=\"font-size: 12px\">%(prototype)s</code></b><br />\
! <br/>%(parameters)s\n\
! %(returnvalue)s\n\
! %(description)s\n\
! <br /><a href=\"#top\">Back to top</a>\n" % {
! 'lowername': function['name'].lower(),
! 'name': function['name'],
! 'prototype': function['prototype'],
! 'parameters': parameters,
! 'returnvalue': returnvalue,
! 'description': description
! }
!
! if i != len(localfunctions) - 1:
! overview += '<hr size="1">'
!
! text = text.replace('{MODULEFUNCTIONS}', overview)
!
! output = open('output/module_%s.html' % module.replace('.', '_').lower(), "wt")
! output.write(text)
! output.close()
!
! # Generate index page
! template = open('templates/index.html')
! text = template.read()
! template.close()
!
! text = text.replace('{GENERATED}', generated)
! text = text.replace('{VERSION}', version)
! text = text.replace('{COMMANDS}', str(len(commands)))
! text = text.replace('{OBJECTS}', str(len(objects)))
! text = text.replace('{EVENTS}', str(len(events)))
! text = text.replace('{MODULES}', str(len(modules)))
!
! output = open('output/index.html', "wt")
! output.write(text)
! output.close()
\ No newline at end of file
Index: generate.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/documentation/generate.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** generate.py 25 Jun 2004 20:52:04 -0000 1.7
--- generate.py 26 Jun 2004 21:51:28 -0000 1.8
***************
*** 13,16 ****
--- 13,17 ----
objectsmethods = []
objectsproperties = []
+ functions = []
if len(paths) == 0:
***************
*** 24,27 ****
--- 25,29 ----
global objectsmethods
global objectsproperties
+ global functions
#print "Examining %s..." % path
***************
*** 30,36 ****
for file in files:
if os.path.isfile(file):
! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties) = parsepython(file)
commands += newcommands
events += newevents
files = glob(path + '/*.cpp')
--- 32,39 ----
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')
***************
*** 38,42 ****
for file in files:
if os.path.isfile(file):
! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties) = parsecpp(file)
commands += newcommands
events += newevents
--- 41,45 ----
for file in files:
if os.path.isfile(file):
! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties, newfunctions) = parsecpp(file)
commands += newcommands
events += newevents
***************
*** 44,47 ****
--- 47,51 ----
objectsmethods += newobjectsmethods
objectsproperties += newobjectsproperties
+ functions += newfunctions
files = glob(path + '/*.h')
***************
*** 49,53 ****
for file in files:
if os.path.isfile(file):
! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties) = parsecpp(file)
commands += newcommands
events += newevents
--- 53,57 ----
for file in files:
if os.path.isfile(file):
! (newcommands, newevents, newobjects, newobjectsmethods, newobjectsproperties, newfunctions) = parsecpp(file)
commands += newcommands
events += newevents
***************
*** 55,58 ****
--- 59,63 ----
objectsmethods += newobjectsmethods
objectsproperties += newobjectsproperties
+ functions += newfunctions
# Get subdirectories and process them
***************
*** 61,65 ****
if os.path.isdir(entry):
examine(entry)
!
for path in paths:
examine(path)
--- 66,70 ----
if os.path.isdir(entry):
examine(entry)
!
for path in paths:
examine(path)
***************
*** 107,108 ****
--- 112,114 ----
for property in objectsproperties:
print "REPLACE INTO documentation_objects_properties VALUES('%s', '%s', '%s', '%s');" % (quote(property['object']), quote(property['property']), quote(property['description']), quote(property['readonly']))
+
|