Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ce44314
draft changes to gallery and legacy recipes
bettina-gier May 22, 2025
dc9ce25
add legacy recipe page
bettina-gier May 23, 2025
fb0f11f
fav image in better comment style
bettina-gier May 23, 2025
720e999
docutils parser, html layout, multiple figures per recipe
lukruh May 27, 2025
ed6b995
skip recipes without label in first line
lukruh May 27, 2025
06ccafc
adapt psyplot to new legacy structure
bettina-gier May 28, 2025
d5a93b0
improve look and feel, extra css file
lukruh May 28, 2025
2652de0
Merge branch 'gallery-updates' of github.com:ESMValGroup/ESMValTool i…
lukruh May 28, 2025
946c676
readd psyplot legacy
bettina-gier May 28, 2025
6f59f58
Fixing figure captions
bettina-gier May 28, 2025
641134b
responsive layout
lukruh May 28, 2025
96f5aea
fix errors
bettina-gier May 28, 2025
6c88370
Merge branch 'gallery-updates' of github.com:ESMValGroup/ESMValTool i…
bettina-gier May 28, 2025
d5bd2a5
test 2 gallery plots from 1 recipe file
bettina-gier May 28, 2025
62453cf
hide docutils parsing errors, fine tune plot width
lukruh May 28, 2025
1a9945e
fix duplicate figure name
bettina-gier May 28, 2025
a9c40ee
hide caption numbers in gallery
lukruh Jun 2, 2025
d20a171
Merge branch 'main' into gallery-updates
bettina-gier Jun 2, 2025
953c1da
Merge branch 'main' into gallery-updates
bettina-gier Jun 5, 2025
49723cb
add gallery tags to documentation
bettina-gier Jun 5, 2025
46e5e8f
add gallery tags to documentation
bettina-gier Jun 5, 2025
73e0956
Merge branch 'main' into gallery-updates
bettina-gier Jun 17, 2025
8903f82
Update doc/sphinx/source/generate_gallery.py
lukruh Jun 18, 2025
5e50ca7
adjust mobile breakpoints without sidebar
lukruh Jun 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions doc/sphinx/source/generate_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""Create gallery with all available recipes."""

import os
from pathlib import Path

RECIPE_DIR = "recipes"
OUT_PATH = os.path.abspath("gallery.rst")
Expand Down Expand Up @@ -31,10 +32,14 @@

def _get_figure_index(file_content):
"""Get index of figure in text."""
offset = 0
if ".. gallery=True" in file_content:
offset = file_content.index(".. gallery=True") + 15
file_content = file_content[offset:]
if FIGURE_STR in file_content:
return file_content.index(FIGURE_STR) + len(FIGURE_STR)
return offset + file_content.index(FIGURE_STR) + len(FIGURE_STR)
if IMAGE_STR in file_content:
return file_content.index(IMAGE_STR) + len(IMAGE_STR)
return offset + file_content.index(IMAGE_STR) + len(IMAGE_STR)
raise ValueError("File does not contain image")


Expand Down Expand Up @@ -79,6 +84,17 @@ def _get_next_row(filenames, file_contents):
return (row, refs)


def _find_recipes(root_dir, exclude_dirs):
return [
path.relative_to(root_dir)
for path in Path(root_dir).rglob("recipe_*.rst")
if not any(
path.parents[0].name.startswith(exclude)
for exclude in exclude_dirs
)
]


def main():
"""Generate gallery for recipe plots."""
print(f"Generating gallery at {OUT_PATH}")
Expand All @@ -87,11 +103,8 @@ def main():
refs = ""
filenames = []
file_contents = []
for filename in sorted(os.listdir(RECIPE_DIR)):
if not filename.startswith("recipe_"):
continue
if not filename.endswith(".rst"):
continue
fnames = _find_recipes(RECIPE_DIR, ["legacy", "figures"])
for filename in sorted(fnames):
with open(os.path.join(RECIPE_DIR, filename)) as in_file:
recipe_file = in_file.read()
if FIGURE_STR not in recipe_file and IMAGE_STR not in recipe_file:
Expand Down
8 changes: 3 additions & 5 deletions doc/sphinx/source/recipes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ IPCC
recipe_ipccwg1ar6ch3
recipe_ipccwg1ar5ch9
recipe_collins13ipcc
recipe_examples

Land
^^^^
Expand Down Expand Up @@ -165,11 +164,10 @@ require a legacy version of ESMValTool to run.


.. toctree::
:maxdepth: 1
:maxdepth: 2

legacy_recipe_list

recipe_rainfarm
recipe_schlund20jgr
recipe_spei


Broken recipe list
Expand Down
15 changes: 15 additions & 0 deletions doc/sphinx/source/recipes/legacy_recipe_list.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.. _legacy_recipe_list:

Legacy Recipes
==============

Recipes that have been retired and are included for
documentation purposes only. Typically, these recipes
require a legacy version of ESMValTool to run.

.. toctree::
:maxdepth: 1

legacy/recipe_rainfarm
legacy/recipe_schlund20jgr
legacy/recipe_spei
1 change: 1 addition & 0 deletions doc/sphinx/source/recipes/recipe_gier20bg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Example plots
Barplot of the growth rate, averaged over all years, with standard deviation
of interannual variability.

.. gallery=True
.. _fig_gier20bg_5:
.. figure:: /recipes/figures/gier20bg/fig05.png
:align: center
Expand Down