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): ...@@ -105,6 +105,7 @@ class APIHelpTopic(HelpTopic.HelpTopic):
""" """
isAPIHelpTopic=1 isAPIHelpTopic=1
funcs=() # for backward compatibility
def __init__(self, id, title, file): def __init__(self, id, title, file):
self.id=id self.id=id
...@@ -114,6 +115,7 @@ class APIHelpTopic(HelpTopic.HelpTopic): ...@@ -114,6 +115,7 @@ class APIHelpTopic(HelpTopic.HelpTopic):
self.doc=dict.get('__doc__','') self.doc=dict.get('__doc__','')
self.apis=[] self.apis=[]
self.funcs=[]
for k, v in dict.items(): for k, v in dict.items():
if (not _ignore_objects.has_key(k) or if (not _ignore_objects.has_key(k) or
_ignore_objects[k] is not v): _ignore_objects[k] is not v):
...@@ -123,7 +125,9 @@ class APIHelpTopic(HelpTopic.HelpTopic): ...@@ -123,7 +125,9 @@ class APIHelpTopic(HelpTopic.HelpTopic):
elif (hasattr(v, 'isImplementedByInstancesOf')): elif (hasattr(v, 'isImplementedByInstancesOf')):
# A scarecrow interface. # A scarecrow interface.
self.apis.append(APIDoc(v, 1)) 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 # try to get title from first non-blank line
# of module docstring # of module docstring
if not self.title: if not self.title:
...@@ -145,7 +149,7 @@ class APIHelpTopic(HelpTopic.HelpTopic): ...@@ -145,7 +149,7 @@ class APIHelpTopic(HelpTopic.HelpTopic):
def SearchableText(self): def SearchableText(self):
"The full text of the Help Topic, for indexing purposes" "The full text of the Help Topic, for indexing purposes"
text="%s %s" % (self.title, self.doc) 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()) text="%s %s" % (text, api.SearchableText())
return text return text
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<h1>API Documentation</h1> <h1>API Documentation</h1>
<dtml-if "_.len(apis) > 1"> <dtml-if "_.len(apis) > 1 or (apis and funcs)">
<h3>Classes</h3> <h3>Classes</h3>
<dl><dd> <dl><dd>
<h2 class="api"> <h2 class="api">
...@@ -14,12 +14,37 @@ ...@@ -14,12 +14,37 @@
</dd></dl> </dd></dl>
</dtml-if> </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-if doc>
<dtml-var doc fmt="structured-text"> <dtml-var doc fmt="structured-text">
<hr noshade> <hr noshade>
</dtml-if> </dtml-if>
<dtml-in apis> <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-var view>
<dtml-unless sequence-end> <dtml-unless sequence-end>
<hr noshade> <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