pydata-sphinx-theme icon indicating copy to clipboard operation
pydata-sphinx-theme copied to clipboard

Add custom sphinx translator dynamically with a mixin

Open jorisvandenbossche opened this issue 4 years ago • 0 comments

Originally posted by @humitos in https://github.com/pandas-dev/pydata-sphinx-theme/pull/95#issuecomment-609067871

FYI, I changed the way that we are handling this in sphinx-hoverxref for a more permissive way. Instead of overriding the translator completely, I'm just adding the behavior that I need by creating a new class dynamically and inheriting from the translator define by the user (or extension) plus my mixin class with the behavior I need.

This allowed me to make my extension compatible with your theme. I just tested this theme with my extension and they both work nicely together!

So, if you think that you can be compatible with other HTML5Translator that the user could define, you may want to follow a similar pattern to avoid the same problem that I had with your theme.

See the PR at https://github.com/readthedocs/sphinx-hoverxref/pull/42

jorisvandenbossche avatar Apr 04 '20 18:04 jorisvandenbossche