Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug summary
Using the Matplotlib plot directive in Sphinx documentation results in cluttering the output directory with all the produced image files in all generated formats even when they are not needed (plot_html_show_formats = False
). This is especially obvious with thesinglehtml
builder, where all the necessary images must be inside the_images
subdirectory, but in fact, in addition to_images
, the whole directory tree with every image in every format is copied to the output directory, although nothing of it is referenced from the HTML file.
What is more interesting, if another builder is executed first, then its cached images are reused properly — only the necessary files are copied into_images
, without cluttering the output directory with unneeded files and subdirectories.
Code for reproduction
See a minimal working example athttps://github.com/MikhailRyazanov/plot-clutter.
Actual outcome
From step 1 of the example above:
$ tree build/singlehtmlbuild/singlehtml├── _images│ ├── index-1.svg│ ├── other-1.svg│ └── script.svg├── index-1.pdf├── index-1.svg├── index.html├── objects.inv├── _static│ <skipped>└── subdir ├── other-1.pdf ├── other-1.svg ├── script.pdf └── script.svg
Expected outcome
From step 2 of the example above:
build/singlehtml├── _images│ ├── index-1.svg│ ├── other-1.svg│ └── script.svg├── index.html├── objects.inv└── _static <skipped>
Additional information
In practice, this undesired behavior directly affects the downloadable documentation at Read the docs — seeissue #9068 there.
Operating system
No response
Matplotlib Version
3.5.2
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
Linux package manager