From: Mike Bayer Date: Wed, 11 Jan 2006 02:44:47 +0000 (+0000) Subject: does pydoc for properties too X-Git-Tag: rel_0_1_0~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6e7c0d084c601baeac7aba0b6462151e3fcd5b3;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git does pydoc for properties too --- diff --git a/doc/build/components/pydoc.myt b/doc/build/components/pydoc.myt index 4f0b554e00..76a67c61f9 100644 --- a/doc/build/components/pydoc.myt +++ b/doc/build/components/pydoc.myt @@ -1,7 +1,6 @@ <%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) @@ -44,11 +43,17 @@ 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 = [] @@ -61,7 +66,7 @@ <&|doclib.myt:item, name=obj.__name__, description=description &> -<&|formatting.myt:formatplain&><% format_paragraphs(obj.__doc__) %>
+<&|formatting.myt:formatplain&><% format_paragraphs(obj.__doc__) %> % if not isclass and len(functions): <&|doclib.myt:item, name="modfunc", description="Module Functions" &> @@ -71,13 +76,19 @@ % -% 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&> @@ -115,4 +126,15 @@ <&| formatting.myt:function_doc, name="def " + func.__name__, arglist=argstrings &> <&|formatting.myt:formatplain&><% format_paragraphs(func.__doc__) %> + + + +<%method property_doc> + <%args> + name + prop + + <&| formatting.myt:member_doc, name=name + " = property()" &> + <&|formatting.myt:formatplain&><% format_paragraphs(prop.__doc__) %> + \ No newline at end of file diff --git a/doc/build/lib/highlight.py b/doc/build/lib/highlight.py index a35ba48537..df711965ca 100644 --- a/doc/build/lib/highlight.py +++ b/doc/build/lib/highlight.py @@ -79,7 +79,7 @@ html_escapes = { '"' : '"' } -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) @@ -97,7 +97,7 @@ def highlight(source, filename = None, syntaxtype = None, html_escape = True): if highlighter is None: if html_escape: - return html_escape(source) + return do_html_escape(source) else: return source else: @@ -123,12 +123,12 @@ class Highlighter: 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('%s' % (pair[1], html_escape(pair[0]))) + self.output.write('%s' % (pair[1], do_html_escape(pair[0]))) else: self.output.write('%s' % (pair[1], pair[0]))