Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6146e9a

Browse files
tacaswellQuLogic
authored andcommitted
MNT: have the helper script edit citing.rst
1 parent 32b020a commit 6146e9a

File tree

3 files changed

+40
-16
lines changed

3 files changed

+40
-16
lines changed

doc/citing.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ specific DOI from the link, referring to the version used for your publication.
3636

3737
By version
3838
~~~~~~~~~~
39+
.. START OF AUTOGENERATED
40+
3941
4042
v3.2.1
4143
.. image:: _static/3714460.svg
@@ -127,3 +129,5 @@ v1.4.1
127129
v1.4.0
128130
.. image:: _static/11451.svg
129131
:target: https://doi.org/10.5281/zenodo.11451
132+
133+
.. END OF AUTOGENERATED

doc/devel/release_guide.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,12 @@ it as such.
222222
For final releases, also get the DOI from `zenodo
223223
<https://zenodo.org/>`__ (which will automatically produce one once
224224
the tag is pushed). Add the doi post-fix and version to the dictionary in
225-
:file:`tools/cache_zenodo_svg.py` and run the script (requires ``httpx``).
225+
:file:`tools/cache_zenodo_svg.py` and run the script.
226226

227227

228-
This will download the new svg to the :file:`_static` directory
229-
in the docs and print the restructured text that needs to be put into
230-
:file:`doc/citing.rst`. Commit the new svg, the change to
231-
:file:`tools/cache_zenodo_svg.py`, and the changes to
228+
This will download the new svg to the :file:`_static` directory in the
229+
docs and edit :file:`doc/citing.rst`. Commit the new svg, the change
230+
to :file:`tools/cache_zenodo_svg.py`, and the changes to
232231
:file:`doc/citing.rst` to the VER-doc branch and push to GitHub. ::
233232

234233
git checkout v2.0.0-doc

tools/cache_zenodo_svg.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,38 @@ def _get_xdg_cache_dir():
9393
"v1.4.1": "12287",
9494
"v1.4.0": "11451",
9595
}
96-
target_dir = Path(__file__).parent.parent.absolute() / "doc" / "_static"
96+
doc_dir = Path(__file__).parent.parent.absolute() / "doc"
97+
target_dir = doc_dir / "_static"
98+
citing = doc_dir / "citing.rst"
9799

98-
for version, doi in data.items():
99-
svg_path = target_dir / f"{doi}.svg"
100-
if not svg_path.exists():
101-
url = f"https://zenodo.org/badge/doi/10.5281/zenodo.{doi}.svg"
102-
payload = download_or_cache(url, f"{doi}.svg")
103-
with open(svg_path, "xb") as fout:
104-
fout.write(payload.read())
105-
print(
106-
f"""{version}
100+
header = []
101+
footer = []
102+
with open(citing, "r") as fin:
103+
target = header
104+
for ln in fin:
105+
if target is not None:
106+
target.append(ln.rstrip())
107+
if ln.strip() == ".. START OF AUTOGENERATED":
108+
target.extend(["", ""])
109+
target = None
110+
if ln.strip() == ".. END OF AUTOGENERATED":
111+
target = footer
112+
target.append(ln)
113+
114+
with open(citing, "w") as fout:
115+
fout.write("\n".join(header))
116+
for version, doi in data.items():
117+
svg_path = target_dir / f"{doi}.svg"
118+
if not svg_path.exists():
119+
url = f"https://zenodo.org/badge/doi/10.5281/zenodo.{doi}.svg"
120+
payload = download_or_cache(url, f"{doi}.svg")
121+
with open(svg_path, "xb") as fout:
122+
fout.write(payload.read())
123+
fout.write(
124+
f"""
125+
{version}
107126
.. image:: _static/{doi}.svg
108127
:target: https://doi.org/10.5281/zenodo.{doi}"""
109-
)
128+
)
129+
fout.write("\n\n")
130+
fout.write("\n".join(footer))

0 commit comments

Comments
 (0)