diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-01-11 02:44:47 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-01-11 02:44:47 +0000 |
| commit | a6e7c0d084c601baeac7aba0b6462151e3fcd5b3 (patch) | |
| tree | be38ffe76b17fbbddfd3a84ea1f8c3eeff4a41f8 /doc | |
| parent | 8fd5f6369b9d4d3ccfa5fce7c0c605d6bb5b00e7 (diff) | |
| download | sqlalchemy-a6e7c0d084c601baeac7aba0b6462151e3fcd5b3.tar.gz | |
does pydoc for properties too
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/build/components/pydoc.myt | 36 | ||||
| -rw-r--r-- | doc/build/lib/highlight.py | 8 |
2 files changed, 33 insertions, 11 deletions
diff --git a/doc/build/components/pydoc.myt b/doc/build/components/pydoc.myt index 4f0b554e0..76a67c61f 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) </%global> @@ -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 @@ </%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" &> @@ -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> + + +<%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 diff --git a/doc/build/lib/highlight.py b/doc/build/lib/highlight.py index a35ba4853..df711965c 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('<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])) |
