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