Hello,

Is it possible for Sphinx's autodoc module to "rename" Python types?

For example, say we have the following three files making up a
package:

./mypack/funcs.py
        __all__ = ['funca', 'funcb']
        import os, sys
        def funca():
                """This is a silly function."""
                pass
        def funcb():
                """Another silly function."""
                pass

./mypack/MyClass.py
        __all__ = ['MyClass']
        import os, sys
        class MyClass(object):
                """This is a silly class."""
                pass

./mypack/__init__.py
        """This is a silly package."""
        from MyClass import *
        from funcs import *
        del(funcs)

This way, when you "import mypack", the final package exposes two
"public" members:

        mypack.funca    # Points to mypack.funcs.funca
        mypack.funcb    # Points to mypack.funcs.funcb
        mypack.MyClass  # Points to mypack.MyClass<module>.MyClass<class>

At the package level, the extra imports of os and sys from funcs.py
and MyClass.py are "hidden", and the package namespace is further
cleaned by removing the "funcs" name from the package namespace.  We
typically author a lot of packages this way so the final surface area
of the package is "tidy".

Given that, it's not clear how we could use autodoc to automatically
produce "nice" docs.  For example, have the documentation reference a
class named mypack.MyClass, not mypack.MyClass.MyClass.  Or
automatically doc all functions in mypack.myfuncs without having to
list out each function exported by that module in a rst file.  I
looked at sphinx-apidoc, but it didn't quite give what we were looking
for (e.g. it produced docs referring to mypack.MyClass.MyClass).

I know this has been a bit hand wavey, but I'd be curious if there's a
magic bullet here or if this is just an example of "you're doing it
wrong".

Thanks for any insight,
John

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to sphinx-dev@googlegroups.com.
To unsubscribe from this group, send email to 
sphinx-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en.

Reply via email to