2

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}
bad_coder
  • 11,289
  • 20
  • 44
  • 72
sunspots
  • 1,047
  • 13
  • 29
  • To diagnose this we would need the full `.rst` file and would also have needed the `conf.py` for completeness. The question, as it stands, does not provide full information. However, if the answer solved your problem, and without more information, you should accept it by clicking the green check mark, in order for it not to show in the searches as unsolved. – bad_coder Oct 10 '20 at 20:56

2 Answers2

1

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.

sunspots
  • 1,047
  • 13
  • 29
0

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
vanPelt2
  • 870
  • 6
  • 16