readthedocs / sphinx-autoapi

A new approach to API documentation in Sphinx.
https://sphinx-autoapi.readthedocs.io/
MIT License
439 stars 131 forks source link

Not working with sphinx.ext.viewcode #346

Closed JeffSolo closed 2 years ago

JeffSolo commented 2 years ago

Including extension sphinx.ext.viewcode fails on Macbook Pro M1. The extension worked for the same files when building without using autoapi.

File "/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/ext/viewcode.py", line 268, in collect_pages lines[start])
IndexError: list index out of range

Sphinx traceback:

# Sphinx version: 5.0.2
# Python version: 3.7.13 (CPython)
# Docutils version: 0.18.1 release
# Jinja2 version: 2.10.1
# Last messages:
#   done
#   highlighting module code... [  0%] addin_processor.addin_processor
#   highlighting module code... [  0%] addin_processor.addin_processor_neo4j
#   highlighting module code... [  0%] addin_processor.app.helpers.arg_config_parsing
#   highlighting module code... [  0%] addin_processor.app.helpers.file_handling
#   highlighting module code... [  1%] addin_processor.app.process
#   highlighting module code... [  1%] addin_processor.app.validate
#   highlighting module code... [  1%] addin_processor.restore
#   highlighting module code... [  1%] addin_processor.utility.config
#   highlighting module code... [  1%] addin_processor.utility.logging
# Loaded extensions:
#   sphinx.ext.mathjax (5.0.2) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (2.0.0) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.5) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/alabaster/__init__.py
#   sphinx_rtd_theme (unknown version) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx_rtd_theme/__init__.py
#   sphinx.ext.autodoc.preserve_defaults (1.0) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/ext/autodoc/preserve_defaults.py
#   sphinx.ext.autodoc.type_comment (5.0.2) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/ext/autodoc/type_comment.py
#   sphinx.ext.autodoc (5.0.2) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.autosummary (5.0.2) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/ext/autosummary/__init__.py
#   sphinx.ext.napoleon (5.0.2) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/ext/napoleon/__init__.py
#   sphinx.ext.viewcode (5.0.2) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/ext/viewcode.py
#   sphinx.ext.graphviz (5.0.2) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/ext/graphviz.py
#   sphinx.ext.inheritance_diagram (5.0.2) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/ext/inheritance_diagram.py
#   autoapi.extension (unknown version) from /usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/autoapi/extension.py
Traceback (most recent call last):
  File "/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app.build(args.force_all, filenames)
  File "/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/application.py", line 329, in build
    self.builder.build_update()
  File "/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 290, in build_update
    len(to_build))
  File "/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 355, in build
    self.finish()
  File "/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/builders/html/__init__.py", line 660, in finish
    self.finish_tasks.add_task(self.gen_pages_from_extensions)
  File "/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/util/parallel.py", line 34, in add_task
    res = task_func()
  File "/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/builders/html/__init__.py", line 683, in gen_pages_from_extensions
    for pagename, context, template in pagelist:
  File "/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/sphinx/ext/viewcode.py", line 268, in collect_pages
    lines[start])
IndexError: list index out of range
AWhetter commented 2 years ago

Do you have a small test case (conf.py, rst files, and Python files) that I can test against? I can't reproduce your issue.