Skip to content

DOC: dynamically size math symbol tables (closes #26143) #30172

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions doc/sphinxext/math_symbol_table.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
import math
from docutils.parsers.rst import Directive

from matplotlib import _mathtext, _mathtext_data
Expand Down Expand Up @@ -86,15 +87,15 @@ def render_symbol(sym, ignore_variant=False):
return f'\\{sym}' if sym in ('\\', '|', '+', '-', '*') else sym

lines = []
for category, columns, syms in symbols:
for category, _columns, syms in symbols:
syms = sorted(syms,
# Sort by Unicode and place variants immediately
# after standard versions.
key=lambda sym: (render_symbol(sym, ignore_variant=True),
sym.startswith(r"\var")),
reverse=(category == "Hebrew")) # Hebrew is rtl
rendered_syms = [f"{render_symbol(sym)} ``{sym}``" for sym in syms]
columns = min(columns, len(syms))
columns = max(3, int(math.ceil(math.sqrt(len(syms)))))
lines.append("**%s**" % category)
lines.append('')
max_width = max(map(len, rendered_syms))
Expand Down