Skip to content

Subclasses of Polygon with numpydoc xref throws error b/c of CapStyle, JoinStyle #19839

@nstarman

Description

@nstarman

Problem

The sphinx links to CapStyle and JoinStyle in v3.4.0 are relative to the file, so a subclass of matplotlib.patches.Patch in a package with numpydoc xref (https://numpydoc.readthedocs.io/en/latest/install.html) turned on cannot link to the objects and errors with.
WARNING: py:obj reference target not found: CapStyle
WARNING: py:obj reference target not found: JoinStyle

https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html#matplotlib.patches.Patch.set_capstyle
https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html#matplotlib.patches.Patch.set_joinstyle

   @docstring.interpd
    def set_capstyle(self, s):
        """
        Set the `.CapStyle`.

        Parameters
        ----------
        s : `.CapStyle` or %(CapStyle)s
        """
        cs = CapStyle(s)
        self._capstyle = cs
        self.stale = True

Edit:

The problem also appears to involve Patches.__init__. I can monkey-patch a fix with

Polygon.__init__.__doc__ = Polygon.__init__.__doc__.replace(
    "`.CapStyle`", "``matplotlib._enums.CapStyle``")
Polygon.__init__.__doc__ = Polygon.__init__.__doc__.replace(
    "`.JoinStyle`", "``matplotlib._enums.JoinStyle``")
Polygon.set_capstyle.__doc__ = Polygon.set_capstyle.__doc__.replace(
    "`.CapStyle`", "``matplotlib._enums.CapStyle``")
Polygon.set_joinstyle.__doc__ = Polygon.set_joinstyle.__doc__.replace(
    "`.JoinStyle`", "``matplotlib._enums.JoinStyle``")

Suggested Improvement

  • This line could be be changed to say
   @docstring.interpd
    def set_capstyle(self, s):
        """
        Set the `~matplotlib._enums.CapStyle`.

        Parameters
        ----------
        s : `~matplotlib._enums.CapStyle` or %(CapStyle)s
        """
        cs = CapStyle(s)
        self._capstyle = cs
        self.stale = True

Matplotlib version

  • Operating system: Big Sur & Ubuntu
  • Matplotlib version 3.4.0
  • Matplotlib documentation version (is listed under the logo): 3.4.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy