Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added parsing function to gallery_order.py to categorize folders in galleries directory as sorted or unsorted#27442

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
ngmatt882 wants to merge5 commits intomatplotlib:mainfromngmatt882:galary

Conversation

ngmatt882
Copy link

@ngmatt882ngmatt882 commentedDec 5, 2023
edited
Loading

PR summary

Added a function in gallery_order.py to parse through README files in galleries directory. Function separates folders using key words, primarily their order type.
Addresses issue#25032. Review and advice is required before it can close issue#25032.

PR checklist

@story645
Copy link
Member

story645 commentedDec 5, 2023
edited
Loading

@timhoffm wanted it to be a gallery_order.txt file, I think the best thing is maybe make it configurable - possibly w/ fallback:

Look for gallery-order, then sort-order directive in readme, then the explicit lists in gallery_order?

If we're parsing the readme files, there needs to be some sort of comment/fake directive/(possibly real directive but that's out of scope here) to set off the file list so it doesn't get rendered as part of rendering the readme.

Also thanks for taking this on!

@story645
Copy link
Member

So selfishly I want this to go in b/c I want to make use of this oncesphinx-gallery/sphinx-gallery#1226 goes in. Can you add move one of the explicit file lists to a readme to show that this function works?

@timhoffm
Copy link
Member

I don't think the ordering should be defined in README, instead we should create a GALLERY_ORDERING.txt. Seesphinx-gallery/sphinx-gallery#1068 (comment).

@story645
Copy link
Member

I don't think the ordering should be defined in README,

I think in README the ordering would need to be set off with a pseudo-directive so it doesn't get rendered as part of the README. I think the easiest thing for this PR to implement is parsing a gallery_order.txt file

timhoffm reacted with thumbs up emoji

@ngmatt882
Copy link
Author

I'm a bit confused on what the issue should be addressing now. My current implementation falls short as you said there's no real comment in the galleries README as well as I'm unable to find other files. I'm happy to show you what results I have as of now which will be in the gallery_order.txt under galleries.

@story645
Copy link
Member

story645 commentedDec 6, 2023
edited
Loading

I'm a bit confused on what the issue should be addressing now

Sorry, should have been more detailed in the original issue. I'm gonna give the example of theplot types gallery. The way the gallery subheadings are ordered:

image

Is currently determined by this list ingallery_order.py:

plot_types_order= ['../galleries/plot_types/basic','../galleries/plot_types/stats','../galleries/plot_types/arrays','../galleries/plot_types/unstructured','../galleries/plot_types/3D',UNSORTED]

And subsection ordering is determined by:

list_all= [    ...# **Plot Types# Basic"plot","scatter_plot","bar","stem","step","fill_between",    ...    ]

I'm happy to show you what results I have as of now which will be in thegallery_order.txt under galleries.

This is on the right path, but the idea is that underplot_types/ for example, there would be a gallery_order.txt file that has a list of folders:

basicstatsarraysunstructured3D

and for example underbasic/ there would be anothergallery_order.txt that would do a subsection sort, for example:

bar.pyscatter_plot.pyplot.pyUNSORTEDfill_between.py

that lists the beginning and end plots.

And those files could be read into a list kind of like the one ingallery_order.py and used for ordering the sub galleries. The parent folders should be equal to the Path('gallery_order.txt`).parent and therefore don't need to be listed in the file.

These lists of files are fed into MplExplicitOrder and MPLExplicitSubOrder and that turns them into sorting keys used to sort the thumbnails. (I also should also add theunorderd implementation to MplExplicitSubOrder but really those classes can probably be consolidated as they've got the same call method->just instantiate them with different base lists but also I'm gonna say out of scope here...

totally optional

The totally not necessary proposal for readme is that in areadme.rst file you can set off the ordering using a comment/fake directive, so for example in the plot types readme:

.. _plot_types:..redirect-from::/tutorials/basic/sample_plotsPlot types==========Overview of many common plotting commands provided by Matplotlib.See the `gallery<../gallery/index.html>`_ for more examples andthe `tutorials page<../tutorials/index.html>`_ for longer examples...gallery-sort-order::   basic   stats   arrays   unstructured   3D

If it's not stashed in a comment, then rst will try to parse/build it as if it was plain text and we don't want that content on the readme.

ETA: when I say fall back, what I mean is that you can set it up so that sort order is determined by:

  1. gallery_order.txt
  2. if not in gallery_order.text then check readme .. gallery-sort-order::
  3. if not in .. gallery-sort-order then check ordering list in gallery_order.py

And the only reason I'm proposing fallback is then transition from one sorting scheme to the other can be done in follow up PRs

@story645
Copy link
Member

closing in favor of#27991 because that's a more robust solution

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
Status: Waiting for author
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[MNT]: Specify ordering in file in gallery folder
3 participants
@ngmatt882@story645@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp