Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'type' object is not iterable #1674

Closed
loganesch-wf opened this issue Jan 14, 2015 · 5 comments
Closed

TypeError: 'type' object is not iterable #1674

loganesch-wf opened this issue Jan 14, 2015 · 5 comments

Comments

@loganesch-wf
Copy link

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!

@shimizukawa
Copy link
Member

@loganesch-wf I suspect that your python module A has a line like __all__ = SomeClass.
autodoc inspect A.__all__ to get members for documentation.

If it isn't true, please attach a small sample project to reproduce the issue. Thanks.

@birkenfeld
Copy link
Member

OK, I fixed crashes for the case @shimizukawa described. If this was the case here, we can close the issue.

@shimizukawa shimizukawa added this to the 1.2.x milestone Jan 15, 2015
@loganesch-wf
Copy link
Author

I'll pull down the latest master and see if that fixes my issue. Thanks for the quick turn around!

@loganesch-wf
Copy link
Author

Looks like that was it. Thank you! ⭐

@birkenfeld
Copy link
Member

Nice!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants