MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_plot_html_code_caption

Function test_plot_html_code_caption

lib/matplotlib/tests/test_sphinxext.py:208–229  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

206
207
208def test_plot_html_code_caption(tmp_path):
209 # Test that :code-caption: option adds caption to code block
210 shutil.copyfile(tinypages / 'conf.py', tmp_path / 'conf.py')
211 shutil.copytree(tinypages / '_static', tmp_path / '_static')
212 doctree_dir = tmp_path / 'doctrees'
213 (tmp_path / 'index.rst').write_text("""
214.. plot::
215 :include-source:
216 :code-caption: Example plotting code
217
218 import matplotlib.pyplot as plt
219 plt.plot([1, 2, 3], [1, 4, 9])
220""")
221 html_dir = tmp_path / '_build' / 'html'
222 build_sphinx_html(tmp_path, doctree_dir, html_dir)
223
224 # Check that the HTML contains the code caption
225 html_content = (html_dir / 'index.html').read_text(encoding='utf-8')
226 assert 'Example plotting code' in html_content
227 # Verify the caption is associated with the code block
228 # (appears in a caption element)
229 assert '<p class="caption"' in html_content or 'caption' in html_content.lower()
230
231
232def test_srcset_version(tmp_path):

Callers

nothing calls this directly

Calls 1

build_sphinx_htmlFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…