Skip to content

Docs fixes / improvements#483

Open
ilia-kats wants to merge 10 commits into
scverse:mainfrom
ilia-kats:docs_fixes
Open

Docs fixes / improvements#483
ilia-kats wants to merge 10 commits into
scverse:mainfrom
ilia-kats:docs_fixes

Conversation

@ilia-kats

Copy link
Copy Markdown
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
Copy Markdown
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

flying-sheep commented Mar 3, 2026

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member

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

@ilia-kats

Copy link
Copy Markdown
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
Copy Markdown
Member

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

@ilia-kats

Copy link
Copy Markdown
Collaborator Author

If you think so. Done.

this is necessary to make it pick up cross-references within the current
class, e.g. :attr:`n_obs`.
This is necessary to have return types for properties. See
discussion in scverse/mudata#130
@grst

grst commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

I'm not a huge fan of adding yet another custom file to the sphinx configuration.
We earlier discussed making the docs customizations a package #113

Could this be part of scverse-misc[docs]?
Is scanpydoc still actively used? Can it be replaced by scverse-misc?
Or is it better to have a separate package (e.g. scversedocs)?

@ilia-kats

Copy link
Copy Markdown
Collaborator Author

If you're talking about the new extension, that's a workaround for sphinx-doc/sphinx#14264. I'm happy to also put it into scverse-misc (might go well with scverse/scverse-misc#37), scanpydoc, or wherever, but then the cookiecutter template should use that package by default. Also note that that extension is tightly integrated with the class.rst template, so if we move it, we need to move everything.

@grst

grst commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

but then the cookiecutter template should use that package by default

agree, if everything that is now a custom sphinx configuration in this cookiecutter template is covered by scverse-misc, I'm happy to depend on it by default.

ilia-kats added a commit to scverse/scverse-misc that referenced this pull request Jul 1, 2026
This moves the autosummary templates and custom Sphinx extensions from
cookiecutter-scverse into our own Sphinx extension. See also the
discussion in scverse/cookiecutter-scverse#483
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.

3 participants