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".

Changing objtype to "function" above does not work, as my custom
BoundMethodDocumenter gets overwritten when sphinx.ext.autodoc.setup
calls app.add_autodocumenter(FunctionDocumenter).  As objtype is used as
dictionary key for autodocs "documenter registry", there can be only one
documenter for a given objtype.

What is the correct way to tell sphinx to consider certain objects as
functions?

Many thanks,
Christoph

-- 
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.


Reply via email to