Skip to content

[MNT]: Specify ordering in file in gallery folder #25032

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

Open
story645 opened this issue Jan 19, 2023 · 3 comments · May be fixed by #27991
Open

[MNT]: Specify ordering in file in gallery folder #25032

story645 opened this issue Jan 19, 2023 · 3 comments · May be fixed by #27991
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Documentation: build building the docs Good first issue Open a pull request against these issues if there are no active ones!

Comments

@story645
Copy link
Member

story645 commented Jan 19, 2023

Since we wrote this extension to do the ordering, there's no reason we can't change it to read from README.txt in each directory. We could have it look for something that looks like a comment to reST so it does nothing in the sphinx-gallery-processed reST without having to do anything extra.
Originally posted by @QuLogic in #24746 (comment)

I think it's a relatively good first issue following #25028 because each readme can be parsed into its respective gallery list. Steps involved are

  1. figure out the reST comment notation that allows for easy specification of ordering + a consistent sentinel for placing unsorted files
  2. write a parser that translates the set of comments into a list that preserves the order (including sentinel)
  3. parse each file into its respective list in
    folder_lists = [examples_order, tutorials_order, plot_types_order]
  4. add documentation on doing this ordering to https://github.com/matplotlib/matplotlib/blob/main/doc/devel/documenting_mpl.rst?plain=1#L933

Medium difficulty because some familiarity with sphinx would be helpful, but not strictly necessary. I think a medium to advanced version of this would be implementing a .. gallery-toc custom directive

And yes, down the line we should maybe spin a maintain docs page off from the writing docs page.

An alternative to using the readme is using a special purpose 'gallery_order' file #24746 (comment)

@story645 story645 added Good first issue Open a pull request against these issues if there are no active ones! Documentation: build building the docs Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues labels Jan 19, 2023
@jklymak
Copy link
Member

jklymak commented Jan 19, 2023

I was going to open a discussion with sphinx-gallery about this as well. It seems like something they should be able to handle.

@QuLogic
Copy link
Member

QuLogic commented Jan 19, 2023

I looked into this yesterday; it's not particularly difficult to implement, and I did about half of it. The subsection order is pretty easy to do as each one is independent, but the problem with the higher section order is that we currently have a mix with some special things appearing after the unsorted ones. I did not fully investigate if the ordering class gets access to all the directories but I don't believe so, so there's a little bit of extra work to handle the bookkeeping of the split there.

@story645 story645 changed the title [MNT]: Specify gallery ordering in readme [MNT]: Specify ordering in file in gallery folder Jan 21, 2023
@Higgs32584
Copy link
Contributor

I want to do this issue, but I am a little bit confused by this part:
write a parser that translates the set of comments into a list that preserves the order (including sentinel)

Are you pulling the text from each README.md or reordering the directory? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Documentation: build building the docs Good first issue Open a pull request against these issues if there are no active ones!
Projects
None yet
4 participants