On Wed, Nov 28, 2012 at 7:06 AM, Christoph Groth <[email protected]> wrote:
> Hello,
>
> I'd like to convince sphinx to auto-document bound methods as
> "autofunction" instead of "autodata". I've added this to our conf.py:
>
> import types
> from sphinx.ext import autodoc
>
> class BoundMethodDocumenter(autodoc.FunctionDocumenter):
> objtype = "bound_method"
>
> @classmethod
> def can_document_member(cls, member, membername, isattr, parent):
> # Return True iff `member` is a bound method. Taken from
> # <http://stackoverflow.com/a/1260881>.
> return (isinstance(member, types.MethodType) and
> member.im_self is not None and
> not issubclass(member.im_class, type) and
> member.im_class is not types.ClassType)
>
> autodoc.add_documenter(BoundMethodDocumenter)
>
> This "works" in the sense that sphinx now tries to document the bound
> methods with the "autobound_method" directive. But such a directive
> does not exist - I'd like bound methods to be documented with
> "autofunction".
I think you can do this using the directivetype attribute like in the
following (untested) code:
class BoundMethodDocumenter(autodoc.FunctionDocumenter):
objtype = "bound_method"
directivetype = "function"
...
--
Jonathan Waltman
--
You received this message because you are subscribed to the Google Groups
"sphinx-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/sphinx-users?hl=en.