DOCS: Render API methods inline via custom autosummary templates (#847)#885
Merged
henrydingliu merged 1 commit intoMay 30, 2026
Merged
Conversation
…act#847) Add custom autosummary templates (_templates/autosummary/{class,class_inherited,function}.rst) so API class pages document methods and properties inline instead of as a summary table linking to per-method stub pages. - Reference templates without the .rst extension in api.md; the prior ':template: class.rst' refs never resolved (Sphinx appends .rst, producing class.rst.rst) and silently fell back to the base template. - Set numpydoc_show_class_members=False and templates_path=['_templates'] so numpydoc no longer emits the duplicate members summary table. - Fix linkcode_resolve to unwrap property objects to their fget and guard inspect.getsourcefile/getsourcelines; documenting members inline exposed property objects that previously crashed the full jb build with a TypeError.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## experimental #885 +/- ##
=============================================
Coverage 87.04% 87.04%
=============================================
Files 86 86
Lines 4986 4986
Branches 646 646
=============================================
Hits 4340 4340
Misses 456 456
Partials 190 190
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
sphinx.ext.autosummarytemplates underdocs/_templates/autosummary/:class.rst,class_inherited.rst,function.rst.:template:names indocs/library/api.mdto drop.rst(:template: class.rst→:template: class).numpydoc_show_class_members = Falseandtemplates_path = ['_templates']indocs/_config.yml(and the generateddocs/conf.py).docs/_ext/linkcode.pyagainstpropertyobjects so inline members don't crash the build.Three issues fixed along the way:
:template: class.rstnever worked. Sphinx appends.rst, so it looked forautosummary/class.rst.rstand fell back to the base template. Names now omit the extension.numpydoc_show_class_members = Falsestops numpydoc emitting its own members table next to the inline members.linkcode_resolvecrash. Inline members passpropertyobjects to the resolver, whereinspect.getsourcefile(property)raisesTypeErrorand abortsjb build. Fixed by unwrapping properties tofgetand guardinggetsourcefile/getsourcelines.Related GitHub Issue(s)
experimental; builds on merged docs: remove autosummary-generated API stubs #879.Additional Context for Reviewers
conf.pyis regenerated from_config.ymlby Jupyter Book; both updated to stay in sync.jb build .succeeds (warnings all pre-existing). HTML spot checks:Development(class)Triangle(class_inherited)load_sample(function)One thing to decide: with
:inherited-members:on,Triangleshows 64 methods and 24 properties, including sklearn ones it inherits likeget_params,set_output,set_fit_request,get_metadata_routing. Do you want all of those shown, or should I hide the sklearn ones (or just drop inherited members entirely)? Let me know which you prefer and I'll adjust.jb build .(HTML builder).