Closed
Description
A Python class with type annotation produces a warning: WARNING: duplicate object description
during the sphinx-build
if the sphinx.ext.napoleon
extension is used. This used to not produce any warnings on version 1.8.5 of sphinx, but produces the warnings in version 3.4.3.
To Reproduce
Steps to reproduce the behavior:
#!/usr/bin/env bash
set -e
set -x
mkdir repro && cd repro
mkdir -p docs/source
cat << EOF > generate_warning.py
class Test:
"""
Attributes:
attr: a doc
"""
attr: bool
EOF
cat << EOF > docs/source/conf.py
import os
import sys
sys.path.insert(0, os.path.abspath('../../'))
extensions = [
'sphinx.ext.napoleon',
]
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
EOF
cat << EOF > docs/source/index.rst
.. toctree::
apidoc/modules
EOF
# I use conda to create environemnts, but if you don't create a virtual env with
# sphinx 3.4.3 instead of the following block
cat << EOF > environment.yml
name: sphinx-duplicate-warning
channels:
- conda-forge
- nodefaults
dependencies:
- sphinx==3.4.3
EOF
conda env create
Then activate the environment and run sphinx build:
cd repro
conda activate sphinx-duplicate-warning
sphinx-apidoc --force --separate -o docs/source/apidoc . && sphinx-build -M html "docs/source" "build"
Expected behavior
No warning
Your project
repro.zip
Environment info
- OS: MacOS 10.15.7
- Python version: 3.8.6
- Sphinx version: 3.4.3
- Sphinx extensions: sphinx.ext.napoleon
Additional context
Submitted the same report to napoleon repo: sphinx-contrib/napoleon#30