Skip to content

[Doc]: Spurious references from API to gallery examples #22036

Open

Description

@StefRe

Documentation Link

https://matplotlib.org/devdocs/api/_as_gen/matplotlib.axes.Axes.set_axis_off.html

Problem

My understanding is that the API reference should only include links to gallery examples if the given API function is listed in the .. admonition:: References block of the example, see documentation and e.g. #19233 (comment). However, links seem to be generated for any function in the example, see for instance set_axis_off where set_axis_off is included in the references list in only 2 of the 9 linked gallery examples. plot links to even 176 examples (there's hardly any example that's not linked to from there).

(this is kind of the reverse of #19715)

Suggested improvement

Add links only to those gallery examples that explicitly list the given function in their references block.

Matplotlib Version

3.6.0.dev888+g25a54a4fef.d20211129

Activity

  1. jklymak commented on Dec 22, 2021

    @jklymak
    Member

    No that is not correct. The admonition was added because many references were not being made, but the automatic references are indeed meant to show up this way.

  2. StefRe commented on Dec 22, 2021

    @StefRe
    ContributorAuthor

    @jklymak

    The admonition was added because many references were not being made

    so that means that I should list in the admonition only those functions that are not automatically turned into a link by sphinx?


    the automatic references are indeed meant to show up this way

    is this really useful?


    If this is indeed the intended behavior then I think the documentation should be amended, shouldn't it?

    Whether or not a function is mentioned here should be decided depending on if a mini-gallery link prominently helps to illustrate that function; e.g. mention matplotlib.pyplot.subplots only in examples that are about laying out subplots, not in every example that uses it.

  3. jklymak commented on Dec 22, 2021

    @jklymak
    Member

    I don't think it makes any practical difference to people adding admonitions. They can list things here, or not, based on that advice, some of which will be duplicate with the automatic cross linking. I suppose you could make the case that we get rid of the automatic cross links, but I'm personally of the opinion more cross linking is good.

  4. StefRe commented on Dec 22, 2021

    @StefRe
    ContributorAuthor

    OK, so we can close this issue or should we wait for @timhoffm (who wrote the above mentioned paragraph in #19232) to weigh in?

  5. added this to the v3.6.0 milestone on Dec 22, 2021
  6. timhoffm commented on Dec 23, 2021

    @timhoffm
    Member

    What is linked and what not is determined by sphinx-gallery (see https://sphinx-gallery.github.io/stable/configuration.html#references-to-examples):

    When documenting a given function/class, Sphinx-Gallery enables you to link to any examples that either:

    1. Use the function/instantiate the class in the code.
    2. Refer to that function/class using sphinx markup :func:/:class: in a documentation block.

    (1) depends on how good the parser can infer types. Sometimes it works sometimes it doesn’t.
    If it does we get links to the example.

    The references admonition is intended to list the most relevant API. This has two purposes:

    A) It‘s an explicit summary of API worth mentioning in the example.
    B) It makes sure that that API is linked to the example via (2) from above.

    Whether one adds something to the admonition should mainly be determined by A) and not depend on whether the autodetection (1) works or not.

    One could argue that the flaky auto-detection from doe (1) is undesirable. Suppressing it would need a respective option in sphinx-gallery. I‘m not aware that it exists. If it did, I‘d have a slight favor of suppressing the autogenerated links.

  7. timhoffm commented on Dec 23, 2021

    @timhoffm
    Member

    So to summarize: I think the request here is reasonable, but would need action primarily in sphinx-gallery.

  8. modified the milestones: v3.6.0, v3.7.0 on Jul 8, 2022
  9. modified the milestones: v3.7.0, v3.7.1 on Feb 14, 2023
  10. modified the milestones: v3.7.1, v3.7-doc on Mar 4, 2023
  11. modified the milestones: v3.7-doc, v3.8-doc on Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions