mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-11-14 18:24:37 -06:00
The toolchain folder is now binder/, and the root ./binder symlink is gone. The command is ./binder/binder: a plain path to the script, with no link and no install step. Every invocation moved with it: pre-commit entries, workflow steps, the VS Code extension's command palette, help text, and docs. - bindery/ paths and bindery.* imports, including the chapter code cells that import binder.tools.figures, now name binder/. - Binder (mybinder.org) reads its configuration from a root binder/ folder and refuses to build when binder/ and .binder/ both exist. .binder/postBuild and .binder/requirements.txt move into binder/, so the TinyTorch "Launch Binder" buttons keep working; binder/README.md records which file names the toolchain must not use there. - contributors/projects.json still pointed the book's contributor record at publishing/; it now names binder/, where that .all-contributorsrc lives. - The margin-figure reader-link audit report linked its 222 figures through the retired quarto/ tree; the links now resolve under books/. The hooks reformatted hidden Python cells and trimmed whitespace in the Volume II chapters whose figure imports this rename touches. Checks: ./binder/binder check cli passes (contract and canonical hooks), binder.tools.figures imports, and every workflow YAML file parses. binder test suite, excluding the four modules that cannot import mlsysim through the root symlink (fixed separately): 7 failed, 346 passed. The GitHub repository variables BOOK_ROOT, BOOK_TOOLS, BOOK_DEPS, and BOOK_DOCKER still name the retired book/ layout and must change when this reaches origin.
92 lines
2.4 KiB
Python
92 lines
2.4 KiB
Python
from types import SimpleNamespace
|
|
|
|
from binder.cli.commands.validate import ValidateCommand
|
|
|
|
|
|
def _run_xref_case(tmp_path, body):
|
|
qmd = tmp_path / "chapter.qmd"
|
|
qmd.write_text(body, encoding="utf-8")
|
|
command = ValidateCommand(
|
|
config_manager=SimpleNamespace(book_dir=tmp_path),
|
|
chapter_discovery=None,
|
|
)
|
|
return command._run_xref_sentence_start_case(tmp_path)
|
|
|
|
|
|
def test_algorithm_refs_follow_sentence_position(tmp_path):
|
|
result = _run_xref_case(
|
|
tmp_path,
|
|
"\n".join(
|
|
[
|
|
"@Alg-start states the loop.",
|
|
"The implementation follows @alg-mid.",
|
|
"The transition is mechanical: @alg-after-colon shows it.",
|
|
"**Scenario**: @Alg-bold-leadin shows it.",
|
|
]
|
|
),
|
|
)
|
|
|
|
assert not result.issues
|
|
|
|
|
|
def test_algorithm_ref_case_violations_are_flagged(tmp_path):
|
|
result = _run_xref_case(
|
|
tmp_path,
|
|
"\n".join(
|
|
[
|
|
"@alg-start states the loop.",
|
|
"The implementation follows @Alg-mid.",
|
|
"The transition is mechanical: @Alg-after-colon shows it.",
|
|
]
|
|
),
|
|
)
|
|
|
|
assert [issue.code for issue in result.issues] == [
|
|
"xref_sentence_start_case",
|
|
"xref_midsentence_case",
|
|
"xref_midsentence_case",
|
|
]
|
|
|
|
|
|
def test_algorithm_bracket_refs_are_flagged(tmp_path):
|
|
result = _run_xref_case(
|
|
tmp_path,
|
|
"\n".join(
|
|
[
|
|
"[Algorithm @alg-start] states the loop.",
|
|
"The implementation follows [algorithm @alg-mid].",
|
|
]
|
|
),
|
|
)
|
|
|
|
assert [issue.code for issue in result.issues] == [
|
|
"algorithm_ref_bracketed_prefix",
|
|
"algorithm_ref_bracketed_prefix",
|
|
]
|
|
|
|
|
|
def test_bare_algorithm_refs_are_flagged(tmp_path):
|
|
result = _run_xref_case(
|
|
tmp_path,
|
|
"\n".join(
|
|
[
|
|
"Algorithm @alg-start states the loop.",
|
|
"The implementation follows algorithm @alg-mid.",
|
|
]
|
|
),
|
|
)
|
|
|
|
assert [issue.code for issue in result.issues] == [
|
|
"algorithm_ref_bare_prefix",
|
|
"algorithm_ref_bare_prefix",
|
|
]
|
|
|
|
|
|
def test_bare_algorithm_refs_catch_capitalized_target(tmp_path):
|
|
result = _run_xref_case(
|
|
tmp_path,
|
|
"The implementation follows algorithm @Alg-mid.",
|
|
)
|
|
|
|
assert "algorithm_ref_bare_prefix" in [issue.code for issue in result.issues]
|