From 1eddf86331e46db564749a4a7fde260ebae6c7b5 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Wed, 4 Oct 2023 08:18:09 -0400 Subject: [PATCH] docs: use html for notebook download links (#1976) --- .docs/conf.py | 44 ++++++++++++++++++++++++++++++++------------ .docs/prolog.rst | 10 ---------- 2 files changed, 32 insertions(+), 22 deletions(-) delete mode 100644 .docs/prolog.rst diff --git a/.docs/conf.py b/.docs/conf.py index dd3b87f92..0113ff54c 100644 --- a/.docs/conf.py +++ b/.docs/conf.py @@ -23,15 +23,8 @@ # -- determine if running on readthedocs ------------------------------------ on_rtd = os.environ.get("READTHEDOCS") == "True" -# -- determine if this version is a release candidate -with open("../README.md") as f: - lines = f.readlines() -rc_text = "" -for line in lines: - if line.startswith("### Version"): - if "release candidate" in line: - rc_text = "release candidate" - break +# -- determine if this is a development or release version ------------------ +branch_or_version = __version__ if "dev" not in __version__ else "develop" # -- get authors with open("../CITATION.cff") as f: @@ -45,8 +38,6 @@ for line in lines: if line.startswith("**Documentation for version"): line = f"**Documentation for version {__version__}" - if rc_text != "": - line += f" --- {rc_text}" line += "**\n" f.write(line) @@ -272,6 +263,35 @@ nbsphinx_prolog = ( r""" {% set docname = env.doc2path(env.docname, base=None) %} + +.. raw:: html + +
+ This page was generated from + {{ env.docname.split('/')|last|e + '.py' }}. + It's also available as a notebook. + +
""" - + Path("prolog.rst").read_text() ) + +# Import Matplotlib to avoid this message in notebooks: +# "Matplotlib is building the font cache; this may take a moment." +import matplotlib.pyplot diff --git a/.docs/prolog.rst b/.docs/prolog.rst deleted file mode 100644 index 3efa2ef7d..000000000 --- a/.docs/prolog.rst +++ /dev/null @@ -1,10 +0,0 @@ -.. only:: html - - .. role:: raw-html(raw) - :format: html - - .. note:: - - | This page was generated from `{{ docname[:-6] }}`__. Download as :download:`a Jupyter notebook (.ipynb) <../{{ docname }}>` or :download:`Python script (.py) <../{{ docname[:-6] }}.py>`. - - __ https://github.com/modflowpy/flopy/blob/develop/.docs/{{ docname[:-6] }}.py \ No newline at end of file