Skip to content

[Doc]: Suppress missing references through a ! prefix instead of missing_references extension. #28920

Closed

Description

@timhoffm

Problem

Our standard way to handle missing references is our missing_references extension, which specifies explicit error messages including line numbers inside missing_references.json.

This is cumbersome because docstring edits can change the line numbers, requiring to adapt the missing_references.json.

Suggested improvement

I just found out, that one can suppress references by prefixing with an exclamation mark. This seems undocumented but is used inside the sphinx docs, e.g. :class:`!MyClass` . I've opened an issue on that: sphinx-doc/sphinx#12940.

If this is intended as a public feature on the sphinx side, I propose to switch to it and dump our missing references. This has several advantages:

  • The missing info is inlined, so that we can see in the sources whether the link will works or not.
  • We don't have problems with line number changes anymore.
  • When references vanish, e.g. by removal after deprecation, we don't have to change old references, e.g. in changelog to a literal role, but can simply prefix them with the exclamation mark.
  • It's still straight forward to get an overview of missing references by searching for `!

Sprint task

For the following references, add a ! in front, e.g. :class:`MyClass` -> :class:`!MyClass`

When the reference is inside a method docstring, the method is listed in parenthesis, e.g. :class:`MyClass` (method)

To avoid merge conflicts, please choose 1 file to work on at a time and note it here

doc/tutorials/

  • galleries/tutorials/artists.py: Updates the galleries/tutorials/artists.py file in response to issue #28920 #29080
    • :attr:matplotlib.axes.Axes.patch
    • :attr:matplotlib.figure.Figure.patch
    • :class:matplotlib.backend_bases.FigureCanvas
    • :class:matplotlib.backend_bases.Renderer
    • :attr:matplotlib.figure.Figure.transFigure
    • :attr:matplotlib.axes.Axes.patches
    • :attr:matplotlib.axes.Axes.xaxis
    • :attr:matplotlib.axes.Axes.yaxis

doc/users/

#29086

  • galleries/users/explain/figure/event_handling.py:
    • :obj:Rectangle.contains
    • :obj:Line2D.pick
  • galleries/users/explain/figure/interactive.py:
    • :obj:ipykernel.pylab.backend_inline
  • galleries/users/explain/figure/interactive_guide.py:
    • :obj:Artist.stale_callback
    • :obj:Figure.stale_callback
    • :meth:IPython.terminal.interactiveshell.TerminalInteractiveShell.inputhook

doc/api/

  • doc/api/toolkits/axisartist.rst:
    • :class:mpl_toolkits.axisartist.Axes
  • doc/api/toolkits/mplot3d.rst:
    • :attr:mpl_toolkits.mplot3d.axis3d._axinfo

