Skip to content

Docs fixes / improvements#483

Open
ilia-kats wants to merge 6 commits intoscverse:mainfrom
ilia-kats:docs_fixes
Open

Docs fixes / improvements#483
ilia-kats wants to merge 6 commits intoscverse:mainfrom
ilia-kats:docs_fixes

Conversation

@ilia-kats
Copy link
Collaborator

Various fixes for the autosummary templates. In particular:

  • don't print Methods table heading if there are no methods

    Currently, the methods heading is printed if there are any methods, including __init__, but __init__ is filtered out from the methods list and table. This can lead to the situation that if a class has only __init__ and no other public methods, the "Methods table" and "Methods" headings will be printed, but no actual methods will be documented. Move the methods filtering to the very beginning and overwrite the methods variable with the filtered version to prevent above problem.

  • use fullname instead of objname in the class template

    With this change, one can apply autosummary to submodules of the package and have everything work.

  • add a module.rst autosummary template

    The only difference to the default template is the addition of toctree directives for functions, classes, and exceptions. This enables one to pass a module to autosummary and have it generate documenation pages and crossreferences for all top-level functions, classes, and exceptions, not just for submodules.

Currently, the methods heading is printed if there are any methods,
including __init__, but __init__ is filtered out from the methods list
and table. This can lead to the situation that if a class has only
__init__ and no other public methods, the "Methods table" and "Methods"
headings will be printed, but no actual methods will be documented.

Move the methods filtering to the very beginning and overwrite the
methods variable with the filtered version to prevent above problem.
With this change, one can apply autosummary to submodules of the package
and have everything work.
The only difference to the default template is the addition of toctree
directives for functions, classes, and exceptions. This enables one to
pass a module to autosummary and have it generate documenation pages and
crossreferences for all top-level functions, classes, and exceptions,
not just for submodules.
@ilia-kats
Copy link
Collaborator Author

The test-scripts workflow is failing due to some version parsing error somewhere in the requests package, unrelated to this PR.

@flying-sheep
Copy link
Member

flying-sheep commented Mar 3, 2026

I did something similar here: scverse/anndata@2bd53b8

The loop.first style is more elegant since there are fewer blocks involved, so while you’re changing these templates, why not like that!

@ilia-kats
Copy link
Collaborator Author

Done. Although I still like the previous version better: It only filtered in one place, now we have to filter in two places (methods table and methods docs).

@flying-sheep
Copy link
Member

we could both re-define the variable and use the loop.first style, right?

@ilia-kats
Copy link
Collaborator Author

True, but then I don't really see a difference to my original approach, it's just moving the if block from outside the loop to inside the loop.

@flying-sheep
Copy link
Member

Yeah, it’s just fewer endifs next to each other – easier to understand.

@ilia-kats
Copy link
Collaborator Author

If you think so. Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants