Skip to content

Commit e927d9e

Browse files
authored
allow retrieving doi code from rtd (#269)
* allow retrieving doi code from rtd * update page_footer * rename env var to something allowed
1 parent 7af5789 commit e927d9e

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

Diff for: examples/conf.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,17 @@
7171
"page_sidebar_items": ["postcard", "page-toc", "edit-this-page"],
7272
}
7373
version = os.environ.get("READTHEDOCS_VERSION", "")
74-
version = version if "-" in version else "main"
74+
version = version if "." in version else "main"
75+
doi_code = os.environ.get("DOI_READTHEDOCS", "10.5281/zenodo.5654871")
7576
html_context = {
7677
"github_url": "https://github.com",
7778
"github_user": "pymc-devs",
7879
"github_repo": "pymc-examples",
7980
"github_version": version,
8081
"doc_path": "examples/",
8182
"sandbox_repo": f"pymc-devs/pymc-sandbox/{version}",
82-
"doi_url": "https://doi.org/10.5281/zenodo.5654871",
83-
"doi_code": "10.5281/zenodo.5654871",
83+
"doi_url": f"https://doi.org/{doi_code}",
84+
"doi_code": doi_code,
8485
}
8586

8687

@@ -117,10 +118,24 @@
117118

118119
# MyST config
119120
myst_enable_extensions = ["colon_fence", "deflist", "dollarmath", "amsmath", "substitution"]
121+
citation_code = f"""
122+
```bibtex
123+
@incollection{{citekey,
124+
author = "<notebook authors, see above>"
125+
title = "<notebook title>",
126+
editor = "PyMC Team",
127+
booktitle = "PyMC examples",
128+
doi = "{doi_code}"
129+
}}
130+
```
131+
"""
132+
133+
120134
myst_substitutions = {
121135
"pip_dependencies": "{{ extra_dependencies }}",
122136
"conda_dependencies": "{{ extra_dependencies }}",
123137
"extra_install_notes": "",
138+
"citation_code": citation_code,
124139
}
125140
jupyter_execute_notebooks = "off"
126141

Diff for: examples/page_footer.md

+1-9
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ Also remember to cite the relevant libraries used by your code.
1717

1818
Here is an citation template in bibtex:
1919

20-
```bibtex
21-
@incollection{citekey,
22-
author = "<notebook authors, see above>"
23-
title = "<notebook title>",
24-
editor = "PyMC Team",
25-
booktitle = "PyMC examples",
26-
doi = "10.5281/zenodo.5654871"
27-
}
28-
```
20+
{{ citation_code }}
2921

3022
which once rendered could look like:
3123

0 commit comments

Comments
 (0)