From f683ad72d4dd8237081973c2a7c6dd4a569c4a77 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sun, 22 May 2022 00:53:29 +0200 Subject: [PATCH] Ensure updated monkey-patching of sphinx-gallery EXAMPLE_HEADER We have copied the EXAMPLE_HEADER and patched it (#22405). This ensures we are notified if sphinx-gallery changes the EXAMPLE_HEADER. See the test docstring for more details. --- lib/matplotlib/tests/test_doc.py | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/matplotlib/tests/test_doc.py diff --git a/lib/matplotlib/tests/test_doc.py b/lib/matplotlib/tests/test_doc.py new file mode 100644 index 000000000000..8a4df35179bc --- /dev/null +++ b/lib/matplotlib/tests/test_doc.py @@ -0,0 +1,34 @@ +import pytest + + +def test_sphinx_gallery_example_header(): + """ + We have copied EXAMPLE_HEADER and modified it to include meta keywords. + This test monitors that the version we have copied is still the same as + the EXAMPLE_HEADER in sphinx-gallery. If sphinx-gallery changes its + EXAMPLE_HEADER, this test will start to fail. In that case, please update + the monkey-patching of EXAMPLE_HEADER in conf.py. + """ + gen_rst = pytest.importorskip('sphinx_gallery.gen_rst') + + EXAMPLE_HEADER = """ +.. DO NOT EDIT. +.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. +.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: +.. "{0}" +.. LINE NUMBERS ARE GIVEN BELOW. + +.. only:: html + + .. note:: + :class: sphx-glr-download-link-note + + Click :ref:`here ` + to download the full example code{2} + +.. rst-class:: sphx-glr-example-title + +.. _sphx_glr_{1}: + +""" + assert gen_rst.EXAMPLE_HEADER == EXAMPLE_HEADER