From 1beb7407f7307e878aa08eb8ee1bbf0b21990449 Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Thu, 29 Feb 2024 16:23:23 -0800 Subject: [PATCH] Remove anchor on benchmarks in breadcrumbs * Remove anchor on benchmarks in breadcrumbs when on the benchmarks page * Add `page_type` to each template run for page type specific logic --- src/coffee/static_site_generator.py | 4 ++++ src/coffee/templates/benchmarks.html | 2 +- src/coffee/templates/macros/breadcrumb.html | 8 ++++++-- tests/templates/macros/test_breadcrumb.py | 13 +++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/coffee/static_site_generator.py b/src/coffee/static_site_generator.py index 611c8f47..4a44444b 100644 --- a/src/coffee/static_site_generator.py +++ b/src/coffee/static_site_generator.py @@ -149,6 +149,7 @@ def _generate_index_page(self, output_dir: pathlib.Path) -> None: self._write_file( output=output_dir / "index.html", template_name="index.html", + page_type="index", ) def _grouped_benchmark_scores(self, benchmark_scores: list[BenchmarkScore]) -> dict: @@ -166,6 +167,7 @@ def _generate_benchmarks_page(self, benchmark_scores: list[BenchmarkScore], outp template_name="benchmarks.html", grouped_benchmark_scores=self._grouped_benchmark_scores(benchmark_scores), show_benchmark_header=True, + page_type="benchmarks", ) def _generate_benchmark_pages(self, benchmark_scores: list[BenchmarkScore], output_dir: pathlib.Path) -> None: @@ -177,6 +179,7 @@ def _generate_benchmark_pages(self, benchmark_scores: list[BenchmarkScore], outp benchmark_definition=benchmark_definition, grouped_benchmark_scores=self._grouped_benchmark_scores(benchmark_scores), stars_description=STARS_DESCRIPTION, + page_type="benchmark", ) def _generate_test_report_pages(self, benchmark_scores: list[BenchmarkScore], output_dir: pathlib.Path) -> None: @@ -187,4 +190,5 @@ def _generate_test_report_pages(self, benchmark_scores: list[BenchmarkScore], ou template_name="test_report.html", benchmark_score=benchmark_score, stars_description=STARS_DESCRIPTION, + page_type="test_report", ) diff --git a/src/coffee/templates/benchmarks.html b/src/coffee/templates/benchmarks.html index 22ac5ea0..1325fd04 100644 --- a/src/coffee/templates/benchmarks.html +++ b/src/coffee/templates/benchmarks.html @@ -6,7 +6,7 @@ {% block title %}Benchmarks{% endblock %} {% block content %} - {{ breadcrumb(benchmark_score, benchmark_definition) }} + {{ breadcrumb(benchmark_score, benchmark_definition, page_type="benchmarks") }}

AI Safety Benchmarks {% include "_provisional.html" %}

diff --git a/src/coffee/templates/macros/breadcrumb.html b/src/coffee/templates/macros/breadcrumb.html index eab6458d..63434618 100644 --- a/src/coffee/templates/macros/breadcrumb.html +++ b/src/coffee/templates/macros/breadcrumb.html @@ -1,8 +1,12 @@ -{% macro breadcrumb(benchmark_score, benchmark_definition) %} +{% macro breadcrumb(benchmark_score, benchmark_definition, page_type) %}