Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7cc1e72

Browse files
authored
Merge pull request #19774 from timhoffm/doc-references
Document how to create sphinx-gallery references to examples
2 parents 222bd9a + 246210a commit 7cc1e72

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

doc/_static/mpl.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ div.note {
439439
border-color: #ccc;
440440
}
441441

442-
div.seealso {
442+
div.seealso, div.admonition-references {
443443
background-color: #EAF1F7;
444444
border-color: #8EADCC;
445445
color: #3F5E7F;

doc/devel/documenting_mpl.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,35 @@ are delimited by a line of ``###`` characters:
859859
860860
In this way text, code, and figures are output in a "notebook" style.
861861

862+
References for sphinx-gallery
863+
-----------------------------
864+
865+
The showcased Matplotlib functions should be listed in an admonition at the
866+
bottom as follows
867+
868+
.. code-block:: python
869+
870+
###############################################################################
871+
#
872+
# .. admonition:: References
873+
#
874+
# The use of the following functions, methods, classes and modules is shown
875+
# in this example:
876+
#
877+
# - `matplotlib.axes.Axes.fill` / `matplotlib.pyplot.fill`
878+
# - `matplotlib.axes.Axes.axis` / `matplotlib.pyplot.axis`
879+
880+
This allows sphinx-gallery to place an entry to the example in the
881+
mini-gallery of the mentioned functions. Whether or not a function is mentioned
882+
here should be decided depending on if a mini-gallery link prominently helps
883+
to illustrate that function; e.g. mention ``matplotlib.pyplot.subplots`` only
884+
in examples that are about laying out subplots, not in every example that uses
885+
it.
886+
887+
Functions that exist in ``pyplot`` as well as in Axes or Figure should mention
888+
both references no matter which one is used in the example code. The ``pyplot``
889+
reference should always be the second to mention; see the example above.
890+
862891
Order of examples in the gallery
863892
--------------------------------
864893

examples/lines_bars_and_markers/fill.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,12 @@ def _koch_snowflake_complex(order):
7676

7777
plt.show()
7878

79-
#############################################################################
79+
###############################################################################
8080
#
81-
# ------------
81+
# .. admonition:: References
8282
#
83-
# References
84-
# """"""""""
83+
# The use of the following functions, methods, classes and modules is shown
84+
# in this example:
8585
#
86-
# The use of the following functions, methods, classes and modules is shown
87-
# in this example:
88-
89-
import matplotlib
90-
matplotlib.axes.Axes.fill
91-
matplotlib.pyplot.fill
92-
matplotlib.axes.Axes.axis
93-
matplotlib.pyplot.axis
86+
# - `matplotlib.axes.Axes.fill` / `matplotlib.pyplot.fill`
87+
# - `matplotlib.axes.Axes.axis` / `matplotlib.pyplot.axis`

0 commit comments

Comments
 (0)