Issues

Issue #1441 closed

Nested classes and autosummary

Daniel McDonald
created an issue

I'm currently working on documentation for scikit-bio, which relies on sphinx and numpydoc. Our documentation so far is coming along quite well, however, one of our modules uses nested classes and it appears that autosummary is handling them correctly. By nested classes, what I mean is:

class outer(object):
    class nested(object):
        pass

The module level docstring contains an autosummary call that resembles the following:

r"""foo (:mod:`foo`)
=================================================

.. currentmodule:: foo

does stuff

Classes
-------

.. autosummary::
   :toctree: generated/

   outer
"""

The version of sphinx I'm currently using is 1.2.2. The form of the error is below. (note, some sphinx line numbers might be off due to print statements I've added in, please let me know if this is an issue). For the purposes of an example, I took an existing module whose documentation [works](http://scikit-bio.readthedocs.org/en/latest/core.sequence.html, and added in an empty nested class called nested within BiologicalSequence. The empty class simply contains a pass.

Traceback (most recent call last):
  File "/Users/mcdonadt/.virtualenvs/python27/lib/python2.7/site-packages/sphinx/cmdline.py", line 254, in main
    app.build(force_all, filenames)
  File "/Users/mcdonadt/.virtualenvs/python27/lib/python2.7/site-packages/sphinx/application.py", line 212, in build
    self.builder.build_update()
  File "/Users/mcdonadt/.virtualenvs/python27/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 214, in build_update
    'out of date' % len(to_build))
  File "/Users/mcdonadt/.virtualenvs/python27/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 242, in build
    self.warn(*warning)
  File "/Users/mcdonadt/.virtualenvs/python27/lib/python2.7/site-packages/sphinx/application.py", line 260, in warn
    raise SphinxWarning(warntext)
SphinxWarning: /Users/mcdonadt/ResearchWork/software/scikit-bio/doc/source/generated/skbio.core.sequence.BiologicalSequence.rst:76: WARNING: autodoc: failed to import class u'nested' from module u'skbio.core.sequence.BiologicalSequence'; the following exception was raised:
Traceback (most recent call last):
  File "/Users/mcdonadt/.virtualenvs/python27/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 335, in import_object
    __import__(self.modname)
ImportError: No module named BiologicalSequence


Warning, treated as error:
/Users/mcdonadt/ResearchWork/software/scikit-bio/doc/source/generated/skbio.core.sequence.BiologicalSequence.rst:76: WARNING: autodoc: failed to import class u'nested' from module u'skbio.core.sequence.BiologicalSequence'; the following exception was raised:
Traceback (most recent call last):
  File "/Users/mcdonadt/.virtualenvs/python27/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 335, in import_object
    __import__(self.modname)
ImportError: No module named BiologicalSequence

make: *** [html] Error 1

Any insight into how to have nested classes included in the documentation would be greatly appreciated.

Comments (7)

  1. Log in to comment