sphinx-doc / sphinx-doc/sphinx

special-members doesn't work

Open
#9,818 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

I have a class histogram with a method __eq__, which I'd like to document.

When I write

.. autoclass:: histogram
    :members:
    :special-members: __eq__

it doesn't work (no such method appears in the documentation). I tried to add __eq__ to the list of :members: as suggested here, but it didn't work.

However, when I use a directive .. automethod::, it works, which looks like a bug. This works:

.. autoclass:: histogram
    :members:

    .. automethod:: __eq__
How to Reproduce
$ git clone https://github.com/ynikitenko/lena
$ cd lena
$ pip install -r requirements.txt
$ cd docs
$ # change the file 
$ vi sources/structures.py +55
$ make html
$ # open _build/html/index and see that it works / doesn't work
Expected behavior

special-members should work.

Your project

https://github.com/ynikitenko/lena

Screenshots

No response

OS

Arch Linux, 5.10.75-1-lts

Python version

3.9.7

Sphinx version

3.4.0

Sphinx extensions

'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.coverage', 'sphinx.ext.graphviz', 'sphinx.ext.mathjax', 'sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinxcontrib.napoleon',

Extra tools

No response

Additional context

Currently my readthedocs pages don't work because of another bug.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in the lena documentation using sources/structures.py, the autoclass directive, and :special-members: eq, then compare it with the working nested automethod example. Run make html and inspect the generated documentation; done means eq appears when requested through special-members.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.