lib/matplotlib/

  • lib/matplotlib/axes/_axes.py:
    • :meth:matplotlib.collections._CollectionWithSizes.set_sizes (matplotlib.axes._axes.Axes.barbs)
    • :obj:ax.transAxes (matplotlib.axes._axes.Axes.inset_axes)
    • :meth:matplotlib.collections._MeshData.set_array (matplotlib.axes._axes.Axes.pcolormesh)
    • :obj:kde.factor (matplotlib.axes._axes.Axes.violinplot)
  • lib/matplotlib/axes/_base.py:
    • :obj:fmt_xdata (matplotlib.axes._base._AxesBase.format_xdata)
    • :obj:fmt_ydata (matplotlib.axes._base._AxesBase.format_ydata)
  • lib/matplotlib/backend_bases.py:
    • :obj:Timer (matplotlib.backend_bases.FigureCanvasBase.new_timer)
    • :obj:_iter_collection_raw_paths (matplotlib.backend_bases.RendererBase.draw_path_collection)
    • :obj:_iter_collection (matplotlib.backend_bases.RendererBase.draw_path_collection)
    • :class:matplotlib.backend_bases._Backend (matplotlib.backend_bases.ShowBase)
    • :obj:ToolContainer (matplotlib.backend_bases.ToolContainerBase.remove_toolitem)
  • lib/matplotlib/backend_tools.py:
    • :obj:toggled (matplotlib.backend_tools.AxisScaleBase.disable)
  • lib/matplotlib/backends/backend_agg.py:
    • :obj:draw_image (matplotlib.backends.backend_agg.RendererAgg.option_scale_image)
  • lib/matplotlib/backends/backend_cairo.py:
    • :obj:option_scale_image (matplotlib.backends.backend_cairo.RendererCairo.draw_image)
  • lib/matplotlib/backends/backend_pdf.py:
    • :class:matplotlib.backends._backend_pdf_ps.RendererPDFPSBase (matplotlib.backends.backend_pdf.RendererPdf)
  • lib/matplotlib/backends/backend_tkagg.py:
    • :class:matplotlib.backends._backend_tk.FigureCanvasTk (matplotlib.backends.backend_tkagg.FigureCanvasTkAgg)
  • lib/matplotlib/colorbar.py:
    • :attr:lines (matplotlib.colorbar.Colorbar.add_lines)
  • lib/matplotlib/dviread.py:
    • :obj:_read (matplotlib.dviread.Vf)
  • lib/matplotlib/image.py:
    • :obj:can_composite (matplotlib.image.composite_images)
    • :obj:make_image (matplotlib.image.composite_images)
  • lib/matplotlib/mlab.py:
    • :obj:kde.covariance_factor (matplotlib.mlab.GaussianKDE)
  • lib/matplotlib/patches.py:
    • :class:matplotlib.patches._Style (matplotlib.patches.ArrowStyle)
    • :class:matplotlib.patches.ArrowStyle._Curve (matplotlib.patches.ArrowStyle.BarAB)
    • :class:matplotlib.patches.ArrowStyle._Base (matplotlib.patches.ArrowStyle.Fancy)
    • :class:matplotlib.patches.ConnectionStyle._Base (matplotlib.patches.ConnectionStyle.Angle3)
  • lib/matplotlib/patheffects.py:
    • :meth:AbstractPathEffect._update_gc (matplotlib.patheffects.SimpleLineShadow)
  • lib/matplotlib/projections/geo.py:
    • :class:matplotlib.projections.geo._GeoTransform (matplotlib.projections.geo.AitoffAxes.AitoffTransform)
    • :attr:input_dims (matplotlib.projections.geo.AitoffAxes.AitoffTransform.transform_non_affine)
    • :attr:output_dims (matplotlib.projections.geo.AitoffAxes.AitoffTransform.transform_non_affine)
  • lib/matplotlib/pyplot.py:
    • :obj:Image (matplotlib.pyplot.gci)
  • lib/matplotlib/quiver.py:
    • :meth:_find_tails (matplotlib.quiver.Barbs)
    • :meth:_make_barbs (matplotlib.quiver.Barbs)
  • lib/matplotlib/scale.py:
    • :attr:name (matplotlib.scale.ScaleBase)
  • lib/matplotlib/testing/compare.py:
    • :obj:converter (matplotlib.testing.compare.compare_images)
  • lib/matplotlib/transforms.py:
    • :attr:height (matplotlib.transforms.Bbox.bounds)
    • :attr:width (matplotlib.transforms.Bbox.bounds)
    • :attr:min (matplotlib.transforms.Bbox.p0)
    • :attr:max (matplotlib.transforms.Bbox.p1)
    • :attr:xmin (matplotlib.transforms.Bbox.x0)
    • :attr:xmax (matplotlib.transforms.Bbox.x1)
    • :attr:ymin (matplotlib.transforms.Bbox.y0)
    • :attr:ymax (matplotlib.transforms.Bbox.y1)
    • :class:matplotlib.transforms._BlendedMixin (matplotlib.transforms.BlendedAffine2D)
  • lib/matplotlib/tri/_trirefine.py:
    • :attr:triangulation (matplotlib.tri._trirefine.UniformTriRefiner.refine_triangulation)
  • lib/matplotlib/widgets.py:
    • :obj:active (matplotlib.widgets.AxesWidget)
    • :attr:eventson (matplotlib.widgets.CheckButtons.set_active)
    • :class:matplotlib.widgets._SelectorWidget (matplotlib.widgets.LassoSelector)

