From e927d9e2629bb9f8e645e54e1f31ad4e3122e8e5 Mon Sep 17 00:00:00 2001 From: Oriol Abril-Pla Date: Mon, 10 Jan 2022 02:42:10 +0200 Subject: [PATCH] allow retrieving doi code from rtd (#269) * allow retrieving doi code from rtd * update page_footer * rename env var to something allowed --- examples/conf.py | 21 ++++++++++++++++++--- examples/page_footer.md | 10 +--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/examples/conf.py b/examples/conf.py index 4c7bb47a9..50d39ead6 100644 --- a/examples/conf.py +++ b/examples/conf.py @@ -71,7 +71,8 @@ "page_sidebar_items": ["postcard", "page-toc", "edit-this-page"], } version = os.environ.get("READTHEDOCS_VERSION", "") -version = version if "-" in version else "main" +version = version if "." in version else "main" +doi_code = os.environ.get("DOI_READTHEDOCS", "10.5281/zenodo.5654871") html_context = { "github_url": "https://github.com", "github_user": "pymc-devs", @@ -79,8 +80,8 @@ "github_version": version, "doc_path": "examples/", "sandbox_repo": f"pymc-devs/pymc-sandbox/{version}", - "doi_url": "https://doi.org/10.5281/zenodo.5654871", - "doi_code": "10.5281/zenodo.5654871", + "doi_url": f"https://doi.org/{doi_code}", + "doi_code": doi_code, } @@ -117,10 +118,24 @@ # MyST config myst_enable_extensions = ["colon_fence", "deflist", "dollarmath", "amsmath", "substitution"] +citation_code = f""" +```bibtex +@incollection{{citekey, + author = "" + title = "", + editor = "PyMC Team", + booktitle = "PyMC examples", + doi = "{doi_code}" +}} +``` +""" + + myst_substitutions = { "pip_dependencies": "{{ extra_dependencies }}", "conda_dependencies": "{{ extra_dependencies }}", "extra_install_notes": "", + "citation_code": citation_code, } jupyter_execute_notebooks = "off" diff --git a/examples/page_footer.md b/examples/page_footer.md index 8cfa05b89..3b0dc0347 100644 --- a/examples/page_footer.md +++ b/examples/page_footer.md @@ -17,15 +17,7 @@ Also remember to cite the relevant libraries used by your code. Here is an citation template in bibtex: -```bibtex -@incollection{citekey, - author = "" - title = "", - editor = "PyMC Team", - booktitle = "PyMC examples", - doi = "10.5281/zenodo.5654871" -} -``` +{{ citation_code }} which once rendered could look like: