Skip to content

Commit

Permalink
Let doc generation append regular image when available
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSosic committed Feb 13, 2025
1 parent 9281087 commit 3f7a7c6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/scripts/build_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ def build_examples(destination_directory: Path, dummy: bool, remove_dir: bool):
# lines = [line for line in lines if "![svg]" not in line]
# We check whether pre-built light and dark plots exist. If so, we append
# corresponding lines to our markdown file for including them.
# If not, we check if a single plot version exists and append it
# regardless of light/dark mode.
light_figure = Path(sub_directory / (file_name + "_light.svg"))
dark_figure = Path(sub_directory / (file_name + "_dark.svg"))
figure = Path(sub_directory / (file_name + ".svg"))
if light_figure.is_file() and dark_figure.is_file():
lines.append(f"```{{image}} {file_name}_light.svg\n")
lines.append(":align: center\n")
Expand All @@ -182,6 +185,10 @@ def build_examples(destination_directory: Path, dummy: bool, remove_dir: bool):
lines.append(":align: center\n")
lines.append(":class: only-dark\n")
lines.append("```\n")
elif figure.is_file():
lines.append(f"```{{image}} {file_name}.svg\n")
lines.append(":align: center\n")
lines.append("```\n")

# Rewrite the file
with open(markdown_path, "w", encoding="UTF-8") as markdown_file:
Expand Down

0 comments on commit 3f7a7c6

Please sign in to comment.