lib/mpl_toolkits/

  • lib/mpl_toolkits/axes_grid1/anchored_artists.py:
    • :attr:matplotlib.axes.Axes.transData (mpl_toolkits.axes_grid1.anchored_artists.AnchoredAuxTransformBox)
    • :attr:matplotlib.axes.Axes.transAxes (mpl_toolkits.axes_grid1.anchored_artists.AnchoredDirectionArrows)
  • lib/mpl_toolkits/axes_grid1/axes_grid.py:
    • :attr:cbar_axes (mpl_toolkits.axes_grid1.axes_grid.ImageGrid)
    • :obj:Size.from_any (mpl_toolkits.axes_grid1.axes_grid.ImageGrid)
  • lib/mpl_toolkits/axes_grid1/axes_size.py:
    • :obj:get_size (mpl_toolkits.axes_grid1.axes_size)
    • :class:mpl_toolkits.axes_grid1.axes_size._Base (mpl_toolkits.axes_grid1.axes_size.Add)
  • lib/mpl_toolkits/axisartist/axis_artist.py:
    • :obj:mpl_toolkits.axislines.Axes (mpl_toolkits.axisartist.axis_artist)
  • lib/mpl_toolkits/axisartist/axisline_style.py:
    • :class:mpl_toolkits.axisartist.axisline_style.AxislineStyle._Base (mpl_toolkits.axisartist.axisline_style.AxislineStyle.SimpleArrow)
  • lib/mpl_toolkits/mplot3d/axes3d.py:
    • :attr:fmt_zdata (mpl_toolkits.mplot3d.axes3d.Axes3D.format_zdata)

