sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.42k stars 2.1k forks source link

autoclass: sometimes, `__init__`'s parameters are appended #9808

Open Yura52 opened 2 years ago

Yura52 commented 2 years ago

Describe the bug

Screenshot 2021-11-01 at 23 53 06

How to Reproduce

$ git clone https://github.com/Yura52/zero
$ cd zero
$ git checkout tags/v0.0.7 -b debug
$ pip install numpy torch pynvml tqdm
$ pip install -r other/requirements_dev.txt
$ make clean && make docs
$ # open docs/build/html/index and visit the same pages that are described above

Expected behavior

No response

Your project

https://github.com/Yura52/zero/tree/main/docs

Screenshots

No response

OS

Mac

Python version

3.7.11

Sphinx version

4.1.2

Sphinx extensions

'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.napoleon', 'sphinx.ext.viewcode', 'sphinxcontrib.spelling', 'sphinx_copybutton',

Extra tools

No response

Additional context

No response

ts-mk commented 2 years ago

I confirm this bug occurs even in the latest version (Sphinx: 4.3.0, Python: 3.9.5). It seems to happen when type hints are used. If I remove them, the extra parameters section disappears from the class description.

ts-mk commented 2 years ago

autodoc_class_signature = "separated" (which I didn't know was introduced) corrects the behaviour for me because I want to have parameters within __init__()'s description. However, the default option (autodoc_class_signature = "mixed") doesn't behave as expected.