Hi Michael,

I don't have a time now to do a longer answer. Please ask if more precision is
needed.

On Thu, May 26, 2011 at 10:14:36AM -0700, Michael Bayer wrote:
> How would I get, either via autodoc or even *not* autodoc, the
> __eq__() method below to appear in documentation?
> 
> class SomeFoo(object):
>     class SomeBar(object):
>         def __eq__(self, other):
>             """Compare a frobnozzle to other."""

[...]

> because autoclass can't handle it:
> 
> autodoc can't import/find class 'mypackage.SomeFoo.SomeBar', it
> reported error: "No module named SomeFoo", please check your spelling
> and sys.path

We have the same problem in Sage (www.sagemath.org). Actually, the problem is
not due to Sphinx but to Python itself which doesn't properly handles nested
classes in particular with respect to pickling. I personally think it is a bug
of Python itself. We partially solved the problem using a metaclass which
mangle the name of the class. For example, in your case:
   SomeFoo.SomeBar.__name__
is set to
   "SomeFoo.SomeBar"
instead of just
   "SomeBar"
We then insert in
    SomeFoo.__module__."SomeFoo.SomeBar" = SomeFoo.SomeBar
Then sphinx is able to find it. The remaining problem is to fix skip_member to
avoid sphinx documenting is under "SomeFoo.SomeBar"...

Some pointers:

   http://www.sagemath.org/doc/reference/sage/misc/nested_class.html
   
http://groups.google.com/group/sage-devel/browse_thread/thread/6c7055f4a580b7ae/

You can also browsed the following tickets on our trac server:

   #7448 : Fixes Sphinx rendering of nested classes
   #5986: Workaround mishandled nested classes in Python and cPickle

   http://trac.sagemath.org/sage_trac/ticket/7448
   http://trac.sagemath.org/sage_trac/ticket/5986

Note that our code currently bug if you have two level of nesting with
crosslink:

   http://trac.sagemath.org/sage_trac/ticket/9107

Hope this helps,

Florent

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