diff --git a/doc/_static/zenodo_cache/1004650.svg b/doc/_static/zenodo_cache/1004650.svg
new file mode 100644
index 000000000000..8d70568301a7
--- /dev/null
+++ b/doc/_static/zenodo_cache/1004650.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/1098480.svg b/doc/_static/zenodo_cache/1098480.svg
new file mode 100644
index 000000000000..93eb714978e4
--- /dev/null
+++ b/doc/_static/zenodo_cache/1098480.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/11451.svg b/doc/_static/zenodo_cache/11451.svg
new file mode 100644
index 000000000000..87edde75d917
--- /dev/null
+++ b/doc/_static/zenodo_cache/11451.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/1154287.svg b/doc/_static/zenodo_cache/1154287.svg
new file mode 100644
index 000000000000..e19917debda9
--- /dev/null
+++ b/doc/_static/zenodo_cache/1154287.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/1189358.svg b/doc/_static/zenodo_cache/1189358.svg
new file mode 100644
index 000000000000..2792f3ef69b4
--- /dev/null
+++ b/doc/_static/zenodo_cache/1189358.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/1202050.svg b/doc/_static/zenodo_cache/1202050.svg
new file mode 100644
index 000000000000..45c04ceb3f8f
--- /dev/null
+++ b/doc/_static/zenodo_cache/1202050.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/1202077.svg b/doc/_static/zenodo_cache/1202077.svg
new file mode 100644
index 000000000000..ec73136ad802
--- /dev/null
+++ b/doc/_static/zenodo_cache/1202077.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/12287.svg b/doc/_static/zenodo_cache/12287.svg
new file mode 100644
index 000000000000..799bcddc4fbc
--- /dev/null
+++ b/doc/_static/zenodo_cache/12287.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/12400.svg b/doc/_static/zenodo_cache/12400.svg
new file mode 100644
index 000000000000..82cdfe33b7e2
--- /dev/null
+++ b/doc/_static/zenodo_cache/12400.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/1343133.svg b/doc/_static/zenodo_cache/1343133.svg
new file mode 100644
index 000000000000..32a2f172ea87
--- /dev/null
+++ b/doc/_static/zenodo_cache/1343133.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/1420605.svg b/doc/_static/zenodo_cache/1420605.svg
new file mode 100644
index 000000000000..1655f9f66373
--- /dev/null
+++ b/doc/_static/zenodo_cache/1420605.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/1482098.svg b/doc/_static/zenodo_cache/1482098.svg
new file mode 100644
index 000000000000..ba7adb122829
--- /dev/null
+++ b/doc/_static/zenodo_cache/1482098.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/1482099.svg b/doc/_static/zenodo_cache/1482099.svg
new file mode 100644
index 000000000000..2f9155ddb267
--- /dev/null
+++ b/doc/_static/zenodo_cache/1482099.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/15423.svg b/doc/_static/zenodo_cache/15423.svg
new file mode 100644
index 000000000000..bec3f657cf0c
--- /dev/null
+++ b/doc/_static/zenodo_cache/15423.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/248351.svg b/doc/_static/zenodo_cache/248351.svg
new file mode 100644
index 000000000000..e8e38ac9c1be
--- /dev/null
+++ b/doc/_static/zenodo_cache/248351.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/2577644.svg b/doc/_static/zenodo_cache/2577644.svg
new file mode 100644
index 000000000000..492bbbbc60cf
--- /dev/null
+++ b/doc/_static/zenodo_cache/2577644.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/2669103.svg b/doc/_static/zenodo_cache/2669103.svg
new file mode 100644
index 000000000000..fef871d56e50
--- /dev/null
+++ b/doc/_static/zenodo_cache/2669103.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/2893252.svg b/doc/_static/zenodo_cache/2893252.svg
new file mode 100644
index 000000000000..2e39a0b456b1
--- /dev/null
+++ b/doc/_static/zenodo_cache/2893252.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/3264781.svg b/doc/_static/zenodo_cache/3264781.svg
new file mode 100644
index 000000000000..7924a7dcaa22
--- /dev/null
+++ b/doc/_static/zenodo_cache/3264781.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/32914.svg b/doc/_static/zenodo_cache/32914.svg
new file mode 100644
index 000000000000..0656fd8b062b
--- /dev/null
+++ b/doc/_static/zenodo_cache/32914.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/3563226.svg b/doc/_static/zenodo_cache/3563226.svg
new file mode 100644
index 000000000000..4731dfab137a
--- /dev/null
+++ b/doc/_static/zenodo_cache/3563226.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/3633833.svg b/doc/_static/zenodo_cache/3633833.svg
new file mode 100644
index 000000000000..34a894f0ccc6
--- /dev/null
+++ b/doc/_static/zenodo_cache/3633833.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/3633844.svg b/doc/_static/zenodo_cache/3633844.svg
new file mode 100644
index 000000000000..a3e6b7724224
--- /dev/null
+++ b/doc/_static/zenodo_cache/3633844.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/3695547.svg b/doc/_static/zenodo_cache/3695547.svg
new file mode 100644
index 000000000000..b0bdfe3ba830
--- /dev/null
+++ b/doc/_static/zenodo_cache/3695547.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/3714460.svg b/doc/_static/zenodo_cache/3714460.svg
new file mode 100644
index 000000000000..07e433ea0313
--- /dev/null
+++ b/doc/_static/zenodo_cache/3714460.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/44579.svg b/doc/_static/zenodo_cache/44579.svg
new file mode 100644
index 000000000000..4e5854a3e770
--- /dev/null
+++ b/doc/_static/zenodo_cache/44579.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/56926.svg b/doc/_static/zenodo_cache/56926.svg
new file mode 100644
index 000000000000..5358db519e44
--- /dev/null
+++ b/doc/_static/zenodo_cache/56926.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/570311.svg b/doc/_static/zenodo_cache/570311.svg
new file mode 100644
index 000000000000..289b4f407a9b
--- /dev/null
+++ b/doc/_static/zenodo_cache/570311.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/573577.svg b/doc/_static/zenodo_cache/573577.svg
new file mode 100644
index 000000000000..5aea1629ed35
--- /dev/null
+++ b/doc/_static/zenodo_cache/573577.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/_static/zenodo_cache/61948.svg b/doc/_static/zenodo_cache/61948.svg
new file mode 100644
index 000000000000..8761c190e8f1
--- /dev/null
+++ b/doc/_static/zenodo_cache/61948.svg
@@ -0,0 +1,35 @@
+
\ No newline at end of file
diff --git a/doc/citing.rst b/doc/citing.rst
index b267bf845197..8c366cdfb0c1 100644
--- a/doc/citing.rst
+++ b/doc/citing.rst
@@ -27,93 +27,107 @@ pp. 90-95, 2007 `_.
DOIs
----
+
+The following DOI represents *all* Matplotlib versions. Please select a more
+specific DOI from the list below, referring to the version used for your publication.
+
+ .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.592536.svg
+ :target: https://doi.org/10.5281/zenodo.592536
+
+By version
+~~~~~~~~~~
+.. START OF AUTOGENERATED
+
+
v3.2.1
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3714460.svg
- :target: https://doi.org/10.5281/zenodo.3714460
+ .. image:: _static/zenodo_cache/3714460.svg
+ :target: https://doi.org/10.5281/zenodo.3714460
v3.2.0
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3695547.svg
- :target: https://doi.org/10.5281/zenodo.3695547
+ .. image:: _static/zenodo_cache/3695547.svg
+ :target: https://doi.org/10.5281/zenodo.3695547
v3.1.3
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3633844.svg
- :target: https://doi.org/10.5281/zenodo.3633844
+ .. image:: _static/zenodo_cache/3633844.svg
+ :target: https://doi.org/10.5281/zenodo.3633844
v3.1.2
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3563226.svg
- :target: https://doi.org/10.5281/zenodo.3563226
+ .. image:: _static/zenodo_cache/3563226.svg
+ :target: https://doi.org/10.5281/zenodo.3563226
v3.1.1
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3264781.svg
- :target: https://doi.org/10.5281/zenodo.3264781
+ .. image:: _static/zenodo_cache/3264781.svg
+ :target: https://doi.org/10.5281/zenodo.3264781
v3.1.0
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.2893252.svg
- :target: https://doi.org/10.5281/zenodo.2893252
+ .. image:: _static/zenodo_cache/2893252.svg
+ :target: https://doi.org/10.5281/zenodo.2893252
v3.0.3
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.2577644.svg
- :target: https://doi.org/10.5281/zenodo.2577644
+ .. image:: _static/zenodo_cache/2577644.svg
+ :target: https://doi.org/10.5281/zenodo.2577644
v3.0.2
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1482099.svg
- :target: https://doi.org/10.5281/zenodo.1482099
+ .. image:: _static/zenodo_cache/1482099.svg
+ :target: https://doi.org/10.5281/zenodo.1482099
v3.0.1
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1482098.svg
- :target: https://doi.org/10.5281/zenodo.1482098
+ .. image:: _static/zenodo_cache/1482098.svg
+ :target: https://doi.org/10.5281/zenodo.1482098
v2.2.5
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3633833.svg
- :target: https://doi.org/10.5281/zenodo.3633833
+ .. image:: _static/zenodo_cache/3633833.svg
+ :target: https://doi.org/10.5281/zenodo.3633833
v3.0.0
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1420605.svg
- :target: https://doi.org/10.5281/zenodo.1420605
+ .. image:: _static/zenodo_cache/1420605.svg
+ :target: https://doi.org/10.5281/zenodo.1420605
v2.2.4
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.2669103.svg
- :target: https://doi.org/10.5281/zenodo.2669103
+ .. image:: _static/zenodo_cache/2669103.svg
+ :target: https://doi.org/10.5281/zenodo.2669103
v2.2.3
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1343133.svg
- :target: https://doi.org/10.5281/zenodo.1343133
+ .. image:: _static/zenodo_cache/1343133.svg
+ :target: https://doi.org/10.5281/zenodo.1343133
v2.2.2
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1202077.svg
- :target: https://doi.org/10.5281/zenodo.1202077
+ .. image:: _static/zenodo_cache/1202077.svg
+ :target: https://doi.org/10.5281/zenodo.1202077
v2.2.1
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1202050.svg
- :target: https://doi.org/10.5281/zenodo.1202050
+ .. image:: _static/zenodo_cache/1202050.svg
+ :target: https://doi.org/10.5281/zenodo.1202050
v2.2.0
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1189358.svg
- :target: https://doi.org/10.5281/zenodo.1189358
+ .. image:: _static/zenodo_cache/1189358.svg
+ :target: https://doi.org/10.5281/zenodo.1189358
v2.1.2
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1154287.svg
- :target: https://doi.org/10.5281/zenodo.1154287
+ .. image:: _static/zenodo_cache/1154287.svg
+ :target: https://doi.org/10.5281/zenodo.1154287
v2.1.1
- .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1098480.svg
- :target: https://doi.org/10.5281/zenodo.1098480
+ .. image:: _static/zenodo_cache/1098480.svg
+ :target: https://doi.org/10.5281/zenodo.1098480
v2.1.0
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.1004650.svg
- :target: https://doi.org/10.5281/zenodo.1004650
+ .. image:: _static/zenodo_cache/1004650.svg
+ :target: https://doi.org/10.5281/zenodo.1004650
v2.0.2
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.573577.svg
- :target: https://doi.org/10.5281/zenodo.573577
+ .. image:: _static/zenodo_cache/573577.svg
+ :target: https://doi.org/10.5281/zenodo.573577
v2.0.1
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.570311.svg
- :target: https://doi.org/10.5281/zenodo.570311
+ .. image:: _static/zenodo_cache/570311.svg
+ :target: https://doi.org/10.5281/zenodo.570311
v2.0.0
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.248351.svg
- :target: https://doi.org/10.5281/zenodo.248351
+ .. image:: _static/zenodo_cache/248351.svg
+ :target: https://doi.org/10.5281/zenodo.248351
v1.5.3
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.61948.svg
- :target: https://doi.org/10.5281/zenodo.61948
+ .. image:: _static/zenodo_cache/61948.svg
+ :target: https://doi.org/10.5281/zenodo.61948
v1.5.2
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.56926.svg
- :target: https://doi.org/10.5281/zenodo.56926
+ .. image:: _static/zenodo_cache/56926.svg
+ :target: https://doi.org/10.5281/zenodo.56926
v1.5.1
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.44579.svg
- :target: https://doi.org/10.5281/zenodo.44579
+ .. image:: _static/zenodo_cache/44579.svg
+ :target: https://doi.org/10.5281/zenodo.44579
v1.5.0
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.32914.svg
- :target: https://doi.org/10.5281/zenodo.32914
+ .. image:: _static/zenodo_cache/32914.svg
+ :target: https://doi.org/10.5281/zenodo.32914
v1.4.3
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.15423.svg
- :target: https://doi.org/10.5281/zenodo.15423
+ .. image:: _static/zenodo_cache/15423.svg
+ :target: https://doi.org/10.5281/zenodo.15423
v1.4.2
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.12400.svg
- :target: https://doi.org/10.5281/zenodo.12400
+ .. image:: _static/zenodo_cache/12400.svg
+ :target: https://doi.org/10.5281/zenodo.12400
v1.4.1
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.12287.svg
- :target: https://doi.org/10.5281/zenodo.12287
+ .. image:: _static/zenodo_cache/12287.svg
+ :target: https://doi.org/10.5281/zenodo.12287
v1.4.0
- .. image:: https://zenodo.org/badge/doi/10.5281/zenodo.11451.svg
- :target: https://doi.org/10.5281/zenodo.11451
+ .. image:: _static/zenodo_cache/11451.svg
+ :target: https://doi.org/10.5281/zenodo.11451
+
+.. END OF AUTOGENERATED
diff --git a/doc/devel/release_guide.rst b/doc/devel/release_guide.rst
index aac6fe5438fc..cc03dd80c874 100644
--- a/doc/devel/release_guide.rst
+++ b/doc/devel/release_guide.rst
@@ -219,12 +219,22 @@ Via the `GitHub UI
pushed tag into a release. If this is a pre-release remember to mark
it as such.
-For final releases, also get the DOI from `zenodo `__
-(which will automatically produce one once the tag is pushed), add the DOI link
-to :file:`doc/citing.rst`, commit to the VER-doc branch and push to GitHub ::
+For final releases, also get the DOI from `zenodo
+`__ (which will automatically produce one once
+the tag is pushed). Add the doi post-fix and version to the dictionary in
+:file:`tools/cache_zenodo_svg.py` and run the script.
+
+
+This will download the new svg to the :file:`_static` directory in the
+docs and edit :file:`doc/citing.rst`. Commit the new svg, the change
+to :file:`tools/cache_zenodo_svg.py`, and the changes to
+:file:`doc/citing.rst` to the VER-doc branch and push to GitHub. ::
git checkout v2.0.0-doc
+ $EDITOR tools/cache_zenodo_svg.py
+ python tools/cache_zenodo_svg.py
$EDITOR doc/citing.html
+ git commit -a
git push DANGER v2.0.0-doc:v2.0.0-doc
.. _release_bld_bin:
diff --git a/doc/users/credits.rst b/doc/users/credits.rst
index 093907fb132d..dc41752c6401 100644
--- a/doc/users/credits.rst
+++ b/doc/users/credits.rst
@@ -11,6 +11,7 @@ Matplotlib was written by John D. Hunter, with contributions from an
ever-increasing number of users and developers. The current lead
developer is Thomas A. Caswell; they are assisted by many `active
`_ developers.
+Please also see our instructions on :doc:`/citing`.
The following is a list of contributors extracted from the
git revision control history of the project:
diff --git a/doc/users/generate_credits.py b/doc/users/generate_credits.py
index edda54eddef2..87c9584eabc2 100755
--- a/doc/users/generate_credits.py
+++ b/doc/users/generate_credits.py
@@ -23,6 +23,7 @@
and Thomas A. Caswell; they are assisted by many
`active
`_ developers.
+Please also see our instructions on :doc:`/citing`.
The following is a list of contributors extracted from the
git revision control history of the project:
diff --git a/doc/users/index.rst b/doc/users/index.rst
index 7afb7be62096..852ca4321e90 100644
--- a/doc/users/index.rst
+++ b/doc/users/index.rst
@@ -20,4 +20,5 @@ User's Guide
github_stats.rst
whats_new_old.rst
license.rst
+ ../citing.rst
credits.rst
diff --git a/tools/cache_zenodo_svg.py b/tools/cache_zenodo_svg.py
new file mode 100644
index 000000000000..6c8760b2635b
--- /dev/null
+++ b/tools/cache_zenodo_svg.py
@@ -0,0 +1,131 @@
+import urllib.request
+from io import BytesIO
+import os
+from pathlib import Path
+
+
+def download_or_cache(url, version):
+ """
+ Get bytes from the given url or local cache.
+
+ Parameters
+ ----------
+ url : str
+ The url to download.
+ sha : str
+ The sha256 of the file.
+
+ Returns
+ -------
+ BytesIO
+ The file loaded into memory.
+ """
+ cache_dir = _get_xdg_cache_dir()
+
+ if cache_dir is not None: # Try to read from cache.
+ try:
+ data = (cache_dir / version).read_bytes()
+ except IOError:
+ pass
+ else:
+ return BytesIO(data)
+
+ with urllib.request.urlopen(
+ urllib.request.Request(url, headers={"User-Agent": ""})
+ ) as req:
+ data = req.read()
+
+ if cache_dir is not None: # Try to cache the downloaded file.
+ try:
+ cache_dir.mkdir(parents=True, exist_ok=True)
+ with open(cache_dir / version, "xb") as fout:
+ fout.write(data)
+ except IOError:
+ pass
+
+ return BytesIO(data)
+
+
+def _get_xdg_cache_dir():
+ """
+ Return the XDG cache directory.
+
+ See https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
+ """
+ cache_dir = os.environ.get("XDG_CACHE_HOME")
+ if not cache_dir:
+ cache_dir = os.path.expanduser("~/.cache")
+ if cache_dir.startswith("~/"): # Expansion failed.
+ return None
+ return Path(cache_dir, "matplotlib")
+
+
+if __name__ == "__main__":
+ data = {
+ "v3.2.1": "3714460",
+ "v3.2.0": "3695547",
+ "v3.1.3": "3633844",
+ "v3.1.2": "3563226",
+ "v3.1.1": "3264781",
+ "v3.1.0": "2893252",
+ "v3.0.3": "2577644",
+ "v3.0.2": "1482099",
+ "v3.0.1": "1482098",
+ "v2.2.5": "3633833",
+ "v3.0.0": "1420605",
+ "v2.2.4": "2669103",
+ "v2.2.3": "1343133",
+ "v2.2.2": "1202077",
+ "v2.2.1": "1202050",
+ "v2.2.0": "1189358",
+ "v2.1.2": "1154287",
+ "v2.1.1": "1098480",
+ "v2.1.0": "1004650",
+ "v2.0.2": "573577",
+ "v2.0.1": "570311",
+ "v2.0.0": "248351",
+ "v1.5.3": "61948",
+ "v1.5.2": "56926",
+ "v1.5.1": "44579",
+ "v1.5.0": "32914",
+ "v1.4.3": "15423",
+ "v1.4.2": "12400",
+ "v1.4.1": "12287",
+ "v1.4.0": "11451",
+ }
+ doc_dir = Path(__file__).parent.parent.absolute() / "doc"
+ target_dir = doc_dir / "_static/zenodo_cache"
+ citing = doc_dir / "citing.rst"
+ target_dir.mkdir(exist_ok=True, parents=True)
+ header = []
+ footer = []
+ with open(citing, "r") as fin:
+ target = header
+ for ln in fin:
+ if target is not None:
+ target.append(ln.rstrip())
+ if ln.strip() == ".. START OF AUTOGENERATED":
+ target.extend(["", ""])
+ target = None
+ if ln.strip() == ".. END OF AUTOGENERATED":
+ target = footer
+ target.append(ln)
+
+ with open(citing, "w") as fout:
+ fout.write("\n".join(header))
+ for version, doi in data.items():
+ svg_path = target_dir / f"{doi}.svg"
+ if not svg_path.exists():
+ url = f"https://zenodo.org/badge/doi/10.5281/zenodo.{doi}.svg"
+ payload = download_or_cache(url, f"{doi}.svg")
+ with open(svg_path, "xb") as svgout:
+ svgout.write(payload.read())
+ fout.write(
+ f"""
+{version}
+ .. image:: _static/zenodo_cache/{doi}.svg
+ :target: https://doi.org/10.5281/zenodo.{doi}"""
+ )
+ fout.write("\n\n")
+ fout.write("\n".join(footer))
+ fout.write('\n')