]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
does pydoc for properties too
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 11 Jan 2006 02:44:47 +0000 (02:44 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 11 Jan 2006 02:44:47 +0000 (02:44 +0000)
doc/build/components/pydoc.myt
doc/build/lib/highlight.py

index 4f0b554e001758257596dcb67a60d0fe6dc39593..76a67c61f998871061ac6999637bb9c4bcc574b2 100644 (file)
@@ -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>
 
                     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" &>
 %
 </&>
 </&>
-% 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
index a35ba48537b530725e4125909124a3b13daffe80..df711965ca6032cc6d534677cb8d1d36541a8a99 100644 (file)
@@ -79,7 +79,7 @@ html_escapes = {
     '"' : '&quot;'
 }
 
-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]))