Activity

  1. AbhinRustagi commented on Oct 9, 2024

    @AbhinRustagi

    @timhoffm I would be happy to work on this

  2. timhoffm commented on Oct 11, 2024

    @timhoffm
    MemberAuthor

    @AbhinRustagi thanks for the interest. So far, this is a proposal. I'd like to get feedback from other core devs before moving forward.

  3. tacaswell commented on Oct 11, 2024

    @tacaswell
    Member

    I am 👍 on using this.

    As a side note, how long at ! done this?

  4. timhoffm commented on Oct 11, 2024

    @timhoffm
    MemberAuthor

    Since 2007: sphinx-doc/sphinx@b6024b9a (and it has been documented since 2008 sphinx-doc/sphinx@06dd99e1)

  5. timhoffm commented on Oct 11, 2024

    @timhoffm
    MemberAuthor

    @AbhinRustagi you are welcome to start working on this.

  6. story645 commented on Nov 4, 2024

    @story645
    Member

    Updated the above w/ all the entries in missing reference that seemed easily fixable. The rest of the entries I can't find in any docstring/doc and about half seem to be due to how the animation class is architectured, but I'll list them here for anyone who wants to take a stab at figuring out what's going on:

    Animation

    • doc/api/_as_gen/matplotlib.animation.ArtistAnimation.rst:
      • :obj:matplotlib.animation.ArtistAnimation.new_frame_seq
      • :obj:matplotlib.animation.ArtistAnimation.new_saved_frame_seq
      • :obj:matplotlib.animation.ArtistAnimation.pause
      • :obj:matplotlib.animation.ArtistAnimation.resume
      • :obj:matplotlib.animation.ArtistAnimation.save
      • :obj:matplotlib.animation.ArtistAnimation.to_html5_video
      • :obj:matplotlib.animation.ArtistAnimation.to_jshtml
    • doc/api/_as_gen/matplotlib.animation.FFMpegFileWriter.rst:
      • :obj:matplotlib.animation.FFMpegFileWriter.bin_path
      • :obj:matplotlib.animation.FFMpegFileWriter.finish
      • :obj:matplotlib.animation.FFMpegFileWriter.grab_frame
      • :obj:matplotlib.animation.FFMpegFileWriter.isAvailable
      • :obj:matplotlib.animation.FFMpegFileWriter.saving
      • :obj:matplotlib.animation.FFMpegFileWriter.setup
    • doc/api/_as_gen/matplotlib.animation.FFMpegWriter.rst:
      • :obj:matplotlib.animation.FFMpegWriter.bin_path
      • :obj:matplotlib.animation.FFMpegWriter.finish
      • :obj:matplotlib.animation.FFMpegWriter.grab_frame
      • :obj:matplotlib.animation.FFMpegWriter.isAvailable
      • :obj:matplotlib.animation.FFMpegWriter.saving
      • :obj:matplotlib.animation.FFMpegWriter.setup
      • :obj:matplotlib.animation.FFMpegWriter.frame_size
      • :obj:matplotlib.animation.FFMpegWriter.output_args
      • :obj:matplotlib.animation.FFMpegWriter.supported_formats
    • doc/api/_as_gen/matplotlib.animation.FileMovieWriter.rst:
      • :obj:matplotlib.animation.FileMovieWriter.bin_path
      • :obj:matplotlib.animation.FileMovieWriter.isAvailable
      • :obj:matplotlib.animation.FileMovieWriter.saving
    • doc/api/_as_gen/matplotlib.animation.HTMLWriter.rst:
      • :obj:matplotlib.animation.HTMLWriter.bin_path
      • :obj:matplotlib.animation.HTMLWriter.saving
    • doc/api/_as_gen/matplotlib.animation.ImageMagickFileWriter.rst:
      • :obj:matplotlib.animation.ImageMagickFileWriter.bin_path
      • :obj:matplotlib.animation.ImageMagickFileWriter.finish
      • :obj:matplotlib.animation.ImageMagickFileWriter.grab_frame
      • :obj:matplotlib.animation.ImageMagickFileWriter.isAvailable
      • :obj:matplotlib.animation.ImageMagickFileWriter.saving
      • :obj:matplotlib.animation.ImageMagickFileWriter.setup
    • doc/api/_as_gen/matplotlib.animation.ImageMagickWriter.rst:
      • :obj:matplotlib.animation.ImageMagickWriter.bin_path
      • :obj:matplotlib.animation.ImageMagickWriter.finish
      • :obj:matplotlib.animation.ImageMagickWriter.grab_frame
      • :obj:matplotlib.animation.ImageMagickWriter.isAvailable
      • :obj:matplotlib.animation.ImageMagickWriter.saving
      • :obj:matplotlib.animation.ImageMagickWriter.setup
    • doc/api/_as_gen/matplotlib.animation.MovieWriter.rst:
      • :obj:matplotlib.animation.MovieWriter.saving
    • doc/api/_as_gen/matplotlib.animation.PillowWriter.rst:
      • :obj:matplotlib.animation.PillowWriter.saving
    • doc/api/_as_gen/matplotlib.animation.TimedAnimation.rst:
      • :obj:matplotlib.animation.TimedAnimation.new_frame_seq
      • :obj:matplotlib.animation.TimedAnimation.new_saved_frame_seq
      • :obj:matplotlib.animation.TimedAnimation.pause
      • :obj:matplotlib.animation.TimedAnimation.resume
      • :obj:matplotlib.animation.TimedAnimation.save
      • :obj:matplotlib.animation.TimedAnimation.to_html5_video
      • :obj:matplotlib.animation.TimedAnimation.to_jshtml
    • lib/matplotlib/animation.py:
      • :obj:matplotlib.animation.FFMpegFileWriter.frame_format (matplotlib.animation.FFMpegFileWriter.supported_formats)
      • :obj:matplotlib.animation.FFMpegFileWriter.frame_size (matplotlib.animation.FFMpegFileWriter.supported_formats)
      • :obj:matplotlib.animation.FFMpegFileWriter.output_args (matplotlib.animation.FFMpegFileWriter.supported_formats)
      • :obj:matplotlib.animation.FileMovieWriter.frame_size (matplotlib.animation.FileMovieWriter.finish)
      • :obj:matplotlib.animation.FileMovieWriter.supported_formats (matplotlib.animation.FileMovieWriter.finish)
      • :obj:matplotlib.animation.FuncAnimation.pause (matplotlib.animation.FuncAnimation.new_frame_seq)
      • :obj:matplotlib.animation.FuncAnimation.resume (matplotlib.animation.FuncAnimation.new_frame_seq)
      • :obj:matplotlib.animation.FuncAnimation.save (matplotlib.animation.FuncAnimation.new_frame_seq)
      • :obj:matplotlib.animation.FuncAnimation.to_html5_video (matplotlib.animation.FuncAnimation.new_frame_seq)
      • :obj:matplotlib.animation.FuncAnimation.to_jshtml (matplotlib.animation.FuncAnimation.new_frame_seq)
      • :obj:matplotlib.animation.HTMLWriter.frame_format (matplotlib.animation.HTMLWriter.finish)
      • :obj:matplotlib.animation.HTMLWriter.frame_size (matplotlib.animation.HTMLWriter.finish)
      • :obj:matplotlib.animation.ImageMagickFileWriter.frame_format (matplotlib.animation.ImageMagickFileWriter.input_names)
      • :obj:matplotlib.animation.ImageMagickFileWriter.frame_size (matplotlib.animation.ImageMagickFileWriter.input_names)
      • :obj:matplotlib.animation.ImageMagickWriter.frame_size (matplotlib.animation.ImageMagickWriter.input_names)
      • :obj:matplotlib.animation.ImageMagickWriter.supported_formats (matplotlib.animation.ImageMagickWriter.input_names)
      • :obj:matplotlib.animation.MovieWriter.frame_size (matplotlib.animation.MovieWriter.bin_path)
      • :obj:matplotlib.animation.PillowWriter.frame_size (matplotlib.animation.PillowWriter.finish)

    doc/api (these seem to be part of an inheritance diagram?)

    • doc/api/artist_api.rst:
      • :class:matplotlib.axes._base._AxesBase
      • :class:matplotlib.collections._CollectionWithSizes
      • :class:matplotlib.collections._MeshData
      • :class:matplotlib.image._ImageBase
      • :class:matplotlib.text._AnnotationBase

    doc/docstring of matplotlib.ft2font.PyCapsule.set_text/ <-this method doesn't exist in matplotlib

    • :class:numpy.float64

    can't find in text

    • :class:HashableList[_HT]
    • :class:mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes
    • :class:mpl_toolkits.axes_grid1.parasite_axes.AxesParasite
    • :class:mpl_toolkits.axisartist.axisline_style._FancyAxislineStyle.FilledArrow
    • :class:mpl_toolkits.axisartist.axisline_style._FancyAxislineStyle.SimpleArrow
    • :class:mpl_toolkits.axisartist.axislines._FixedAxisArtistHelperBase
    • :class:mpl_toolkits.axisartist.axislines._FloatingAxisArtistHelperBase
    • :class:mpl_toolkits.axisartist.floating_axes.FloatingAxesHostAxes
    • :class:numpy.uint8
    • :obj:matplotlib.typing._HT
  7. focardozom commented on Nov 5, 2024

    @focardozom
    Contributor

    Hi! I'll work on the artists.py and doc/users/

  8. Astro42 commented on Nov 5, 2024

    @Astro42

    hi! I'll work on the axisartist.rst

  9. added a commit that references this issue on Nov 14, 2024
  10. added a commit that references this issue on Nov 14, 2024
  11. added a commit that references this issue on Nov 14, 2024
  12. timhoffm commented on Feb 1, 2025

    @timhoffm
    MemberAuthor

    Semi-related #29560 fixes _CollectionWithSizes.set_sizes references, which are injected through the "(SubClass:kwdoc)s" placeholder mechanism.

  13. timhoffm commented on Dec 8, 2025

    @timhoffm
    MemberAuthor

    Closing as mostly solved. The remaining entries are mostly references to objects that are not documented via autodoc and therefore cannot be linked.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions