0

When trying to build documentation (any type: html, man pages, latexpdf...) sphinx fails while trying to autodoc a subdirectory of a project. I've tried many different approaches to try to narrow down what the problem is but I can't seem to find the culprit. All of the rst files were generated by sphinx-apidoc.

directory A has the following rst file:

Directory A
=======================================

Submodules
----------

.. toctree::

   A.fileB
   A.fileC
   A.fileD
   A.fileE

Module contents
---------------

.. automodule:: A
    :members:
    :undoc-members:
    :show-inheritance:

Failure does not occur if the :members: directive is removed. Failure also does not occur if files B or E are missing, or if the import of file B in E is missing or commented out.

It will still fail if fileB and fileE are paired down to simply the following:

fileB:

class B(object):
    pass

fileE:

from fileB import B

class E(B):
    pass

with the following stack trace:

# Sphinx version: 1.3b2
# Python version: 2.7.5
# Docutils version: 0.12 release
# Jinja2 version: 2.6
# Last messages:
#   reading sources... [ 37%] foo
#   reading sources... [ 37%] foo
#   reading sources... [ 38%] foo
#   reading sources... [ 38%] foo
#   reading sources... [ 39%] foo
#   reading sources... [ 39%] foo
#   reading sources... [ 40%] foo
#   reading sources... [ 40%] foo
#   reading sources... [ 41%] foo
#   reading sources... [ 41%] problem file
# Loaded extensions:
#   sphinx.ext.autodoc (1.3b2) from Sphinx-1.3b2-py2.7.egg/sphinx/ext/autodoc.pyc
#   sphinx.ext.viewcode (1.3b2) from Sphinx-1.3b2-py2.7.egg/sphinx/ext/viewcode.pyc
Traceback (most recent call last):
  File "Sphinx-1.3b2-py2.7.egg/sphinx/cmdline.py", line 246, in main
    app.build(opts.force_all, filenames)
  File "Sphinx-1.3b2-py2.7.egg/sphinx/application.py", line 257, in build
    self.builder.build_update()
  File "Sphinx-1.3b2-py2.7.egg/sphinx/builders/__init__.py", line 237, in build_update
    'out of date' % len(to_build))
  File "Sphinx-1.3b2-py2.7.egg/sphinx/builders/__init__.py", line 251, in build
    self.doctreedir, self.app))
  File "Sphinx-1.3b2-py2.7.egg/sphinx/environment.py", line 585, in update
    self._read_serial(docnames, app)
  File "Sphinx-1.3b2-py2.7.egg/sphinx/environment.py", line 601, in _read_serial
    self.read_doc(docname, app)
  File "Sphinx-1.3b2-py2.7.egg/sphinx/environment.py", line 753, in read_doc
    pub.publish()
  File "docutils/core.py", line 217, in publish
    self.settings)
  File "docutils/readers/__init__.py", line 72, in read
    self.parse()
  File "docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "docutils/parsers/rst/__init__.py", line 172, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "docutils/parsers/rst/states.py", line 170, in run
    input_source=document['source'])
  File "docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "docutils/parsers/rst/states.py", line 2726, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "docutils/parsers/rst/states.py", line 2726, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "docutils/parsers/rst/states.py", line 2299, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "docutils/parsers/rst/states.py", line 2311, in explicit_construct
    return method(self, expmatch)
  File "docutils/parsers/rst/states.py", line 2054, in directive
    directive_class, match, type_name, option_presets)
  File "docutils/parsers/rst/states.py", line 2103, in run_directive
    result = directive_instance.run()
  File "Sphinx-1.3b2-py2.7.egg/sphinx/ext/autodoc.py", line 1441, in run
    documenter.generate(more_content=self.content)
  File "Sphinx-1.3b2-py2.7.egg/sphinx/ext/autodoc.py", line 816, in generate
    self.document_members(all_members)
  File "Sphinx-1.3b2-py2.7.egg/sphinx/ext/autodoc.py", line 699, in document_members
    members_check_module, members = self.get_object_members(want_all)
  File "Sphinx-1.3b2-py2.7.egg/sphinx/ext/autodoc.py", line 878, in get_object_members
    for mname in memberlist:
TypeError: 'type' object is not iterable

Is there something wrong in the files that autodoc is trying to read or if their is an issue with autodoc itself? is there some kind of work around I can try?

Thanks!

1 Answers1

0

So the solution to my issue was that the init for A simply had

from A.fileD import D
__all__ == D

when it should have contained:

from A.fileD import D
__all__ == ["D"]

Sphinx has also been updated so that instead of failing out when this happens it will issue a warning:

WARNING: missing attribute mentioned in :members: or __all__: ...

see https://github.com/sphinx-doc/sphinx/issues/1674 for more information.