Open
Description
Consider a class that has an attribute without a default value, and is imported. If autoclass
is applied to this class and autosummary
is turned on, sphinx-build
errors out.
Reproduce
Download
bug.tar.gz. Unarchive it, and run
PYTHONPATH=. sphinx-build -v -d "./_build" docs "_build/html" -b html -W --color
It produces an error:
Running Sphinx v3.4.1
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
Traceback (most recent call last):
File "/home/hong/.local/lib/python3.7/site-packages/sphinx/cmd/build.py", line 280, in build_main
app.build(args.force_all, filenames)
File "/home/hong/.local/lib/python3.7/site-packages/sphinx/application.py", line 352, in build
self.builder.build_update()
File "/home/hong/.local/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 298, in build_update
len(to_build))
File "/home/hong/.local/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 310, in build
updated_docnames = set(self.read())
File "/usr/lib/python3.7/contextlib.py", line 119, in __exit__
next(self.gen)
File "/home/hong/.local/lib/python3.7/site-packages/sphinx/util/logging.py", line 214, in pending_warnings
memhandler.flushTo(logger)
File "/home/hong/.local/lib/python3.7/site-packages/sphinx/util/logging.py", line 179, in flushTo
logger.handle(record)
File "/usr/lib/python3.7/logging/__init__.py", line 1529, in handle
self.callHandlers(record)
File "/usr/lib/python3.7/logging/__init__.py", line 1591, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.7/logging/__init__.py", line 901, in handle
rv = self.filter(record)
File "/usr/lib/python3.7/logging/__init__.py", line 762, in filter
result = f.filter(record)
File "/home/hong/.local/lib/python3.7/site-packages/sphinx/util/logging.py", line 422, in filter
raise exc
sphinx.errors.SphinxWarning: /home/hong/tmp/myproject/_impl.py:docstring of myproject._impl.A.rst:1:autosummary: failed to import myproject.A.a
Warning, treated as error:
/home/hong/tmp/myproject/_impl.py:docstring of myproject._impl.A.rst:1:autosummary: failed to import myproject.A.a
Content of bug.tar.gz
:
├── docs
│ ├── conf.py
│ └── index.rst
└── myproject
├── _impl.py
└── __init__.py
_impl.py
:
class A:
"A's doc"
a: int
"a's doc."
__init__.py
:
from ._impl import A
conf.py
:
project = 'myproject'
copyright = '2020, someone'
author = 'someone'
extensions = [
'sphinx.ext.autodoc',
'autodocsumm'
]
html_theme = 'alabaster'
index.rst
:
Welcome to myproject's documentation!
=====================================
.. currentmodule:: myproject
.. autoclass:: A
:members:
:show-inheritance:
:autosummary:
Either removing :autosummary:
or put the definition of class A to __init__.py
resolves the error.
Metadata
Metadata
Assignees
Labels
No labels