-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
DOC: Sort gallery subsections by explicit list then by filename #11257
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
DOC: Sort gallery subsections by explicit list then by filename #11257
Conversation
This looks great to me, unless there are some weird eide effects. I'd add a note both in the |
6b8c641
to
0b42cb3
Compare
I added a note in The doc built from the tests is available here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvement!
doc/sphinxext/gallery_order.py
Outdated
self.ordered_list = list_all | ||
|
||
def __call__(self, item): | ||
if item in self.ordered_list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Return a string determining the sort order."""
doc/sphinxext/gallery_order.py
Outdated
if item in self.ordered_list: | ||
return "{:04d}".format(self.ordered_list.index(item)) | ||
else: | ||
return "zzz" + item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "zzz" + item # ensure not explicitly listed items come last.
doc/sphinxext/gallery_order.py
Outdated
# Examples/tutorials that do not appear in a list will be appended. | ||
|
||
# Tutorials: | ||
list_introductory = ["usage", "pyplot", "sample_plots", "images", "lifecycle", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constructing all the small lists seems a bit cumbersome and is harder to read because of the variing list positions. I would just do:
explicit_subsection_order = [item + ".py" for item in [
# **Tutorials**
# introductory
"usage", "pyplot", "sample_plots", "images", "lifecycle", "customizing",
# intermediate
"artists", "legend_guide", "color_cycle", "gridspec",
"constrainedlayout_guide", "tight_layout_guide",
# advanced
# text
"text_intro", "text_props",
# colors
"colors",
# **Examples**
# color
"color_demo",
# pies
"pie_features", "pie_demo2",
]]
0b42cb3
to
641eb38
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. The sphinx galleries look great.
I'll leave this for someone like @timhoffm who's more up to speed with the current state of the docs
There seem to be a conflict, please backport manually |
PR Summary
This is an alternative to #11214.
In #11214 I proposed to order the subsections by filename instead of codelength (which is a useless measure). While sorting by filename is clearly better, there are still some undesired effects, mostly within the tutorials section where you would rather like to have a custom order implemented to e.g. have the User Guide be the first item in the "introductory" section.
This PR creates a custom "Order-Class" for both, the sections in the gallery / tutorial, as well as the subsections.
This allows to set an explicit order for items if desired and falls back to sorting by path-/filename if some list does not contain the item.
In this way we can have the gallery mostly look nice due to filename ordering, but where necessary/desired impose some custom order.
If you consider this a viable option, feel free to suggest further custom ordering for sections where you feel it is needed.
PR Checklist