Skip to content
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

[Bug]: mpltype custom role breaks sphinx build for third-party projects that have intersphinx links to matplotlib #28234

Open
lpsinger opened this issue May 16, 2024 · 8 comments · May be fixed by #28289

Comments

@lpsinger
Copy link
Contributor

Bug summary

Sphinx docs builds for third-party packages that have intersphinx cross-references to matplotlib are now failing with the following error message:

Unknown interpreted text role "mpltype".

This is because #27557 and Matplotlib 3.9.0 added the :mpltype: custom role to the docs. Would you please provide some guidance for how packages that depend on Matplotlib should be building their sphinx docs?

Code for reproduction

# See https://git.ligo.org/lscsoft/ligo.skymap

Actual outcome

See https://git.ligo.org/leo-singer/ligo.skymap/-/jobs/3342134

Expected outcome

Build should complete without errors

Additional information

No response

Operating system

No response

Matplotlib Version

3.9.0

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

pip

@timhoffm
Copy link
Member

timhoffm commented May 16, 2024

As a temporary workaround can you explicitly link against previous matplotlib versions? https://matplotlib.org/3.8.4/objects.inv

Edit: Looking at the error message, I suspect this is not an intersphinx issue. Instead. You are deriving from Matplotlib and by that inherit the docstring from Axes.__init__, which contains the :mpltype: role. As a workaround, you can try to explicitly set a dummy docstring for PPPlot.__init__.

@timhoffm
Copy link
Member

TODO: Do we have to make this role publically available via matplotlib.sphinxext so that downstream libraries can include it in their sphinx conf? OTOH :rc: is also not publically available and given its wide use, I'm surpised that nobody has stumbled over that.

@oscargus
Copy link
Contributor

Maybe it makes sense to make it publically available as well as :rc:, so that one can improve the documentation for third-party extensions (especially color would be great).

But isn't the reason for lack of earlier bug reports that very few projects inherit the doc-strings?

@story645
Copy link
Member

I don't understand how sphinx registers things well enough, but could it be b/c :rc: is a node object (same with :mathmpl:) while I'm not sure what's going on with :mpltype:

lpsinger added a commit to lpsinger/ligo.skymap that referenced this issue May 16, 2024
Matplotlib 3.9.0 added a custom Sphinx role that breaks packages
that link against Matplotlib's docs using intersphinx.

See matplotlib/matplotlib#28234
@timhoffm
Copy link
Member

There are two ways you can get Sphinx extensions:

  1. The docs/sphinxext folder. This is limited to the current docs.
  2. Via packages that are added to extensions in conf.py. These are portable and can be reused in other docs.

We currently have :mpltype: in (1), which I believed was enough because it’s intended for internal use only. However, it’s usage can leak into other documentations via docstring inheritance.

There are three ways we can handle this:

  1. move the extensions to matplotlib.sphinxext. Affected projects have to include them in their conf.py. To be checked whether the extensions would work in other documentations. Also we’d need to document that these are not intended for general use and can change anytime.
  2. Create simpler/dummy extensions in matplotlib.sphinxext that are text-only. Reasonable if 1. does not work or we want to keep the full functionality strictly private.
  3. Tell downstream projects, that inherit from us to overwrite docstrings when needed.

I‘m inclined towards (3) because it’s a rare effect and (3) is the least work for us.

@story645
Copy link
Member

story645 commented May 16, 2024

Via packages that are added to extensions in conf.py. These are portable and can be reused in other docs

Am slightly confused cause we do this in our conf far as I can tell:

'sphinxext.custom_roles',

@lpsinger
Copy link
Contributor Author

(3) would mean that projects like mine would need to write dummy Sphinx extensions, right? If so, I would prefer (2).

@tacaswell
Copy link
Member

We should promote mpltype to be publicly available.

@tacaswell tacaswell added this to the v3.9.1 milestone May 16, 2024
eerovaher added a commit to eerovaher/astropy that referenced this issue May 17, 2024
`matplotlib` 3.9.0 is causing documentation build failures for projects
that inherit docstrings that use the `:mpltype:` custom role:
matplotlib/matplotlib#28234
[ci skip]
@QuLogic QuLogic linked a pull request May 23, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants