Skip to content

Commit

Permalink
Add download links for environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf committed Mar 26, 2024
1 parent 36e98ee commit b70b759
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
12 changes: 12 additions & 0 deletions docs/src/index.rst.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ COSMO Software Cookbook
:end-before: marker-intro-end


All the examples provide an ``environment.yml`` file that you can download and
then use with conda to create a new environment with all the required
dependencies for this example.

.. code-block:: bash

# Pick a name for the environment and replace <environment-name> with it
conda env create --name <environment-name> --file environment.yml

# when you want to use the environment
conda env activate --name <environment-name>

.. toctree::
:caption: Table of Contents
:maxdepth: 1
2 changes: 1 addition & 1 deletion generate-gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, example):
"examples_dirs": os.path.join(HERE, example),
"gallery_dirs": gallery_dir,
"min_reported_time": 60,
"copyfile_regex": r".*\.(sh|xyz|cp2k)",
"copyfile_regex": r".*\.(sh|xyz|cp2k|yml)",
"matplotlib_animations": True,
}

Expand Down
24 changes: 24 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,30 @@ def build_docs(session):

output.write(f" {path}\n")

# TODO: Explain
with open(file) as fd:
content = fd.read()

if "Download Conda environment file" in content:
# do not add the download link twice
pass
else:
lines = content.split("\n")
with open(file, "w") as fd:
for line in lines:
if "sphx-glr-download-jupyter" in line:
# add the new download link before
fd.write(
"""
.. container:: sphx-glr-download
:download:`Download Conda environment file: environment.yml <environment.yml>`
"""
)

fd.write(line)
fd.write("\n")

session.run("sphinx-build", "-W", "-b", "html", "docs/src", "docs/build/html")


Expand Down

0 comments on commit b70b759

Please sign in to comment.