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

Refactor math_symbol_table.py to dynamically determine column number#30105

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

Open
BeiChenStanly wants to merge2 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromBeiChenStanly:dynamic-math-symbol-table

Conversation

BeiChenStanly
Copy link

Fixed Issue#26143

  • Remove hardcoded column numbers; now columns are auto-calculated based on symbol length and page width constraints. Future changes to symbol lists require no manual column adjustment.

PR summary

This PR refactorsmath_symbol_table.py so that the symbol tables in the mathtext documentation dynamically determine the number of columns, instead of relying on hardcoded values.

What was changed

  • The column count is now determined automatically for each symbol group according to the content and layout constraints.
  • The minimum number of columns is set to 4, and the maximum is 6.
  • Original sorting and special symbol handling logic is preserved.
  • The directive and extension interface remain unchanged.

@github-actionsgithub-actionsbot added the Documentation: buildbuilding the docs labelMay 25, 2025
Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

@BeiChenStanlyBeiChenStanlyforce-pushed thedynamic-math-symbol-table branch 3 times, most recently from679cb47 to2420e6aCompareMay 25, 2025 05:56
@BeiChenStanlyBeiChenStanlyforce-pushed thedynamic-math-symbol-table branch 2 times, most recently fromb726525 to8fe5cb2CompareMay 25, 2025 10:39
…for symbol tables(Issuematplotlib#26143)- Remove hardcoded column numbers; now columns are auto-calculated based on symbol length and page width constraints. Future changes to symbol lists require no manual column adjustment.
@BeiChenStanlyBeiChenStanlyforce-pushed thedynamic-math-symbol-table branch from8fe5cb2 to76e8873CompareMay 26, 2025 05:05
Copy link
Member

@rcomerrcomer left a comment

Choose a reason for hiding this comment

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

Thanks for this@BeiChenStanly. I think this is a nice clean solution and the table renders well for me on both laptop and tablet screen. I just have some minor style comments.

@rcomerrcomer mentioned this pull requestMay 26, 2025
@story645
Copy link
Member

story645 commentedMay 26, 2025
edited
Loading

Any chance you can get this working w/ 1-2 columns for cell phones?

Also thank you very much for picking this up!

@timhoffm
Copy link
Member

Can't we defer the column layout to CSS? I'm not an expert in these things, but flexbox with flex-wrap could likely do the job.

@BeiChenStanlyBeiChenStanlyforce-pushed thedynamic-math-symbol-table branch from5d25f17 to9ea11daCompareMay 26, 2025 15:14
@BeiChenStanly
Copy link
Author

@story645@timhoffm
Thank you for your feedback!

  • For mobile devices, the symbol table supports horizontal scrolling.
  • Currently, the symbol table is rendered as a styled HTML<table>, and switching to a flexbox-based layout would require changing the output to<div> elements instead of<table>. This could introduce breaking changes across the documentation and affect existing styles
    For now, I've kept the table structure for consistency, but if there's interest in a more flexible layout in the future, we could consider a larger refactor.

Let me know if you have any further suggestions!

@story645
Copy link
Member

This could introduce breaking changes across the documentation and affect existing styles

Why if you only apply the css style to the div class for the math table? We have other custom css classes inhttps://github.com/matplotlib/matplotlib/blob/main/doc/_static/mpl.css

@rcomerrcomer removed their request for reviewMay 27, 2025 07:33
@rcomer
Copy link
Member

Apologies, I did not read the issue carefully enough and missed the bit about checking how it responds to window resizing. I think a few potential contributors also missed that so I took the liberty of editing the issue OP to hopefully make it obvious.

story645 and BeiChenStanly reacted with thumbs up emoji

@BeiChenStanly
Copy link
Author

Why if you only apply the css style to the div class for the math table? We have other custom css classes inhttps://github.com/matplotlib/matplotlib/blob/main/doc/_static/mpl.css

Thank you for your suggestion!

The current table styles are provided by the documentation theme, which ensures consistent look and feel (including things like row highlighting on hover, alternating row colors, and compatibility with theme changes) across all tables—certainly not just the math table. While it’s possible to apply a custom CSS class to a<div>-based structure, that would require us to rewrite all existing<table> elements as<div>s and reimplement all table-related styles and behaviors (such as row hover effects, responsive adjustments, etc.) in custom CSS.

This could lead to duplicated effort, potential inconsistencies, and more maintenance if the theme changes in the future.

In addition, I’d like to confirm the original intent of this issue, just to make sure we’re on the same page.

Is the main goal to:

  • Achieve a fully responsive layout for the symbol table (e.g., adapting the number of columns automatically based on screen size, like showing 1-2 columns on mobile and more on desktop)? or
  • Simply avoid hardcoding the number of columns in the code that generates the table, and instead compute the optimal column count based on content and available width (but still use a fixed table layout)?
    If the intention is to support true responsive layouts (for example, using CSS to adapt the number of columns on different devices), it would be helpful to state this explicitly in the issue description so we can design the solution accordingly.

Thanks again for your feedback!

@story645
Copy link
Member

The goal is more truly responsive layout, w/ avoiding fixed column size being a kinda of iterative step.

One of the ways we get responsive grids in other parts of the docs is by usinghttps://sphinx-design.readthedocs.io/en/latest/grids.html. Is there a way to maybe use that here - have the directive auto generate/populate a sphinx design grid?

@BeiChenStanly
Copy link
Author

Thank you for clarifying and for the suggestion regarding Sphinx Design grids!

I will work on redefining the directive to auto-generate a Sphinx Design grid and provide suitable CSS for the symbol table. I do want to note that if the theme or the Sphinx Design extension changes in the future, we may need to maintain or update the custom styles to ensure continued compatibility.

I'm also still learning about advanced grid layouts and their best practices, so I would really appreciate any further advice or examples you can share—especially regarding responsive grids and integration with Sphinx Design.

Thanks again for your helpful feedback and guidance!

story645 reacted with thumbs up emoji

@story645
Copy link
Member

provide suitable CSS for the symbol table

You might not need to - the sphinx grid might just do the trick.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@rcomerrcomerrcomer left review comments

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
Documentation: buildbuilding the docs
Projects
Status: Waiting for author
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[Doc]: dynamically resize the mathtext symbol tables
4 participants
@BeiChenStanly@story645@timhoffm@rcomer

[8]ページ先頭

©2009-2025 Movatter.jp