From ff4ebce2b789a2eeb5ff0ee16f098e47ed125300 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 28 Mar 2026 00:00:51 +0100 Subject: [PATCH 1/3] Fix documentation page titles --- .readthedocs.yaml | 2 +- docs/theme_overrides/base.html | 271 +++++++++++++++++++++++++++++++++ justfile | 4 +- mkdocs.yml | 4 + src/_pytask/session.py | 4 +- 5 files changed, 280 insertions(+), 5 deletions(-) create mode 100644 docs/theme_overrides/base.html diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 519e8b04..5c4fc871 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -19,7 +19,7 @@ build: - UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group docs build: html: - - UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run --group docs zensical build + - PYTASK_DOCS_VERSION="$(UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run --group docs python -c 'import importlib.metadata as m; print(m.version("pytask"))')" UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run --group docs zensical build post_build: - mkdir -p "${READTHEDOCS_OUTPUT}/html" - cp -a docs/build/. "${READTHEDOCS_OUTPUT}/html/" diff --git a/docs/theme_overrides/base.html b/docs/theme_overrides/base.html new file mode 100644 index 00000000..10190a6e --- /dev/null +++ b/docs/theme_overrides/base.html @@ -0,0 +1,271 @@ +{#- + This file was automatically generated - do not edit +-#} +{% import "partials/language.html" as lang with context %} + + + + {% block site_meta %} + + + {% if page.meta and page.meta.description %} + + {% elif config.site_description %} + + {% endif %} + {% if page.meta and page.meta.author %} + + {% elif config.site_author %} + + {% endif %} + {% if page.canonical_url %} + + {% endif %} + {% if page.previous_page %} + + {% endif %} + {% if page.next_page %} + + {% endif %} + {% if config.extra.alternate is iterable %} + {% for alt in config.extra.alternate %} + + {% endfor %} + {% endif %} + {% set href = config.theme.favicon | d("assets/images/favicon.png") %} + + + {% endblock %} + {% block htmltitle %} + {% if page.meta and page.meta.title %} + {{ page.meta.title }} - {{ config.site_name }} + {% elif page.title and page.url != "index.html" %} + {{ page.title | striptags }} - {{ config.site_name }} + {% elif config.extra.version %} + {{ config.site_name }} {{ config.extra.version }} + {% else %} + {{ config.site_name }} + {% endif %} + {% endblock %} + {% block styles %} + {% if config.theme.variant == "modern" %} + {% set href = 'assets/stylesheets/modern/main.6f2fbb28.min.css' | url %} + {% else %} + {% set href = 'assets/stylesheets/classic/main.5b14e6eb.min.css' | url %} + {% endif %} + + {% if config.theme.palette %} + {% if config.theme.variant == "modern" %} + {% set href = 'assets/stylesheets/modern/palette.dfe2e883.min.css' | url %} + {% else %} + {% set href = 'assets/stylesheets/classic/palette.7dc9a0ad.min.css' | url %} + {% endif %} + + {% endif %} + {% include "partials/icons.html" %} + {% endblock %} + {% block libs %} + {% for script in config.extra.polyfills %} + {{ script | script_tag }} + {% endfor %} + {% endblock %} + {% block fonts %} + {% if config.theme.font != false %} + {% set text = config.theme.font.text | d("Roboto", true) %} + {% set code = config.theme.font.code | d("Roboto Mono", true) %} + + + + {% endif %} + {% endblock %} + {% for path in config.extra_css %} + + {% endfor %} + {% include "partials/javascripts/base.html" %} + {% block analytics %} + {% include "partials/integrations/analytics.html" %} + {% endblock %} + {% block extrahead %}{% endblock %} + + {% set direction = config.theme.direction or lang.t("direction") %} + {% if config.theme.palette %} + {% set palette = config.theme.palette %} + {% if not palette is mapping %} + {% set palette = palette | first %} + {% endif %} + {% set scheme = palette.scheme | d("default", true) %} + {% set primary = palette.primary | d("indigo", true) %} + {% set accent = palette.accent | d("indigo", true) %} + + {% else %} + + {% endif %} + {% set features = config.theme.features or [] %} + + + +
+ {% if page.toc | first is defined %} + {% set skip = page.toc | first %} + + {{ lang.t("action.skip") }} + + {% else %} + + {{ lang.t("action.skip") }} + + {% endif %} +
+
+ {% if self.announce() %} + + {% endif %} +
+ {% if config.extra.version %} + + {% endif %} + {% block header %} + {% include "partials/header.html" %} + {% endblock %} +
+ {% block hero %}{% endblock %} + {% block tabs %} + {% if "navigation.tabs.sticky" not in features %} + {% if "navigation.tabs" in features %} + {% include "partials/tabs.html" %} + {% endif %} + {% endif %} + {% endblock %} +
+
+ {% block site_nav %} + {% if nav %} + {% if page.meta and page.meta.hide %} + {% set hidden = "hidden" if "navigation" in page.meta.hide %} + {% endif %} + + {% endif %} + {% if "toc.integrate" not in features %} + {% if page.meta and page.meta.hide %} + {% set hidden = "hidden" if "toc" in page.meta.hide %} + {% endif %} + + {% endif %} + {% endblock %} + {% block container %} +
+ {% if "navigation.path" in features %} + {% include "partials/path.html" %} + {% endif %} +
+ {% block content %} + {% include "partials/content.html" %} + {% endblock %} +
+
+ {% endblock %} + {% include "partials/javascripts/content.html" %} +
+ {% if "navigation.top" in features %} + {% include "partials/top.html" %} + {% endif %} +
+ {% block footer %} + {% include "partials/footer.html" %} + {% endblock %} +
+
+
+
+ {% if "navigation.instant.progress" in features %} + {% include "partials/progress.html" %} + {% endif %} + {% if config.extra.consent %} + + {% include "partials/javascripts/consent.html" %} + {% endif %} + {% block config %} + {% set _ = namespace() %} + {% set _.annotate = config.extra.annotate %} + {% set _.tags = config.extra.tags %} + {%- if config.extra.version -%} + {%- set mike = config.plugins.mike -%} + {%- if not mike or mike.config.version_selector -%} + {%- set _.version = config.extra.version -%} + {%- endif -%} + {%- endif -%} + + {% endblock %} + {% block scripts %} + + {% for script in config.extra_javascript %} + {{ script | script_tag }} + {% endfor %} + {% endblock %} + + diff --git a/justfile b/justfile index 93333683..db94a7e6 100644 --- a/justfile +++ b/justfile @@ -24,12 +24,12 @@ check: lint typing test # Build documentation docs: uv run --group plugin-list python scripts/update_plugin_list.py - uv run --group docs zensical build + PYTASK_DOCS_VERSION="$(uv run --group docs python -c 'import importlib.metadata as m; print(m.version("pytask"))')" uv run --group docs zensical build # Serve documentation with auto-reload docs-serve: uv run --group plugin-list python scripts/update_plugin_list.py - uv run --group docs zensical serve -a 127.0.0.1:8000 + PYTASK_DOCS_VERSION="$(uv run --group docs python -c 'import importlib.metadata as m; print(m.version("pytask"))')" uv run --group docs zensical serve -a 127.0.0.1:8000 # Run tests with lowest dependency resolution (like CI) test-lowest: diff --git a/mkdocs.yml b/mkdocs.yml index 7e72d685..61922b81 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -89,6 +89,7 @@ nav: theme: name: zensical + custom_dir: docs/theme_overrides logo: _static/images/pytask.svg favicon: _static/images/pytask.ico features: @@ -170,3 +171,6 @@ extra_css: extra_javascript: - _static/js/termynal.js - _static/js/custom.js + +extra: + version: !ENV [PYTASK_DOCS_VERSION, ""] diff --git a/src/_pytask/session.py b/src/_pytask/session.py index 79f7f06c..1591c541 100644 --- a/src/_pytask/session.py +++ b/src/_pytask/session.py @@ -36,8 +36,8 @@ class Session: Holds all hooks collected by pytask. tasks List of collected tasks. - dag_reports - Reports for resolving dependencies failed. + dag_report + Report for failed dependency resolution. execution_reports Reports for executed tasks. n_tasks_failed From 8209035767230b7eb0caee4ee353569059625cf3 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 28 Mar 2026 00:04:07 +0100 Subject: [PATCH 2/3] Avoid custom YAML tags in docs config --- .readthedocs.yaml | 2 +- justfile | 4 ++-- mkdocs.yml | 2 +- scripts/run_docs.py | 48 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 scripts/run_docs.py diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 5c4fc871..0bfcaa1f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -19,7 +19,7 @@ build: - UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group docs build: html: - - PYTASK_DOCS_VERSION="$(UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run --group docs python -c 'import importlib.metadata as m; print(m.version("pytask"))')" UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run --group docs zensical build + - UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run --group docs python scripts/run_docs.py build post_build: - mkdir -p "${READTHEDOCS_OUTPUT}/html" - cp -a docs/build/. "${READTHEDOCS_OUTPUT}/html/" diff --git a/justfile b/justfile index db94a7e6..7b60277b 100644 --- a/justfile +++ b/justfile @@ -24,12 +24,12 @@ check: lint typing test # Build documentation docs: uv run --group plugin-list python scripts/update_plugin_list.py - PYTASK_DOCS_VERSION="$(uv run --group docs python -c 'import importlib.metadata as m; print(m.version("pytask"))')" uv run --group docs zensical build + uv run --group docs python scripts/run_docs.py build # Serve documentation with auto-reload docs-serve: uv run --group plugin-list python scripts/update_plugin_list.py - PYTASK_DOCS_VERSION="$(uv run --group docs python -c 'import importlib.metadata as m; print(m.version("pytask"))')" uv run --group docs zensical serve -a 127.0.0.1:8000 + uv run --group docs python scripts/run_docs.py serve -a 127.0.0.1:8000 # Run tests with lowest dependency resolution (like CI) test-lowest: diff --git a/mkdocs.yml b/mkdocs.yml index 61922b81..f900948f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -173,4 +173,4 @@ extra_javascript: - _static/js/custom.js extra: - version: !ENV [PYTASK_DOCS_VERSION, ""] + version: "" diff --git a/scripts/run_docs.py b/scripts/run_docs.py new file mode 100644 index 00000000..ab950aea --- /dev/null +++ b/scripts/run_docs.py @@ -0,0 +1,48 @@ +"""Run docs commands with a temporary config containing the current version.""" + +from __future__ import annotations + +import argparse +import importlib.metadata +import subprocess +import tempfile +from pathlib import Path +from typing import Any + +import yaml + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("command", choices=("build", "serve")) + parser.add_argument("args", nargs="*") + parsed = parser.parse_args() + + config_path = Path("mkdocs.yml") + with config_path.open(encoding="utf-8") as fh: + config: dict[str, Any] = yaml.safe_load(fh) + + config.setdefault("extra", {})["version"] = importlib.metadata.version("pytask") + with tempfile.NamedTemporaryFile( + mode="w", encoding="utf-8", suffix=".yml", dir=".", delete=False + ) as fh: + yaml.safe_dump(config, fh, sort_keys=False) + temporary_config_path = Path(fh.name) + + try: + subprocess.run( + [ + "zensical", + parsed.command, + "-f", + str(temporary_config_path), + *parsed.args, + ], + check=True, + ) + finally: + temporary_config_path.unlink(missing_ok=True) + + +if __name__ == "__main__": + main() From 3ce504f1073a2fe45c036983bc5512da943ef26c Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 28 Mar 2026 00:08:05 +0100 Subject: [PATCH 3/3] Fetch tags before docs install --- .readthedocs.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 0bfcaa1f..168ae73e 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -13,6 +13,7 @@ build: - asdf plugin add uv - asdf install uv latest - asdf global uv latest + - git fetch --tags --force create_environment: - uv venv "${READTHEDOCS_VIRTUALENV_PATH}" install: