"""The reference section: /reference/settings and the three contract pages, in the 1c Logbook layout. The other site suites are about slices — a heading renamed in AGENTS.md stops the build. This one is about the promise a *settings* page makes, which is stronger and easier to break quietly: the page is not written, it is read out of `manager/core/.env.example`, so a key added there appears here with nobody editing site/, and a key documented nowhere fails the build rather than reaching the site bare. The rest is the layout: the pinned console carries the page's own entries and nothing it invented, and a reference page keeps every piece of furniture an article has — the sidebar, the folded menus, prev/next and "Edit this page". python3 -m unittest discover -s tests """ import json import re import shutil import tempfile import unittest from pathlib import Path from tests.test_site_build import (BUILDER, HAS_MARKDOWN_IT, REPO, SITE, ScratchCase, needs_renderer, run_build) ENV_EXAMPLE = "manager/core/.env.example" CONSOLE_LINE = re.compile( r'(.*?)', re.S) CONSOLE_KEY = re.compile(r'([^<]*)') CONSOLE_VALUE = re.compile(r'([^<]*)') HEADING_ID = re.compile(r'
BOARD_AGENT_COMMANDS='
"python3 -m unittest\n", self.html)
css = (SITE / "static" / "site.css").read_text("utf-8")
self.assertIn("code.language-env", css,
"nothing in the stylesheet tells a default from a "
"code block")
def test_the_documentation_is_the_files_own_comment(self):
"""Not a paraphrase written into site/: sentences out of the
comment blocks, arriving as the markdown they were written as."""
self.assertIn("Pinned by default so the URL is bookmarkable",
self.html)
self.assertIn("a test runner missing from this list", self.html)
self.assertIn("board: <number> → <stage> "
"(<name>)", self.html)
def test_a_placeholder_in_a_comment_survives_as_text(self):
"""`", self.html) note = self.html.split("") self.assertTrue( any("definition-of-done check" in part for part in note), "the note about the checks file is not on the page") def test_edit_this_page_opens_the_file_itself(self): """There is no `from` heading to anchor at: the page is the whole file.""" blob = self.manifest["site"]["blob_base"].rstrip("/") + "/" self.assertIn(f'href="{blob}{ENV_EXAMPLE}"', self.html) class TheContractPagesAreSlices(BuiltSite): """Acceptance: slices of the contract files, not paraphrases.""" def test_the_adapter_contract_is_the_adapters_readme(self): html = self.page("/reference/adapters/") self.assertIn("stdout is captured by the board as the job log", html) self.assertIn("work", html) # The normalized event schema, indented in the README, arrives as # the code block it is. self.assertIn("", html) self.assertIn(""v": 1", html) def test_the_driver_contract_is_agents_md(self): html = self.page("/reference/driver/") self.assertIn("refuse fast with a printed reason", html) self.assertIn("DRIVE URL", html) def test_the_command_contract_is_agents_md(self): html = self.page("/reference/commands/") self.assertIn("CMD_WORKTREE", html) self.assertIn("Commands arm on first click and run on the second", html) def test_each_one_edits_at_the_section_it_was_cut_from(self): blob = self.manifest["site"]["blob_base"].rstrip("/") + "/" for entry in self.entries(): if not entry.get("from"): continue wanted = (blob + entry["source"] + "#" + BUILDER.github_anchor(entry["from"])) self.assertIn(f'href="{wanted}"', self.page(entry["path"]), f'{entry["path"]}: "Edit this page" does not open ' f'{entry["source"]} at {entry["from"]}') def test_a_pages_console_is_its_own_headings(self): """The adapter page's entries are the contract's `###` headings, promoted — so the console is generated for a sliced page too, with no per-page authoring anywhere.""" html = self.page("/reference/adapters/") anchors = dict(HEADING_ID.findall(html)) lines = CONSOLE_LINE.findall(html) self.assertEqual(sorted(anchors), sorted(slug for slug, _ in lines)) self.assertIn("run — execute one headless job to completion", [CONSOLE_KEY.search(line).group(1) for _, line in lines], "the console shows the heading's markdown backticks") class TheLayoutKeepsEveryArticlesFurniture(BuiltSite): """A reader must not lose the nav, the contents or the arrows by walking into the reference section.""" def test_the_three_columns_are_there(self): for entry in self.entries(): html = self.page(entry["path"]) for furniture in ('class="page-reference"', 'class="side"', 'class="prose"', 'class="gutter"', 'class="crumbs"', 'class="prose-lede"'): self.assertIn(furniture, html, f'{entry["path"]} is missing {furniture}') def test_the_section_nav_is_folded_in_as_well(self): listed = [page for page in self.manifest["pages"] if page.get("section")] for entry in self.entries(): menu = NAV.search(self.page(entry["path"])) self.assertIsNotNone(menu, f'{entry["path"]} has no folded nav') for page in listed: self.assertIn(f'href="{page["path"]}"', menu.group(1), f'{entry["path"]}\'s menu cannot reach ' f'{page["path"]}') def test_the_folded_contents_carries_the_anchors_the_console_does(self): """Below 1080px the whole gutter goes, console and all. The strip that replaces it has to reach everything the console did, or a phone loses the index entirely.""" for entry in self.entries(): html = self.page(entry["path"]) strip = CONTENTS.search(html) self.assertIsNotNone(strip, f'{entry["path"]} has no contents strip') for slug, _ in CONSOLE_LINE.findall(html): self.assertIn(f'href="#{slug}"', strip.group(1), f'{entry["path"]}\'s contents strip drops ' f"#{slug}") def test_the_arrows_are_rendered(self): for entry in self.entries(): self.assertIn('