Commit 34a9c58e authored by Amos Latteier's avatar Amos Latteier

Beautified API docs and added support for Zope constructors in API docs.

parent 42ad3194
......@@ -156,18 +156,24 @@ class APIDoc(Persistent):
self.name=klass.__name__
self.doc=trim_doc_string(klass.__doc__)
# inheritence information
if hasattr(klass,'__extends__'):
self.extends=[]
for base in klass.__extends__:
names=string.split(base, '.')
url="%s/Help/%s.py#%s" % (names[0], names[1], names[2])
self.extends.append((names[2], url))
# constructor information
if hasattr(klass, '__constructor__'):
self.constructor=MethodDoc(klass.__constructor__)
# Get info on methods and attributes, ignore special items
self.attributes=[]
self.methods=[]
for k,v in klass.__dict__.items():
if k not in ('__extends__', '__doc__'):
if k not in ('__extends__', '__doc__', '__constructor__'):
if type(v)==types.FunctionType:
self.methods.append(MethodDoc(v))
else:
......@@ -213,6 +219,9 @@ class MethodDoc(Persistent):
kwargs=None
def __init__(self, func):
if hasattr(func, 'im_func'):
func=func.im_func
self.name=func.__name__
self.doc=trim_doc_string(func.__doc__)
......
......@@ -12,11 +12,22 @@
</h2>
<dl>
<dd class="api_doc">
<dd>
<dtml-var doc fmt="structured-text">
</dd>
</dl>
<dtml-if constructor>
<hr noshade>
<h3>Constructor</h3>
<dtml-with constructor>
<dtml-var view>
</dtml-with>
</dtml-if>
<hr noshade>
<h3>Methods</h3>
<dd>
<dtml-in attributes>
<dtml-var view>
</dtml-in>
......@@ -24,5 +35,3 @@
<dtml-in methods>
<dtml-var view>
</dtml-in>
</dd>
</dl>
\ No newline at end of file
<a name="&dtml-name;"></a>
<h2 class="method"><dtml-var name>
(
<dtml-in required>
<dtml-var sequence-item>
<dtml-if sequence-end>
<dtml-if optional> , </dtml-if>
<dtml-else> ,
</dtml-if>
</dtml-in>
<dtml-in optional>
<dtml-var sequence-key> = <dtml-var sequence-item>
<dtml-unless sequence-end>,</dtml-unless>
</dtml-in>
<dtml-if varargs>, *<dtml-var varargs> </dtml-if>
<dtml-if kwargs>, **<dtml-var kwargs> </dtml-if>
):
<h2 class="method"><dtml-var name>(<dtml-in required><dtml-var sequence-item><dtml-if sequence-end>
<dtml-if optional>, </dtml-if>
<dtml-else>,
</dtml-if>
</dtml-in>
<dtml-in optional>
<dtml-var sequence-key>=<dtml-var sequence-item><dtml-unless sequence-end>, </dtml-unless>
</dtml-in>
<dtml-if varargs>, *<dtml-var varargs></dtml-if>
<dtml-if kwargs>, **<dtml-var kwargs></dtml-if>):
</h2>
<dl><dd class="method_doc">
<dl><dd>
<dtml-var doc fmt="structured-text">
</dd></dl>
......@@ -18,25 +18,15 @@ padding: 10pt;
}
.api{
font-size: 16pt;
font-size: 14pt;
font-family : "Courier New", Courier, monospace;
}
.attribute, .method{
font-size: 14pt;
font-size: 12pt;
font-family : "Courier New", Courier, monospace;
}
.method_doc{
background: #FFFFDD;
padding: 12pt;
}
.api_doc{
background: #FFFFDD;
padding: 12pt;
}
</style>
</head>
......
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