From 21c80a75dce48721ca1667b955a8be99b92d13fe Mon Sep 17 00:00:00 2001 From: quqingyu <12210819@mail.sustech.edu.cn> Date: Mon, 3 Aug 2026 11:34:51 +0800 Subject: [PATCH 1/2] docs: add online template links --- docs/_static/comfyresearch.css | 35 +++++++++++++++++ docs/_templates/template-link.html | 11 ++++++ docs/conf.py | 14 ++++++- .../reproductions/Neural_Mechanics.md | 3 +- .../diffusion-reproducibility.md | 1 + .../reproductions/edge-of-stability-cpu.md | 1 + .../reproductions/edge-of-stability-eos.md | 1 + .../in-context-associative-recall.md | 1 + .../information-bottleneck-figure3.md | 1 + .../jastrzebski-fig1-cyclic-cbs-vs-clr.md | 1 + .../reproductions/keskar-fig2-3-sb-lb.md | 1 + .../reproductions/lazy-vs-rich-regime.md | 1 + .../reproductions/linear-mode-connectivity.md | 1 + .../random-label-memorization-figure1a.md | 1 + .../reproductions/rank-collapse-figure5.md | 1 + .../rank-collapse-tinyshakespeare.md | 1 + .../saad_solla_plateau_reproduction.md | 3 +- .../reproductions/spectral-bias-figure1a.md | 1 + .../staggered-singular-value-dynamics.md | 1 + docs/en/get-started/first-graph.md | 1 + tests/test_docs_build_contracts.py | 6 +++ tests/test_docs_source_contracts.py | 38 ++++++++++++++++++- tests/test_docs_visual_contracts.py | 11 ++++++ 23 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 docs/_templates/template-link.html diff --git a/docs/_static/comfyresearch.css b/docs/_static/comfyresearch.css index 14d033b..b950694 100644 --- a/docs/_static/comfyresearch.css +++ b/docs/_static/comfyresearch.css @@ -764,6 +764,41 @@ body[data-page="examples/index"] .bd-header-article .bd-breadcrumbs { color: var(--cr-accent-dark); } +.cr-template-link { + display: inline-flex; + width: fit-content; + margin: 10px 0 0; + padding: 7px 14px; + align-items: center; + border: 1px solid var(--cr-accent); + border-radius: 999px; + background: var(--cr-accent); + color: var(--cr-on-accent); + font-size: 0.86rem; + font-weight: 700; + line-height: 1.2; + text-decoration: none; + transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease; +} + +.cr-template-link:hover { + border-color: var(--cr-accent-dark); + background: var(--cr-accent-dark); + color: var(--cr-on-accent); + text-decoration: none; + transform: translateY(-1px); +} + +.cr-template-link:focus-visible { + color: var(--cr-on-accent); +} + +@media (prefers-reduced-motion: reduce) { + .cr-template-link { + transition: none; + } +} + .cr-page-identity { display: flex; margin-left: auto; diff --git a/docs/_templates/template-link.html b/docs/_templates/template-link.html new file mode 100644 index 0000000..82b59ea --- /dev/null +++ b/docs/_templates/template-link.html @@ -0,0 +1,11 @@ +{% if template_id %} + + {{ cr_ui.open_template }} + +{% endif %} diff --git a/docs/conf.py b/docs/conf.py index 1864f99..3067037 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -42,6 +42,7 @@ "doc_type_reproduction": "Reproduction", "doc_status_stable_core": "Stable core", "doc_status_phenomenon": "Phenomenon reproduction", + "open_template": "Open template ↗", "github_repo_aria_label": "Open the GitHub repository", "version_switch_aria_label": "Switch documentation version", "language_switch_label": "中文", @@ -68,6 +69,7 @@ "doc_type_reproduction": "复现", "doc_status_stable_core": "稳定核心", "doc_status_phenomenon": "现象复现", + "open_template": "在线打开模板 ↗", "github_repo_aria_label": "打开 GitHub 仓库", "version_switch_aria_label": "切换文档版本", "language_switch_label": "EN", @@ -93,7 +95,11 @@ "theme-switcher", ], "navbar_persistent": [], - "article_header_start": ["breadcrumbs", "page-status.html"], + "article_header_start": [ + "breadcrumbs", + "page-status.html", + "template-link.html", + ], "article_footer_items": [], "secondary_sidebar_items": ["page-toc"], "show_prev_next": True, @@ -149,6 +155,11 @@ def add_page_context(app, pagename, templatename, context, doctree): } ) + page_meta = context.get("meta") or {} + template_id = page_meta.get("template_id") + if not template_id and doctree is not None: + template_id = doctree.get("template_id") + context.update( { "cr_ui": UI_TEXT[locale], @@ -157,6 +168,7 @@ def add_page_context(app, pagename, templatename, context, doctree): "alternate_language_label": UI_TEXT[locale]["language_switch_label"], "current_docs_version": CURRENT_DOCS_VERSION, "documentation_versions": version_options, + "template_id": template_id, } ) diff --git a/docs/en/examples/reproductions/Neural_Mechanics.md b/docs/en/examples/reproductions/Neural_Mechanics.md index 54d5887..858a816 100644 --- a/docs/en/examples/reproductions/Neural_Mechanics.md +++ b/docs/en/examples/reproductions/Neural_Mechanics.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: b38ae9dd-735b-46c4-973f-a850a2a55544 --- :::{div} cr-eyebrow @@ -57,7 +58,7 @@ Ganguli, Yamins & Tanaka, ICLR 2021 (arXiv:2012.04728). **Template:** `Symmetry & Broken Conservation Laws (GPU)` -**Template ID:** `symmetry-broken-conservation-laws` +**Template ID:** `b38ae9dd-735b-46c4-973f-a850a2a55544` ## Reproduction Goal diff --git a/docs/en/examples/reproductions/diffusion-reproducibility.md b/docs/en/examples/reproductions/diffusion-reproducibility.md index b731ecc..8d2d684 100644 --- a/docs/en/examples/reproductions/diffusion-reproducibility.md +++ b/docs/en/examples/reproductions/diffusion-reproducibility.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: repro-diffusion-same-init-different-seed --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/edge-of-stability-cpu.md b/docs/en/examples/reproductions/edge-of-stability-cpu.md index 310a4ab..d5eaa44 100644 --- a/docs/en/examples/reproductions/edge-of-stability-cpu.md +++ b/docs/en/examples/reproductions/edge-of-stability-cpu.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: edge-of-stability-cpu --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/edge-of-stability-eos.md b/docs/en/examples/reproductions/edge-of-stability-eos.md index ac50c0a..b754c10 100644 --- a/docs/en/examples/reproductions/edge-of-stability-eos.md +++ b/docs/en/examples/reproductions/edge-of-stability-eos.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: 97ff01a8-1724-43ec-8c38-fdb62bbe5faf --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/in-context-associative-recall.md b/docs/en/examples/reproductions/in-context-associative-recall.md index 61752a6..7227ad3 100644 --- a/docs/en/examples/reproductions/in-context-associative-recall.md +++ b/docs/en/examples/reproductions/in-context-associative-recall.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: 5d1a2ab4-825d-4251-8a5a-d7b83b42c1d7 --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/information-bottleneck-figure3.md b/docs/en/examples/reproductions/information-bottleneck-figure3.md index 8ef4980..3c79a8a 100644 --- a/docs/en/examples/reproductions/information-bottleneck-figure3.md +++ b/docs/en/examples/reproductions/information-bottleneck-figure3.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: dafb8339-a932-4b10-b3b6-185fc53a5a4f --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/jastrzebski-fig1-cyclic-cbs-vs-clr.md b/docs/en/examples/reproductions/jastrzebski-fig1-cyclic-cbs-vs-clr.md index 4ba0991..dcd04ad 100644 --- a/docs/en/examples/reproductions/jastrzebski-fig1-cyclic-cbs-vs-clr.md +++ b/docs/en/examples/reproductions/jastrzebski-fig1-cyclic-cbs-vs-clr.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: repro-jastrzbski-fig1-vgg11 --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/keskar-fig2-3-sb-lb.md b/docs/en/examples/reproductions/keskar-fig2-3-sb-lb.md index 11ee807..0273896 100644 --- a/docs/en/examples/reproductions/keskar-fig2-3-sb-lb.md +++ b/docs/en/examples/reproductions/keskar-fig2-3-sb-lb.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: repro-keskar-fig23-sb-lb --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/lazy-vs-rich-regime.md b/docs/en/examples/reproductions/lazy-vs-rich-regime.md index 41f5e44..103d7ff 100644 --- a/docs/en/examples/reproductions/lazy-vs-rich-regime.md +++ b/docs/en/examples/reproductions/lazy-vs-rich-regime.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: d2e8cdd7-d14c-42c3-94dc-ba2b419c07f9 --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/linear-mode-connectivity.md b/docs/en/examples/reproductions/linear-mode-connectivity.md index 5b42d4e..64dae6f 100644 --- a/docs/en/examples/reproductions/linear-mode-connectivity.md +++ b/docs/en/examples/reproductions/linear-mode-connectivity.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: repro-linear-mode-connectivity-cifar10 --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/random-label-memorization-figure1a.md b/docs/en/examples/reproductions/random-label-memorization-figure1a.md index 32bc090..03e1e5d 100644 --- a/docs/en/examples/reproductions/random-label-memorization-figure1a.md +++ b/docs/en/examples/reproductions/random-label-memorization-figure1a.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: repro-random-label-memorization-fig1a --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/rank-collapse-figure5.md b/docs/en/examples/reproductions/rank-collapse-figure5.md index 3252b30..0a9b76d 100644 --- a/docs/en/examples/reproductions/rank-collapse-figure5.md +++ b/docs/en/examples/reproductions/rank-collapse-figure5.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: repro-rank-collapse-figure5-linear-ce --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/rank-collapse-tinyshakespeare.md b/docs/en/examples/reproductions/rank-collapse-tinyshakespeare.md index ab44b96..b8410bb 100644 --- a/docs/en/examples/reproductions/rank-collapse-tinyshakespeare.md +++ b/docs/en/examples/reproductions/rank-collapse-tinyshakespeare.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: repro-rank-collapse-tinyshakespeare-pretraining --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/saad_solla_plateau_reproduction.md b/docs/en/examples/reproductions/saad_solla_plateau_reproduction.md index 1549d0f..5fe36da 100644 --- a/docs/en/examples/reproductions/saad_solla_plateau_reproduction.md +++ b/docs/en/examples/reproductions/saad_solla_plateau_reproduction.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: e399fd7d-e107-44d0-94b6-7e2159392253 --- :::{div} cr-eyebrow @@ -57,7 +58,7 @@ Saad & Solla, Phys. Rev. Lett. 74, 4337-4340 (1995). **Template:** `Saad & Solla Over-Realizable (CPU)` -**Template ID:** `saad-solla-over-realizable-cpu` +**Template ID:** `e399fd7d-e107-44d0-94b6-7e2159392253` ## Reproduction Goal diff --git a/docs/en/examples/reproductions/spectral-bias-figure1a.md b/docs/en/examples/reproductions/spectral-bias-figure1a.md index 06f26e7..72db3a8 100644 --- a/docs/en/examples/reproductions/spectral-bias-figure1a.md +++ b/docs/en/examples/reproductions/spectral-bias-figure1a.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: repro-spectral-bias-fig1a --- :::{div} cr-eyebrow diff --git a/docs/en/examples/reproductions/staggered-singular-value-dynamics.md b/docs/en/examples/reproductions/staggered-singular-value-dynamics.md index 7eb29b9..a6a0335 100644 --- a/docs/en/examples/reproductions/staggered-singular-value-dynamics.md +++ b/docs/en/examples/reproductions/staggered-singular-value-dynamics.md @@ -1,6 +1,7 @@ --- doc_type: reproduction doc_status: phenomenon +template_id: a04f21b3-e31c-4ba3-b8b9-d3af752f77d4 --- :::{div} cr-eyebrow diff --git a/docs/en/get-started/first-graph.md b/docs/en/get-started/first-graph.md index c016ecf..df0f4a2 100644 --- a/docs/en/get-started/first-graph.md +++ b/docs/en/get-started/first-graph.md @@ -1,6 +1,7 @@ --- doc_type: tutorial doc_status: stable-core +template_id: edge-of-stability-cpu --- :::{div} cr-eyebrow diff --git a/tests/test_docs_build_contracts.py b/tests/test_docs_build_contracts.py index 880fcf7..1322f94 100644 --- a/tests/test_docs_build_contracts.py +++ b/tests/test_docs_build_contracts.py @@ -74,6 +74,7 @@ def test_build_docs_writes_the_docs_site(tmp_path: Path) -> None: assert (site / "en/0.1.0/_static/comfyresearch.js").is_file() introduction_html = (site / "en/0.1.0/introduction/index.html").read_text() + assert 'class="cr-template-link"' not in introduction_html assert 'data-page="introduction"' in introduction_html assert 'class="navbar-brand cr-brand"' in introduction_html assert 'class="cr-brand-logo cr-brand-logo--light"' in introduction_html @@ -148,6 +149,9 @@ def test_build_docs_writes_the_docs_site(tmp_path: Path) -> None: assert 'class="prev-next-footer d-print-none"' in first_graph_html assert 'id="pst-secondary-sidebar"' in first_graph_html assert ">Tutorial<" in first_graph_html + assert 'class="cr-template-link"' in first_graph_html + assert "templateId=edge-of-stability-cpu" in first_graph_html + assert "Open template ↗" in first_graph_html assert ">Stable core<" in first_graph_html user_guide_page = site / "en/0.1.0/user-guide/index.html" @@ -220,6 +224,8 @@ def test_build_docs_writes_the_docs_site(tmp_path: Path) -> None: assert "—" not in source_text assert "–" not in source_text + reference_html = (site / "en/0.1.0/reference/index.html").read_text() + assert 'class="cr-template-link"' not in reference_html reference_text = rendered_text(site / "en/0.1.0/reference/index.html") assert "Runtime and file contracts" in reference_text assert "Application" in reference_text diff --git a/tests/test_docs_source_contracts.py b/tests/test_docs_source_contracts.py index 0bcfb92..1e733b3 100644 --- a/tests/test_docs_source_contracts.py +++ b/tests/test_docs_source_contracts.py @@ -10,7 +10,9 @@ def test_docs_pages_publish_identity_and_governance() -> None: assert "sphinx-copybutton==0.5.2" in requirements assert '"sphinx_copybutton"' in config - assert '"article_header_start": ["breadcrumbs", "page-status.html"]' in config + assert '"article_header_start":' in config + assert '"page-status.html"' in config + assert '"template-link.html"' in config assert '"article_footer_items": []' in config assert '"use_edit_page_button": True' not in config assert "html_context = {" not in config @@ -87,6 +89,38 @@ def test_docs_pages_publish_identity_and_governance() -> None: assert "cr_ui.doc_status_stable_core" in status_template assert "cr_ui.doc_status_phenomenon" in status_template assert "doc_version_dev" not in status_template + + template_link = Path("docs/_templates/template-link.html").read_text() + assert "cr-template-link" in template_link + assert "templateId={{ template_id }}" in template_link + assert 'target="_blank"' in template_link + assert 'rel="noopener"' in template_link + assert "cr_ui.open_template" in template_link + + expected_template_ids = { + "examples/reproductions/jastrzebski-fig1-cyclic-cbs-vs-clr.md": "repro-jastrzbski-fig1-vgg11", + "examples/reproductions/edge-of-stability-cpu.md": "edge-of-stability-cpu", + "examples/reproductions/edge-of-stability-eos.md": "97ff01a8-1724-43ec-8c38-fdb62bbe5faf", + "examples/reproductions/keskar-fig2-3-sb-lb.md": "repro-keskar-fig23-sb-lb", + "examples/reproductions/lazy-vs-rich-regime.md": "d2e8cdd7-d14c-42c3-94dc-ba2b419c07f9", + "examples/reproductions/staggered-singular-value-dynamics.md": "a04f21b3-e31c-4ba3-b8b9-d3af752f77d4", + "examples/reproductions/spectral-bias-figure1a.md": "repro-spectral-bias-fig1a", + "examples/reproductions/saad_solla_plateau_reproduction.md": "e399fd7d-e107-44d0-94b6-7e2159392253", + "examples/reproductions/rank-collapse-figure5.md": "repro-rank-collapse-figure5-linear-ce", + "examples/reproductions/rank-collapse-tinyshakespeare.md": "repro-rank-collapse-tinyshakespeare-pretraining", + "examples/reproductions/information-bottleneck-figure3.md": "dafb8339-a932-4b10-b3b6-185fc53a5a4f", + "examples/reproductions/diffusion-reproducibility.md": "repro-diffusion-same-init-different-seed", + "examples/reproductions/random-label-memorization-figure1a.md": "repro-random-label-memorization-fig1a", + "examples/reproductions/linear-mode-connectivity.md": "repro-linear-mode-connectivity-cifar10", + "examples/reproductions/Neural_Mechanics.md": "b38ae9dd-735b-46c4-973f-a850a2a55544", + "examples/reproductions/in-context-associative-recall.md": "5d1a2ab4-825d-4251-8a5a-d7b83b42c1d7", + "get-started/first-graph.md": "edge-of-stability-cpu", + } + template_root = Path("data/graph_library/templates") + for relative_path, template_id in expected_template_ids.items(): + metadata = front_matter(source_root / relative_path) + assert metadata["template_id"] == template_id + assert (template_root / f"{template_id}.json").is_file() assert '"doc_status_stable_core": "Stable core"' in config assert '"doc_status_phenomenon": "Phenomenon reproduction"' in config @@ -250,7 +284,7 @@ def test_docs_theme_uses_native_navigation_and_search() -> None: '"search_as_you_type": False', '"disable_search": True', '"navbar_persistent": []', - '"article_header_start": ["breadcrumbs", "page-status.html"]', + '"article_header_start":', '"**": ["sidebar-nav-bs.html"]', '"introduction": []', '"examples/index": []', diff --git a/tests/test_docs_visual_contracts.py b/tests/test_docs_visual_contracts.py index 03a5b1a..ad55fa9 100644 --- a/tests/test_docs_visual_contracts.py +++ b/tests/test_docs_visual_contracts.py @@ -18,6 +18,17 @@ def relative_luminance(color: str) -> float: return (lighter + 0.05) / (darker + 0.05) +def test_template_link_uses_brand_action_tokens() -> None: + stylesheet = Path("docs/_static/comfyresearch.css").read_text() + block = css_block_with(stylesheet, ".cr-template-link", "background: var(--cr-accent);") + hover = css_block_with(stylesheet, ".cr-template-link:hover", "background: var(--cr-accent-dark);") + assert "background: var(--cr-accent);" in block + assert "color: var(--cr-on-accent);" in block + assert "border: 1px solid var(--cr-accent);" in block + assert "background: var(--cr-accent-dark);" in hover + assert "transform: translateY(-1px);" in hover + + def test_product_screenshot_style() -> None: stylesheet = Path("docs/_static/comfyresearch.css").read_text() screenshots = css_block( From 9ced32147d064a7c423a2a951bdc3225dd8cc4b6 Mon Sep 17 00:00:00 2001 From: quqingyu <12210819@mail.sustech.edu.cn> Date: Mon, 3 Aug 2026 15:24:23 +0800 Subject: [PATCH 2/2] docs: align online template links with deployment --- docs/_templates/template-link.html | 4 +-- docs/conf.py | 3 ++- .../reproductions/Neural_Mechanics.md | 1 + .../saad_solla_plateau_reproduction.md | 1 + tests/test_docs_build_contracts.py | 26 +++++++++++++++++++ tests/test_docs_i18n.py | 3 +++ tests/test_docs_source_contracts.py | 8 +++++- 7 files changed, 42 insertions(+), 4 deletions(-) diff --git a/docs/_templates/template-link.html b/docs/_templates/template-link.html index 82b59ea..307d21a 100644 --- a/docs/_templates/template-link.html +++ b/docs/_templates/template-link.html @@ -1,7 +1,7 @@ -{% if template_id %} +{% if online_template_id %} None: assert "cr-article-meta" in html assert "cr-abstract" in html + template_link_routes = { + "get-started/first-graph": "edge-of-stability-cpu", + "examples/reproductions/jastrzebski-fig1-cyclic-cbs-vs-clr": "repro-jastrzbski-fig1-vgg11", + "examples/reproductions/edge-of-stability-cpu": "edge-of-stability-cpu", + "examples/reproductions/edge-of-stability-eos": "97ff01a8-1724-43ec-8c38-fdb62bbe5faf", + "examples/reproductions/keskar-fig2-3-sb-lb": "repro-keskar-fig23-sb-lb", + "examples/reproductions/lazy-vs-rich-regime": "d2e8cdd7-d14c-42c3-94dc-ba2b419c07f9", + "examples/reproductions/staggered-singular-value-dynamics": "a04f21b3-e31c-4ba3-b8b9-d3af752f77d4", + "examples/reproductions/spectral-bias-figure1a": "repro-spectral-bias-fig1a", + "examples/reproductions/saad_solla_plateau_reproduction": "de684a36-a2d5-440f-bb2b-3c249abb8270", + "examples/reproductions/rank-collapse-figure5": "repro-rank-collapse-figure5-linear-ce", + "examples/reproductions/rank-collapse-tinyshakespeare": "repro-rank-collapse-tinyshakespeare-pretraining", + "examples/reproductions/information-bottleneck-figure3": "dafb8339-a932-4b10-b3b6-185fc53a5a4f", + "examples/reproductions/diffusion-reproducibility": "repro-diffusion-same-init-different-seed", + "examples/reproductions/random-label-memorization-figure1a": "repro-random-label-memorization-fig1a", + "examples/reproductions/linear-mode-connectivity": "repro-linear-mode-connectivity-cifar10", + "examples/reproductions/Neural_Mechanics": "b15a6036-0e38-4f8f-84ba-8b763c408dc9", + "examples/reproductions/in-context-associative-recall": "5d1a2ab4-825d-4251-8a5a-d7b83b42c1d7", + } + for locale_root, link_label in (("en/0.1.0", "Open template ↗"), ("zh/0.1.0", "在线打开模板 ↗")): + for route, online_template_id in template_link_routes.items(): + html = (site / locale_root / route / "index.html").read_text() + assert 'class="cr-template-link"' in html + assert f"templateId={online_template_id}" in html + assert link_label in html + forbidden_screenshot_hashes = { "afed5be9d3cc79c3b9ede8f988b3d73c52e8f1813f5d629d51a4a3da9a94c238", "5b780832a1dcb49efdea3aa224516473707f688bf19cd3d87d2ce48887f3d541", diff --git a/tests/test_docs_i18n.py b/tests/test_docs_i18n.py index 25e3bfd..95921b5 100644 --- a/tests/test_docs_i18n.py +++ b/tests/test_docs_i18n.py @@ -157,6 +157,7 @@ def test_page_context_injects_localized_ui( "doc_type_reproduction", "doc_status_stable_core", "doc_status_phenomenon", + "open_template", "github_repo_aria_label", "version_switch_aria_label", "language_switch_label", @@ -169,9 +170,11 @@ def test_page_context_injects_localized_ui( if language == "zh_CN": assert context["cr_ui"]["search_placeholder"] == "搜索文档" assert context["cr_ui"]["language_switch_label"] == "EN" + assert context["cr_ui"]["open_template"] == "在线打开模板 ↗" else: assert context["cr_ui"]["search_placeholder"] == "Search the docs" assert context["cr_ui"]["language_switch_label"] == "中文" + assert context["cr_ui"]["open_template"] == "Open template ↗" assert "%(query)s" in context["cr_ui"]["search_no_results"] assert context["alternate_language_label"] == context["cr_ui"]["language_switch_label"] assert context["current_docs_version"] == "v0.1.0" diff --git a/tests/test_docs_source_contracts.py b/tests/test_docs_source_contracts.py index 1e733b3..df6011c 100644 --- a/tests/test_docs_source_contracts.py +++ b/tests/test_docs_source_contracts.py @@ -92,7 +92,7 @@ def test_docs_pages_publish_identity_and_governance() -> None: template_link = Path("docs/_templates/template-link.html").read_text() assert "cr-template-link" in template_link - assert "templateId={{ template_id }}" in template_link + assert "templateId={{ online_template_id }}" in template_link assert 'target="_blank"' in template_link assert 'rel="noopener"' in template_link assert "cr_ui.open_template" in template_link @@ -116,11 +116,17 @@ def test_docs_pages_publish_identity_and_governance() -> None: "examples/reproductions/in-context-associative-recall.md": "5d1a2ab4-825d-4251-8a5a-d7b83b42c1d7", "get-started/first-graph.md": "edge-of-stability-cpu", } + expected_online_template_ids = { + **expected_template_ids, + "examples/reproductions/Neural_Mechanics.md": "b15a6036-0e38-4f8f-84ba-8b763c408dc9", + "examples/reproductions/saad_solla_plateau_reproduction.md": "de684a36-a2d5-440f-bb2b-3c249abb8270", + } template_root = Path("data/graph_library/templates") for relative_path, template_id in expected_template_ids.items(): metadata = front_matter(source_root / relative_path) assert metadata["template_id"] == template_id assert (template_root / f"{template_id}.json").is_file() + assert metadata.get("online_template_id", template_id) == expected_online_template_ids[relative_path] assert '"doc_status_stable_core": "Stable core"' in config assert '"doc_status_phenomenon": "Phenomenon reproduction"' in config