Skip to content

Document how to write a References section in examples #19232

Closed

Description

@timhoffm

This should go into https://matplotlib.org/devdocs/devel/documenting_mpl.html#writing-examples-and-tutorials

Also:

Activity

  1. self-assigned this
    on Jan 4, 2021
  2. ianhi commented on Jan 4, 2021

    @ianhi
    Contributor

    Consider adding the possibility for linking between examples. Is this technically only a ".. seealso::" directive?

    I think ideally there would be a minigallery defined by the example. Though im not sure sphinx-gallery supports that.

  3. rajpratyush commented on Mar 16, 2021

    @rajpratyush
    Contributor

    @timhoffm does this issue needs work?

  4. timhoffm commented on Mar 16, 2021

    @timhoffm
    MemberAuthor

    Yes it does.

    There are multiple things to do here:

    The trivial thing would be to just write down what we're currently doing. See, e.g. https://matplotlib.org/devdocs/gallery/lines_bars_and_markers/fill.html#references.

    However this is more like a hack with several drawbacks, which is why I'm a bit hesitant to document it as the recommended solution

    • You need to put import matplotlib in
    • You get the Out[] line.
    • You have to mention pyplot as well as Axes to get references in both docs.

    Also, I had the impression that this way of writing code and let sphinx gallery discover it does not always work, but I cannot point at an example right now.

    The good solution would be to write a sphinx directive

    .. gallery-reference::
       matplotlib.axes.Axes.fill
       matplotlib.pyplot.fill
       matplotlib.axes.Axes.axis
       matplotlib.pyplot.axis
    

    That'd possibly be need to be done upstream in sphinx-gallery.

  5. timhoffm commented on Mar 25, 2021

    @timhoffm
    MemberAuthor

    Proposal: Switch to

    ###############################################################################
    #
    # .. admonition:: References
    #
    #    The use of the following functions, methods, classes and modules is shown
    #    in this example:
    #
    #    - `matplotlib.axes.Axes.fill` / `matplotlib.pyplot.fill`
    #    - `matplotlib.axes.Axes.axis` / `matplotlib.pyplot.axis`
    

    Which results in

    grafik

    This works without defining any new directives.

    For comparison: Current look

    grafik

  6. added a commit that references this issue on Mar 25, 2021
    246210a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions