Coder Social home page Coder Social logo

Comments (4)

electric-coder avatar electric-coder commented on June 9, 2024

The example you're showing is convoluted to say the least, i.e:

    Keyword Args:
        figure (:py:class:`Figure<plotly.graph_objects.Figure>`):
            The figure that draws contents of the scene.

Here, unless I'm mistaken, you're not "declaring" but inserting an explicit cross-reference in the type field. So Figure is your shortened alias for the link to plotly.graph_objects.Figure. (Needless to say for this to work properly you'll need intersphinx correctly setup for plotly).

The usual way of writing these links would be using the shortened ~ syntax, so you'd write ~plotly.graph_objects.Figure or just .Figure - note that on occasion Sphinx won't be able to resolve all links depending on the context and if the referenced class is affected by one of the bugs listed in #11991

The surest way to get this working, currently, is to explicitly write the return type into the docstring (notice that the one field/link you're complaining about is the one you're not writing out explicitly but instead expect Sphinx to extract&link automatically from the signature, so instead of:

    Return:
        The canvas or figure that is reused for this context.

try writing the type explicitly:

    Returns:
        Figure: Description of return value

or with the path as specified in the docs in the link until you find what works:

    Returns:
        ~.plotly.graph_objects.Figure: Description of return value

from sphinx.

jeertmans avatar jeertmans commented on June 9, 2024

The example you're showing is convoluted to say the least, i.e:

    Keyword Args:
        figure (:py:class:`Figure<plotly.graph_objects.Figure>`):
            The figure that draws contents of the scene.

Here, unless I'm mistaken, you're not "declaring" but inserting an explicit cross-reference in the type field. So Figure is your shortened alias for the link to plotly.graph_objects.Figure. (Needless to say for this to work properly you'll need intersphinx correctly setup for plotly).

The usual way of writing these links would be using the shortened ~ syntax, so you'd write ~plotly.graph_objects.Figure or just .Figure - note that on occasion Sphinx won't be able to resolve all links depending on the context and if the referenced class is affected by one of the bugs listed in #11991

The surest way to get this working, currently, is to explicitly write the return type into the docstring (notice that the one field/link you're complaining about is the one you're not writing out explicitly but instead expect Sphinx to extract&link automatically from the signature, so instead of:

    Return:
        The canvas or figure that is reused for this context.

try writing the type explicitly:

    Returns:
        Figure: Description of return value

or with the path as specified in the docs in the link until you find what works:

    Returns:
        ~.plotly.graph_objects.Figure: Description of return value

I think you misunderstood my problem.

This example you cite works properly (i.e., where I put figure (:py:class:Figure<plotly.graph_objects.Figure>)), because the link is actually clickable.

The issue comes from the return type, that is obtained from the type signature (using "sphinx_autodoc_typehints" extension).

For all return values, I get a clickable link, except from Figure objects from Plotly (in the code, from plotly.graph_objects import Figure.).

from sphinx.

electric-coder avatar electric-coder commented on June 9, 2024

The issue comes from ... (using "sphinx_autodoc_typehints" extension).

Exactly! You should post this issue at their repository since it's their extension that proposes to extract the type from the signature.

I think you misunderstood my problem.

I understood it perfectly fine!

from sphinx.

jeertmans avatar jeertmans commented on June 9, 2024

Ok, will do that then :-)

from sphinx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.