-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate public access to many mathtext internals. #18378
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
Conversation
79d539e
to
d8025c9
Compare
90be77c
to
5da1c62
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conditional on CI passing.
f764aae
to
ca81014
Compare
I decided to also make |
336a702
to
130d7ca
Compare
doc/missing-references.json
Outdated
@@ -195,6 +200,70 @@ | |||
"dviread.PsfontsMap": [ | |||
"lib/matplotlib/dviread.py:docstring of matplotlib.dviread.DviFont:20" | |||
], | |||
"matplotlib._mathtext.Box": [ | |||
"doc/api/mathtext_api.rst:11", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes more sense to update these references, or delete them, rather than start accepting them as missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that (AFAICT) at least they will always show up in the SVG inheritance diagram. I got rid of the other occurrences, though.
130d7ca
to
6d2663b
Compare
6d2663b
to
6cebba5
Compare
For most of these classes, there isn't really a "reasonable" way to use them via public API anyways. - `Fonts` subclasses are looked up via the private `_font_type_mapping` and extending that would require adding new entries for `rcParams["mathtext.fontset"]`. - `FontConstantsBase`\s are looked up via the private `_font_constant_mapping`. - `Node` and its subclasses are clearly internal constructs of the mathtext parser (technically, they are visible to `MathtextBackend` subclasses when their `render` method is called, but one cannot register new `MathtextBackend` subclasses either as that happens via the private `_backend_mapping`). - `Ship` is just an implementation detail for the `ship` callable, which can only be called on a `Node` or in a `MathtextBackend`, neither of which are really public per the above. - `Parser` is set up and driven via the (still public) `MathTextParser`. - `Error`, `SHRINK_FACTOR`, `GROW_FACTOR`, `NUM_SIZE_LEVELS` are helpers for the parser. - `latex_to_*`, `stix_virtual_fonts`, `tex2uni` are helper lookup tables for the fonts. (`tex2uni` stays indirectly accessible via the `get_unicode_index`, which basically performs lookup on it.) Making these private should simplify the implementation of various improvements to mathtext, e.g. better support for math fonts, as well as code cleanups.
6cebba5
to
75c26f2
Compare
For most of these classes, there isn't really a "reasonable" way to use
them via public API anyways.
Fonts
subclasses are looked up via the private_font_type_mapping
and extending that would require adding new entries for
rcParams["mathtext.fontset"]
.FontConstantsBase
\s are looked up via the private_font_constant_mapping
.Node
and its subclasses are clearly internal constructs of themathtext parser (technically, they are visible to
MathtextBackend
subclasses when their
render
method is called, but one cannotregister new
MathtextBackend
subclasses either as that happens viathe private
_backend_mapping
).Ship
is just an implementation detail for theship
callable, whichcan only be called on a
Node
or in aMathtextBackend
, neither ofwhich are really public per the above.
Parser
is set up and driven via the (still public)MathTextParser
.Error
,SHRINK_FACTOR
,GROW_FACTOR
,NUM_SIZE_LEVELS
are helpersfor the parser.
latex_to_*
,stix_virtual_fonts
,tex2uni
are helper lookup tablesfor the fonts. (
tex2uni
stays indirectly accessible via theget_unicode_index
, which basically performs lookup on it.)Making these private should simplify the implementation of various
improvements to mathtext, e.g. better support for math fonts, as well as
code cleanups.
We can later decide how to properly expose these internals (e.g. #9165).
See also #16181.
PR Summary
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
andpydocstyle<4
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).