Commit 893eda71 authored by Amos Latteier's avatar Amos Latteier

Added support for documenting Functions to API help topics. This is necessary...

Added support for documenting Functions to API help topics. This is necessary to support help for things like PythonScripts.standard and the sequence module. Before the sequence module was DTML help, but that's wasn't right. This is especially obvious now the Python-based scripts and Page Templates can use the sequence module.
parent 55f3a377
......@@ -105,6 +105,7 @@ class APIHelpTopic(HelpTopic.HelpTopic):
"""
isAPIHelpTopic=1
funcs=() # for backward compatibility
def __init__(self, id, title, file):
self.id=id
......@@ -114,6 +115,7 @@ class APIHelpTopic(HelpTopic.HelpTopic):
self.doc=dict.get('__doc__','')
self.apis=[]
self.funcs=[]
for k, v in dict.items():
if (not _ignore_objects.has_key(k) or
_ignore_objects[k] is not v):
......@@ -123,7 +125,9 @@ class APIHelpTopic(HelpTopic.HelpTopic):
elif (hasattr(v, 'isImplementedByInstancesOf')):
# A scarecrow interface.
self.apis.append(APIDoc(v, 1))
elif type(v)==types.FunctionType:
# A function
self.funcs.append(MethodDoc(v, 0))
# try to get title from first non-blank line
# of module docstring
if not self.title:
......@@ -145,7 +149,7 @@ class APIHelpTopic(HelpTopic.HelpTopic):
def SearchableText(self):
"The full text of the Help Topic, for indexing purposes"
text="%s %s" % (self.title, self.doc)
for api in self.apis:
for api in self.apis + self.funcs:
text="%s %s" % (text, api.SearchableText())
return text
......
......@@ -2,7 +2,7 @@
<h1>API Documentation</h1>
<dtml-if "_.len(apis) > 1">
<dtml-if "_.len(apis) > 1 or (apis and funcs)">
<h3>Classes</h3>
<dl><dd>
<h2 class="api">
......@@ -14,12 +14,37 @@
</dd></dl>
</dtml-if>
<dtml-if "_.len(funcs) > 1 or (apis and funcs)">
<h3>Functions</h3>
<dl><dd>
<h2 class="api">
<dtml-in funcs>
<a href="#<dtml-var name>"><dtml-var name></a>
<dtml-unless sequence-end> , </dtml-unless>
</dtml-in>
</h2>
</dd></dl>
</dtml-if>
<dtml-if doc>
<dtml-var doc fmt="structured-text">
<hr noshade>
</dtml-if>
<dtml-in apis>
<dtml-if expr="_['sequence-start'] and funcs">
<h2>Classes</h2>
</dtml-if>
<dtml-var view>
<dtml-unless expr="_['sequence-end'] and not funcs">
<hr noshade>
</dtml-unless>
</dtml-in>
<dtml-in funcs>
<dtml-if expr="_['sequence-start'] and apis">
<h2>Functions</h2>
</dtml-if>
<dtml-var view>
<dtml-unless sequence-end>
<hr noshade>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment