Repository navigation
DOC: Sort gallery subsections by explicit list then by filename - #11257
Merged
timhoffm merged 1 commit intoMay 16, 2018
Merged
Conversation
2 tasks done
Member
|
This looks great to me, unless there are some weird eide effects. I'd add a note both in the |
ImportanceOfBeingErnest
force-pushed
the
sort-gallery-alternative
branch
from
May 15, 2018 22:53
6b8c641 to
0b42cb3
Compare
Member
Author
|
I added a note in The doc built from the tests is available here. |
jklymak
approved these changes
May 15, 2018
timhoffm
reviewed
May 16, 2018
| self.ordered_list = list_all | ||
|
|
||
| def __call__(self, item): | ||
| if item in self.ordered_list: |
Member
There was a problem hiding this comment.
"""Return a string determining the sort order."""
| if item in self.ordered_list: | ||
| return "{:04d}".format(self.ordered_list.index(item)) | ||
| else: | ||
| return "zzz" + item |
Member
There was a problem hiding this comment.
return "zzz" + item # ensure not explicitly listed items come last.
| # Examples/tutorials that do not appear in a list will be appended. | ||
|
|
||
| # Tutorials: | ||
| list_introductory = ["usage", "pyplot", "sample_plots", "images", "lifecycle", |
Member
There was a problem hiding this comment.
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",
]]
ImportanceOfBeingErnest
force-pushed
the
sort-gallery-alternative
branch
from
May 16, 2018 07:38
0b42cb3 to
641eb38
Compare
timhoffm
approved these changes
May 16, 2018
|
There seem to be a conflict, please backport manually |
6 tasks
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.
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