sphinx-doc / sphinx-doc/sphinx

autosummary doesn't document annotated attributes with no default values

Open
#8,645 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug

For the following code, A.a won't be documented by autosummary:

class A:
    "A's doc"

    a: int
    "Doc"

To Reproduce
Steps to reproduce the behavior:

  1. Download bug.tar.gz and unarchive it.

  2. Run PYTHONPATH=. sphinx-build -d "./_build" docs "_build/html" -b html -W --color

.                                                                                                                                                                                             
├── docs                                                                                                                                                                                      
│   ├── conf.py
│   └── index.rst
└── myproject.py

myproject.py defines class A as above. index.rst shows:

Welcome to myproject's documentation!
=====================================

.. currentmodule:: myproject

.. autosummary::
   :toctree:

   A

conf.py is minimal:

project = 'myproject'
copyright = '2020, someone'
author = 'someone'
extensions = [
    'sphinx.ext.autosummary'
]
html_theme = 'alabaster'
autosummary_generate = True

Expected behavior
A.a being documented.

Environment info

  • OS: Debian 10
  • Python version: 3.7.3
  • Sphinx version: 3.4.1
  • Sphinx extensions: autosummary

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

Start by downloading and unpacking bug.tar.gz, then run the reported sphinx-build command against docs with warnings treated as errors. Trace how the autosummary entry for A is generated from myproject.py, and verify completion when the generated documentation includes A.a for the annotated attribute without a default value.

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.