<%global>
- import re
+ import re, types
def format_paragraphs(text):
- return text
return re.sub(r'([\w ])\n([\w ])', r'\1 \2', text or '', re.S)
</%global>
classes.sort(lambda a, b: cmp(a.__name__, b.__name__))
else:
if functions is None:
- functions = [getattr(obj, x).im_func for x in obj.__dict__.keys() if isinstance(getattr(obj,x), types.MethodType)
+ functions = (
+ [getattr(obj, x).im_func for x in obj.__dict__.keys() if isinstance(getattr(obj,x), types.MethodType)
and
(getattr(obj, x).__name__ == '__init__' or not getattr(obj,x).__name__[0] == '_')
- ]
- functions.sort(lambda a, b: cmp(a.__name__, b.__name__))
+ ] +
+ [(x, getattr(obj, x)) for x in obj.__dict__.keys() if isinstance(getattr(obj,x), property)
+ and
+ not x[0] == '_'
+ ]
+ )
+ functions.sort(lambda a, b: cmp(getattr(a, '__name__', None) or a[0], getattr(b, '__name__', None) or b[0] ))
if classes is None:
classes = []
</%init>
<&|doclib.myt:item, name=obj.__name__, description=description &>
-<&|formatting.myt:formatplain&><% format_paragraphs(obj.__doc__) %></&><br/>
+<&|formatting.myt:formatplain&><% format_paragraphs(obj.__doc__) %></&>
% if not isclass and len(functions):
<&|doclib.myt:item, name="modfunc", description="Module Functions" &>
%
</&>
</&>
-% elif len(functions):
+% else:
+% if len(functions):
<&|formatting.myt:paramtable&>
% for func in functions:
+% if isinstance(func, types.FunctionType):
<& SELF:function_doc, func=func &>
+% elif isinstance(func, tuple):
+ <& SELF:property_doc, name = func[0], prop=func[1] &>
+%
%
</&>
%
+%
% if len(classes):
<&|formatting.myt:paramtable&>
<&| formatting.myt:function_doc, name="def " + func.__name__, arglist=argstrings &>
<&|formatting.myt:formatplain&><% format_paragraphs(func.__doc__) %></&>
</&>
+</%method>
+
+
+<%method property_doc>
+ <%args>
+ name
+ prop
+ </%args>
+ <&| formatting.myt:member_doc, name=name + " = property()" &>
+ <&|formatting.myt:formatplain&><% format_paragraphs(prop.__doc__) %></&>
+ </&>
</%method>
\ No newline at end of file
'"' : '"'
}
-def html_escape(string):
+def do_html_escape(string):
#return "@" + re.sub(r"([&<>])", lambda m: html_escapes[m.group()], string) + "+"
return re.sub(r"([&<>])", lambda m: html_escapes[m.group()], string)
if highlighter is None:
if html_escape:
- return html_escape(source)
+ return do_html_escape(source)
else:
return source
else:
for pair in tokens:
if pair[1] is None:
if self.html_escape:
- self.output.write(html_escape(pair[0]))
+ self.output.write(do_html_escape(pair[0]))
else:
self.output.write(pair[0])
else:
if self.html_escape:
- self.output.write('<span class="%s">%s</span>' % (pair[1], html_escape(pair[0])))
+ self.output.write('<span class="%s">%s</span>' % (pair[1], do_html_escape(pair[0])))
else:
self.output.write('<span class="%s">%s</span>' % (pair[1], pair[0]))