sphinx-doc / sphinx-doc/sphinx

autodoc for generic classes should include the type parameters

Open
#10,568 16 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

domains:py expert extensions:autodoc type:enhancement
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Currently, when autodoc renders a class of the form class Foo(Generic[T]), the resulting HTML just shows "class modulename.Foo", which omits information, as the type parameter is not shown. The only way to show the type parameter at the moment is to use :show-inheritance: to add a line of the form "Bases: Generic[T]". A generic class should instead be rendered as "class modulename.Foo[T]".

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 in Sphinx autodoc's class-rendering path and trace how generic bases are represented in the generated HTML. Check the existing output for a class declared as Generic[T], then update the relevant rendering behavior and verify that the result includes the type parameter as modulename.Foo[T] without relying on show-inheritance.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.