[Checkins] SVN: zope.app.apidoc/trunk/ Class documentation now includes constructor information.
Shane Hathaway
shane at hathawaymix.org
Tue Feb 3 05:09:27 EST 2009
Log message for revision 96022:
Class documentation now includes constructor information.
Changed:
U zope.app.apidoc/trunk/CHANGES.txt
U zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/README.txt
U zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/README.txt
U zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/class_.py
U zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/class_index.pt
U zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/class_.py
U zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/interfaces.py
-=-
Modified: zope.app.apidoc/trunk/CHANGES.txt
===================================================================
--- zope.app.apidoc/trunk/CHANGES.txt 2009-02-03 09:41:10 UTC (rev 96021)
+++ zope.app.apidoc/trunk/CHANGES.txt 2009-02-03 10:09:27 UTC (rev 96022)
@@ -14,6 +14,8 @@
- Expanded the presentation of module documentation.
+- Class documentation now includes constructor information.
+
3.6.0 (2009-01-31)
------------------
Modified: zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/README.txt
===================================================================
--- zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/README.txt 2009-02-03 09:41:10 UTC (rev 96021)
+++ zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/README.txt 2009-02-03 10:09:27 UTC (rev 96022)
@@ -145,6 +145,8 @@
('get', <unbound method APIDocumentation.get>,
<InterfaceClass zope.interface.common.mapping.IReadMapping>)
+ >>> klass.getConstructor()
+ <unbound method APIDocumentation.__init__>
Let's have a closer look at the `getAttributes()` method. First we create an
interface called `IBlah` that is implemented by the class `Blah`:
Modified: zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/README.txt
===================================================================
--- zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/README.txt 2009-02-03 09:41:10 UTC (rev 96021)
+++ zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/README.txt 2009-02-03 10:09:27 UTC (rev 96022)
@@ -161,6 +161,15 @@
{'path': 'zope.container.interfaces.IReadContainer',
'url': 'zope.container.interfaces.IReadContainer'}]
+`getConstructor()`
+~~~~~~~~~~~~~~~~~~
+
+Get info about the class' __init__ method, which is its constructor.
+
+ >>> pprint(details.getConstructor())
+ {'doc': u'<p>Initialize object.</p>\n',
+ 'signature': '()'}
+
`getAttributes()`
~~~~~~~~~~~~~~~~~
Modified: zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/class_.py
===================================================================
--- zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/class_.py 2009-02-03 09:41:10 UTC (rev 96021)
+++ zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/class_.py 2009-02-03 10:09:27 UTC (rev 96022)
@@ -149,3 +149,13 @@
return renderText(self.context.getDocString() or '',
getParent(self.context).getPath())
+ def getConstructor(self):
+ """Get info about the constructor, or None if there isn't one."""
+ attr = self.context.getConstructor()
+ if attr is None:
+ return None
+ attr = removeSecurityProxy(attr)
+ return {
+ 'signature': getFunctionSignature(attr),
+ 'doc': renderText(attr.__doc__ or '', inspect.getmodule(attr)),
+ }
Modified: zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/class_index.pt
===================================================================
--- zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/class_index.pt 2009-02-03 09:41:10 UTC (rev 96021)
+++ zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/browser/class_index.pt 2009-02-03 10:09:27 UTC (rev 96022)
@@ -63,6 +63,23 @@
</div>
+ <h2 class="details-section" i18n:translate="">Constructor</h2>
+
+ <div class="indent" tal:define="init view/getConstructor">
+ <div tal:condition="init">
+ <b><code
+ tal:content="string:__init__${init/signature}" />
+ </b><br>
+ <div class="inline documentation" tal:content="structure init/doc">
+ method desc
+ </div>
+ </div>
+ <p tal:condition="not: init">
+ <em i18n:translate="">This class uses the default constructor.</em>
+ </p>
+ </div>
+
+
<h2 class="details-section" i18n:translate="">Attributes/Properties</h2>
<div class="indent"
Modified: zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/class_.py
===================================================================
--- zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/class_.py 2009-02-03 09:41:10 UTC (rev 96021)
+++ zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/class_.py 2009-02-03 10:09:27 UTC (rev 96022)
@@ -13,7 +13,7 @@
##############################################################################
"""Class representation for code browser
-$Id: __init__.py 29143 2005-02-14 22:43:16Z srichter $
+$Id$
"""
__docformat__ = 'restructuredtext'
@@ -94,3 +94,10 @@
def getSecurityChecker(self):
"""See IClassDocumentation."""
return getCheckerForInstancesOf(self.__klass)
+
+ def getConstructor(self):
+ """See IClassDocumentation."""
+ init = getattr(self.__klass, '__init__', None)
+ if not ismethod(init):
+ return None
+ return init
Modified: zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/interfaces.py
===================================================================
--- zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/interfaces.py 2009-02-03 09:41:10 UTC (rev 96021)
+++ zope.app.apidoc/trunk/src/zope/app/apidoc/codemodule/interfaces.py 2009-02-03 10:09:27 UTC (rev 96022)
@@ -115,7 +115,10 @@
particular class attribute/method.
"""
+ def getConstructor():
+ """Return the __init__ method, or None if there isn't one."""
+
class IFunctionDocumentation(zope.interface.Interface):
"""Representation of a function for documentation."""
More information about the Checkins
mailing list