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

#2021: changed autosummary to only consider elements of __all__, if present #9455

Closed

Conversation

randolf-scholz
Copy link

@randolf-scholz randolf-scholz commented Jul 15, 2021

Addresses #2021

Feature or Bugfix

  • Feature
  • Bugfix

Not sure if it should be considered a feature enhancement or bug fix.

Purpose

  • autosummary ignores __all__ files when determining members, this PR changes the behaviour to always respect the __all__ list, if it exists.

Detail

Changed 2 iterators from

for name in dir(obj):

to

for name in getall(obj) or dir(obj):

using the sphinx.util.inspect.getall function, which returns __all__, if it exists, else None.

Relates

@randolf-scholz randolf-scholz changed the title #2021: changed behaviour to only consider elements of __all__ members… #2021: changed autosummary behaviour to only consider elements of __all__, if present Jul 18, 2021
@randolf-scholz randolf-scholz changed the title #2021: changed autosummary behaviour to only consider elements of __all__, if present #2021: changed autosummary to only consider elements of __all__, if present Jul 18, 2021
@tk0miya tk0miya added this to the 4.2.0 milestone Jul 26, 2021
@marscher
Copy link

marscher commented Sep 7, 2021

Thank you, that would simplify my duties a lot!

@tk0miya tk0miya modified the milestones: 4.2.0, 4.3.0 Sep 12, 2021
Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. But we need to add an option to keep __all__ list ignored.

@randolf-scholz
Copy link
Author

Looks good. But we need to add an option to keep __all__ list ignored.

Is this really necessary? I would be surprised if there is a single project that really wants this option.
The point is that if one adds something like the following members block to the modules template

{% block members %}
{% if members %}
.. rubric:: {{ _('Module Members') }}
.. autosummary::
  :toctree: {{ objname }}
{% for item in members %}
  {{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

Then all of the otherwise hidden module members get added as well:

Screenshot from 2021-09-19 22-49-26

Who would want to see all this nonsense for every module?

@marscher
Copy link

I'd agree to that no one wants to have these kind of implementation details in the members list. However I think that since this is a change of behavior, people should be given the chance to still use the old behavior. Therefore we need a switch.

@tk0miya
Copy link
Member

tk0miya commented Sep 25, 2021

Is this really necessary? I would be surprised if there is a single project that really wants this option.

I can't say there are no projects that depend on the old behavior in the world. I agree they're very few. But this change will bring a breaking change for them. So I can't accept this change without an option.

@Yoshanuikabundi
Copy link
Contributor

@randolf-scholz Hi! I need this feature and don't want it to miss the next release. I'd be happy to extend this PR to take a configuration option, but don't want to step on your toes! Please let me know if you're committed to finishing things up here, or if you don't mind me taking over.

@randolf-scholz
Copy link
Author

@Yoshanuikabundi Hey, sorry I am super busy atm and don't really have time look into it currently. Personally, for several other reasons I also switched my projects to https://github.com/readthedocs/sphinx-autoapi.

@Yoshanuikabundi
Copy link
Contributor

@randolf-scholz No worries, thanks for the update!

@marscher
Copy link

@Yoshanuikabundi I sent a PR to @randolf-scholz including the config interface already. I think it would serve as a base to make further progress. The only thing missing are proper tests for the new interface.

@randolf-scholz when you are so busy, would you like to delegate this to our hands? I dunno if or how we would be able to directly push to your forked branch, but this would simplify things a lot. Thank you!

@tk0miya
Copy link
Member

tk0miya commented Nov 11, 2021

@marscher I think #9831 is a successor of this PR. Could you check it please?

@marscher
Copy link

sorry i'm out of time right now, but will do next week. The code looks good so far.

@tk0miya
Copy link
Member

tk0miya commented Nov 25, 2021

Now I merged #9831 as a successor of this PR. Thank you for all your contributions :-)

@tk0miya tk0miya closed this Nov 25, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants