autodoc duplicates class' methods
Question:
The automatically generated documentation duplicates the Methods
for the Test class, as shown below. Why is this duplication occurring and how can it be stopped?
I have tried several variations within the conf.py
module, but it has been to no avail. After the documentation image, there is a redacted version of this module.
class Test(object):
"""
Something here for test.
"""
def __init__(self):
pass
def fit(X, y):
pass
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'numpydoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.imgconverter']
numpydoc_class_members_toctree = False
autodoc_default_options = {'members': True,
'inherited-members': True,
'show-inheritance': True}
Answers:
For anyone else that faces this issue, I was able to fix it by replacing 'numpydoc'
with 'sphinx.ext.napoleon'
. Additionally, I removed numpydoc_class_members_toctree = False
.
If you still want to use numpydoc
, you can! The documentation lists configuration options to set in conf.py
. Setting the following options to False
eliminates the redundant entries in the autosummary.
numpydoc_show_class_members
numpydoc_show_inherited_class_members
So here is what your conf.py
should look like.
# conf.py
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'numpydoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.imgconverter']
numpydoc_class_members_toctree = False
# Add these lines.
numpydoc_show_class_members = False
numpydoc_show_inherited_class_members = False
Bonus: if you are using Jupyter Book, these go under the sphinx: config:
block in _config.yml
# _config.yml
sphinx:
extra_extensions:
- numpydoc
- sphinx.ext.autodoc
- sphinx.ext.autosummary
- sphinx.ext.doctest
- sphinx.ext.intersphinx
- sphinx.ext.imgconverter
config:
numpydoc_show_class_members: false
numpydoc_show_inherited_class_members: false
numpydoc_class_members_toctree: false
The automatically generated documentation duplicates the Methods
for the Test class, as shown below. Why is this duplication occurring and how can it be stopped?
I have tried several variations within the conf.py
module, but it has been to no avail. After the documentation image, there is a redacted version of this module.
class Test(object):
"""
Something here for test.
"""
def __init__(self):
pass
def fit(X, y):
pass
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'numpydoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.imgconverter']
numpydoc_class_members_toctree = False
autodoc_default_options = {'members': True,
'inherited-members': True,
'show-inheritance': True}
For anyone else that faces this issue, I was able to fix it by replacing 'numpydoc'
with 'sphinx.ext.napoleon'
. Additionally, I removed numpydoc_class_members_toctree = False
.
If you still want to use numpydoc
, you can! The documentation lists configuration options to set in conf.py
. Setting the following options to False
eliminates the redundant entries in the autosummary.
numpydoc_show_class_members
numpydoc_show_inherited_class_members
So here is what your conf.py
should look like.
# conf.py
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'numpydoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.imgconverter']
numpydoc_class_members_toctree = False
# Add these lines.
numpydoc_show_class_members = False
numpydoc_show_inherited_class_members = False
Bonus: if you are using Jupyter Book, these go under the sphinx: config:
block in _config.yml
# _config.yml
sphinx:
extra_extensions:
- numpydoc
- sphinx.ext.autodoc
- sphinx.ext.autosummary
- sphinx.ext.doctest
- sphinx.ext.intersphinx
- sphinx.ext.imgconverter
config:
numpydoc_show_class_members: false
numpydoc_show_inherited_class_members: false
numpydoc_class_members_toctree: false