Skip to content

Commit 48b53ce

Browse files
melissawmstory645esibinga
committed
DOC: Add tags infrastructure for gallery examples
Adds sphinx-tags as a dependency and some basic configuration to display tags with color, using sphinx-design. Co-authored-by: hannah <[email protected]> Co-authored-by: esibinga <[email protected]>
1 parent e394940 commit 48b53ce

File tree

9 files changed

+33
-0
lines changed

9 files changed

+33
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ galleries/examples/*/*.svgz
8282
result_images
8383
doc/_static/constrained_layout*.png
8484
doc/.mpl_skip_subdirs.yaml
85+
doc/_tags
8586

8687
# Nose/Pytest generated files #
8788
###############################

doc/_static/mpl.css

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
--pst-color-link-hover: var(--pst-color-secondary);
44
--sd-color-primary: var(--pst-color-primary);
55
--sd-color-primary-text: var(--pst-color-text-base);
6+
--sd-color-secondary: #ee9040;
7+
--sd-color-success: #28a745;
8+
--sd-color-dark: #323232;
9+
--sd-color-danger: #dc3545;
10+
--sd-color-light: #c9c9c9;
611
}
712

813
.simple li>p {

doc/conf.py

+13
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def _parse_skip_subdirs_file():
118118
'sphinxext.redirect_from',
119119
'sphinx_copybutton',
120120
'sphinx_design',
121+
'sphinx_tags',
121122
]
122123

123124
exclude_patterns = [
@@ -282,6 +283,18 @@ def gallery_image_warning_filter(record):
282283
logger = logging.getLogger('sphinx')
283284
logger.addFilter(gallery_image_warning_filter)
284285

286+
# Sphinx tags configuration
287+
tags_create_tags = True
288+
tags_page_title = "All tags"
289+
tags_create_badges = True
290+
tags_badge_colors = {
291+
"animation": "primary",
292+
"component:*": "secondary",
293+
"event-handling": "success",
294+
"interactivity:*": "dark",
295+
"plot-type:*": "danger",
296+
"*": "light" # default value
297+
}
285298

286299
mathmpl_fontsize = 11.0
287300
mathmpl_srcset = ['2x']

environment.yml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dependencies:
3939
- sphinx-copybutton
4040
- sphinx-gallery>=0.12
4141
- sphinx-design
42+
- sphinx-tags
4243
- pip
4344
- pip:
4445
- mpl-sphinx-theme

galleries/examples/README.txt

+4
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ and source code.
1414
For longer tutorials, see our :ref:`tutorials page <tutorials>`.
1515
You can also find :ref:`external resources <resources-index>` and
1616
a :ref:`FAQ <faq-index>` in our :ref:`user guide <users-guide-index>`.
17+
18+
19+
.. note::
20+
You can also browse the example gallery by :ref:`tags <tagoverview>`.

galleries/examples/animation/animated_histogram.py

+3
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ def animate(frame_number):
5555
ani = animation.FuncAnimation(fig, prepare_animation(bar_container), 50,
5656
repeat=False, blit=True)
5757
plt.show()
58+
59+
# %%
60+
# .. tags:: plot-type:histogram, animation

galleries/examples/animation/multiple_axes.py

+2
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,5 @@ def animate(i):
8080
#
8181
# - `matplotlib.patches.ConnectionPatch`
8282
# - `matplotlib.animation.FuncAnimation`
83+
#
84+
# .. tags:: component:axes, animation

galleries/examples/event_handling/resample.py

+3
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,6 @@ def update(self, ax):
7575
ax.callbacks.connect('xlim_changed', d.update)
7676
ax.set_xlim(16, 365)
7777
plt.show()
78+
79+
# %%
80+
# .. tags:: interactivity:zoom, event-handling

requirements/doc/doc-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ sphinxcontrib-svg2pdfconverter>=1.1.0
2121
sphinx-gallery>=0.12.0
2222
sphinx-copybutton
2323
sphinx-design
24+
sphinx-tags

0 commit comments

Comments
 (0)