Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autosummary: Support documenting inherited attributes #10691

Merged
merged 8 commits into from
Apr 6, 2023

Conversation

jenshnielsen
Copy link
Contributor

@jenshnielsen jenshnielsen commented Jul 22, 2022

For inherited attributes qualname will not match the name of the actual obj that the attribute belongs to

Subject: Autosummary don't filter attributes on qualname

Feature or Bugfix

  • Bugfix

Purpose

Allow autosummary to document inherited instance attributes.
The current implementation of import_ivar_by_name filters attributes if the name of the
object that the attribute belongs to does not match the object being documented. However,
for inherited attributes this is not the case. For my simple project here https://github.com/jenshnielsen/debugproject
simply not filtering on qualname but only on the attribute name seems to resolve the issue.
It is not clear to me if there are any unwanted sideeffects of this and we should filter on the list of
qualnames for the object and all its super classes (if any)

If the super class is defined in another module the above is not sufficient so, try looking
up instance attributes on modules in the MRO of the object

Detail

  • If this approach is acceptable, I still need to write tests for this.

Relates

@jenshnielsen

This comment was marked as outdated.

@jenshnielsen
Copy link
Contributor Author

I have been using this for a while and other people in #9884 reports that this solves the issue for them too. Would it be possible to have this reviewed?

@jenshnielsen
Copy link
Contributor Author

@AA-Turner @takaakiaoki would it be possible to have this reviewed?

@AA-Turner AA-Turner changed the base branch from 5.x to master October 16, 2022 15:28
@jenshnielsen
Copy link
Contributor Author

We have been using this to build our own docs since August and it solves a very real problem for me and for others, see comments in #9884 Is there anything I can do to increase the change of this getting reviewed and eventually merged into master?

For inherited attributes qualname will not match the name of the actual obj that the attribute belongs to
Instance attirbutes on objects defined in other modules cannot be
found by module analyzer unless we import that module. So try
looking for instance attirbutes on objects in MRO order
With basic test that autosum can include inherited attributes
@jjyao
Copy link

jjyao commented Feb 8, 2023

@AA-Turner @takaakiaoki could someone review this PR? Thanks!

@IljaManakov
Copy link

Wow, this PR has been sitting here for 3 months. Can this please be merged at some point? The bug is really annoying.

@AA-Turner AA-Turner changed the title Autosummary support documenting inherited attributes autosummary: Support documenting inherited attributes Apr 6, 2023
@AA-Turner AA-Turner merged commit 3edae68 into sphinx-doc:master Apr 6, 2023
@AA-Turner
Copy link
Member

Thank you @jenshnielsen!

A

@AA-Turner AA-Turner added this to the 6.2.0 milestone Apr 8, 2023
@jenshnielsen jenshnielsen deleted the fix_9884 branch April 11, 2023 09:15
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sphinx autosummary: "failed to import Child.model" (inherited instance attribute)
4 participants