Skip to content

DOC: Sort gallery subsections by filename - #11214

Closed
ImportanceOfBeingErnest wants to merge 1 commit into
matplotlib:masterfrom
ImportanceOfBeingErnest:sort-gallery
Closed

ImportanceOfBeingErnest wants to merge 1 commit into
matplotlib:masterfrom
ImportanceOfBeingErnest:sort-gallery

Conversation

@ImportanceOfBeingErnest

@ImportanceOfBeingErnest ImportanceOfBeingErnest commented May 10, 2018 •

Copy link
Copy Markdown
Member

PR Summary

Up to now the subsections of the gallery were sorted by the length of the code section(s) in the respective example. This let the gallery look a bit chaotic.
Instead it might be useful to sort the examples within each subsection by the filename of the example. This would still not give perfect thematic ordering, but since in many cases the filenames start with the name of the function they focus on, some kind of basic ordering would be achieved.

Note that an alternative would be to order by example headline/title. This seems not too useful because we can have the examples named like "A bar plot...", "Bar plot...", "Demo for Bar..", "Subplots with bars" etc.

This PR would introduce ordering by filename, since it seems to be the best one can achieve automatically and without renaming half of the examples.

PR Checklist

  • Code is PEP 8 compliant
  • Documentation is sphinx and numpydoc compliant

@tacaswell tacaswell added this to the v2.2-doc milestone May 10, 2018
@QuLogic

QuLogic commented May 10, 2018

Copy link
Copy Markdown
Member

This was added in sphinx-gallery 0.1.13, so you need to bump the minimum version in the requirements.

@ImportanceOfBeingErnest

Copy link
Copy Markdown
Member Author

Good point. I added this to the doc-requirements.txt.

@ImportanceOfBeingErnest

ImportanceOfBeingErnest commented May 10, 2018 •

Copy link
Copy Markdown
Member Author

It would be good if a small fix (#11221) could be merged before this PR. I can than rebase this on the fix.
Done, cheers.

@jklymak

jklymak commented May 10, 2018

Copy link
Copy Markdown
Member

I suppose this is beter. It'd still be nice if we could order them ourselves somehow...

https://124-100939689-gh.circle-artifacts.com/0/home/circleci/project/doc/build/html/gallery/index.html

@ImportanceOfBeingErnest

Copy link
Copy Markdown
Member Author

I mean we could order them by using consistent filenames. Or by using a clear structure for the titles (and then use another sphinx-gallery sorter). We could also writer our own sorter, but on what would it need to sort?

@jklymak

jklymak commented May 10, 2018

Copy link
Copy Markdown
Member

I mean we could just have an index.rst in the directory...

@ImportanceOfBeingErnest

Copy link
Copy Markdown
Member Author

... at some point one would then need to question how useful sphinx-gallery really is. Now we're already adding backreferences manually, next, we're creating the gallery by hand...

@jklymak

jklymak commented May 10, 2018

Copy link
Copy Markdown
Member

its been discussed 😉

@timhoffm timhoffm left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the examples this is an improvement, even though not optimal.

For the tutorials, this is equally bad, e.g. the first introductory tutorial should be the usage guide. We should manually define an order for the tutorials in some way.

Anyway, approving as better than before.

@jklymak

jklymak commented May 14, 2018

Copy link
Copy Markdown
Member

We should just number the file names of the tutorials. I assume it’ll sort on numbers. Suggest %03doldname.py. just in case someone gets ambitious

@timhoffm

Copy link
Copy Markdown
Member

Not sure that enforcing an order by a filename convention is good. This means that I have to rename the files in case I want to reorder them or add another tutorial. This also affects the url and would break existing links on the web.

@ImportanceOfBeingErnest

Copy link
Copy Markdown
Member Author

I agree with @timhoffm here. We do not want to rename any files and we do not want to break any links. But we do want to have control over at least some of the subsection orders, e.g. in the tutorials.

I think there is a solution to this. I will prepare a new PR later tonight or tomorrow.

@jklymak

jklymak commented May 15, 2018

Copy link
Copy Markdown
Member

Good points! Would you like this merged or did you want to wait on your new PR?

@anntzer

anntzer commented May 15, 2018

Copy link
Copy Markdown
Contributor

See sphinx-gallery/sphinx-gallery#275 (comment) for my thoughts on the topic...

@jklymak

jklymak commented May 15, 2018

Copy link
Copy Markdown
Member

It seems there is ExampleTitleSortKey. We could number those w/o breaking links. Better would be if they allowed a directive that could be put in the file, but...

@ImportanceOfBeingErnest

Copy link
Copy Markdown
Member Author

I posted an alternative to this PR in #11257. This would allow custom ordering where necessary.

The "thoughts" by @anntzer to use rst toctrees does not seem feasable (currently); they would need to come from the sphinx-gallery side.

The idea by @jklymak to number the examples themselves would be doable, but has the drawback to clutter the titles with numbers and makes it hard to change a once determined order in case a new example should be positionned between two existing ones.

I think the alternative in #11257 might be a good compromise for now.

@jklymak

jklymak commented May 16, 2018

Copy link
Copy Markdown
Member

Closing in lieu of #11257. Feel free to reopen if that doesn't work out

@jklymak jklymak closed this May 16, 2018
@QuLogic QuLogic removed this from the v2.2-doc milestone May 17, 2018
@ImportanceOfBeingErnest
ImportanceOfBeingErnest deleted the sort-gallery branch June 15, 2018 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants