sphinx-doc / sphinxcontrib-django

This is a sphinx extension which improves the documentation of Django apps.
https://pypi.org/project/sphinxcontrib-django/
Apache License 2.0
45 stars 25 forks source link

AttributeError: 'Sphinx' object has no attribute 'extensions' #7

Closed NBajanca closed 6 years ago

NBajanca commented 6 years ago

Hello, I'm having an error while compiling the docs.
This error only occurs when I add sphinxcontrib-django to extensions.

I'm using Django 1.10 and sphinxcontrib-django 0.3.1.

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.intersphinx',
    'sphinx.ext.todo',
    'sphinx.ext.coverage',
    'sphinx.ext.napoleon',
    'sphinx.ext.viewcode',
    'sphinx.ext.graphviz',
    'sphinx_autodoc_annotation',
    'sphinxcontrib_django',
]

Full traceback

# Sphinx version: 1.5.6
# Python version: 3.5.3 (CPython)
# Docutils version: 0.13.1 release
# Jinja2 version: 2.9.6
# Last messages:
#   WARNING: while setting up extension sphinx_autodoc_annotation: directive 'automethod' is already registered, it will be overridden
#   loading pickled environment...
#   done
#   building [mo]: targets for 0 po files that are out of date
#   building [html]: targets for 0 source files that are out of date
#   updating environment:
#   [extensions changed] 16 added, 0 changed, 0 removed
#   reading sources... [  6%] index
#   reading sources... [ 12%] modules/app
#   reading sources... [ 18%] modules/app1
# Loaded extensions:
#   sphinx.ext.coverage (1.5.6) from /home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/coverage.py
#   sphinx.ext.viewcode (1.5.6) from /home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/viewcode.py
#   sphinx_autodoc_annotation (unknown version) from /home/APP_DIR/lib/python3.5/site-packages/sphinx_autodoc_annotation.py
#   sphinx.ext.napoleon (1.5.6) from /home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/napoleon/__init__.py
#   sphinx.ext.todo (1.5.6) from /home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/todo.py
#   sphinx.ext.graphviz (1.5.6) from /home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/graphviz.py
#   sphinxcontrib_django (unknown version) from /home/APP_DIR/lib/python3.5/site-packages/sphinxcontrib_django/__init__.py
#   sphinx.ext.intersphinx (1.5.6) from /home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/intersphinx.py
#   alabaster (0.7.10) from /home/APP_DIR/lib/python3.5/site-packages/alabaster/__init__.py
#   sphinx.ext.autodoc (1.5.6) from /home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/autodoc.py
Traceback (most recent call last):
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/cmdline.py", line 296, in main
    app.build(opts.force_all, filenames)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/application.py", line 333, in build
    self.builder.build_update()
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/builders/__init__.py", line 251, in build_update
    'out of date' % len(to_build))
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/builders/__init__.py", line 265, in build
    self.doctreedir, self.app))
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/environment/__init__.py", line 556, in update
    self._read_serial(docnames, app)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/environment/__init__.py", line 576, in _read_serial
    self.read_doc(docname, app)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/environment/__init__.py", line 684, in read_doc
    pub.publish()
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/core.py", line 217, in publish
    self.settings)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/io.py", line 55, in read
    self.parse()
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/__init__.py", line 185, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 170, in run
    input_source=document['source'])
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 2745, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 326, in section
    self.new_subsection(title, lineno, messages)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 394, in new_subsection
    node=section_node, match_titles=True)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    node=node, match_titles=match_titles)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 2745, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 326, in section
    self.new_subsection(title, lineno, messages)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 394, in new_subsection
    node=section_node, match_titles=True)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    node=node, match_titles=match_titles)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 2318, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 2330, in explicit_construct
    return method(self, expmatch)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 2073, in directive
    directive_class, match, type_name, option_presets)
  File "/home/APP_DIR/lib/python3.5/site-packages/docutils/parsers/rst/states.py", line 2122, in run_directive
    result = directive_instance.run()
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 1668, in run
    documenter.generate(more_content=self.content)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 1013, in generate
    self.document_members(all_members)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 935, in document_members
    check_module=members_check_module and not isattr)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 1010, in generate
    self.add_content(more_content)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 1383, in add_content
    ModuleLevelDocumenter.add_content(self, more_content)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 736, in add_content
    for i, line in enumerate(self.process_doc(docstrings)):
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 698, in process_doc
    self.options, docstringlines)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinx/application.py", line 589, in emit
    results.append(callback(self, *args))
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinxcontrib_django/docstrings.py", line 103, in improve_model_docstring
    _improve_class_docs(app, obj, lines)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinxcontrib_django/docstrings.py", line 116, in _improve_class_docs
    _add_model_fields_as_params(app, cls, lines)
  File "/home/APP_DIR/lib/python3.5/site-packages/sphinxcontrib_django/docstrings.py", line 146, in _add_model_fields_as_params
    if 'sphinx.ext.inheritance_diagram' in app.extensions and \
AttributeError: 'Sphinx' object has no attribute 'extensions'

Let me know if you need more information to debug! Thanks

vdboor commented 6 years ago

It seems that your sphinx version is a bit older (1.5.6). Could you try upgrading Sphinx?

NBajanca commented 6 years ago

Updated to 1.6 (1.6.7) and it did the charm! I would suggest you add that info to the readme file.

Thanks