Skip to content

stage-site and site-build: the follow-ups from the reviews of QuantEcon/lectures#102 and #106 - #108

Merged
mmcky merged 5 commits into
mainfrom
stage-site/follow-ups
Nov 27, 2026
Merged

mmcky merged 5 commits into
mainfrom
stage-site/follow-ups

Conversation

@mmcky

@mmcky mmcky commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Why

The reviews of #102 (tools/stage-site --local-links) and #106 (the PDF) left points to take after their merges. This PR takes them. None changes what any site builds or publishes today.

tools/stage-site (from the reviews of #102)

  • A left-over original that changes nothing. An earlier --clean that kept an edited lecture leaves its original under _build/stage-site-originals/, and staging refused while it was there. It now refuses only when the original differs from the pool's lecture as it is now. Once the lecture has been put back by hand, replacing the original loses nothing.
  • The originals folder. Staging refuses when _build/stage-site-originals is a link or a file. It also refuses when a lecture's place in that folder holds a link, dangling ones included. A dangling link is not .exists(), so copying the original would have written through it. The confinement --clean uses refuses a folder that is itself a link, whose target it would otherwise confine to.
  • The paragraph reading is main's. This PR first changed how tools/stage-site reads paragraphs, so that inline literals are found as CommonMark finds them. After four review rounds, that hand-written reading still disagreed with markdown-it on 9 of 62 cases, against 21 for main's. The maintainer chose to split it out (Matt, 2026-11-27, in the project-monorepo session: "Split; markdown-it next (Recommended)"). So prose_mask is main's again, and a separate PR will read paragraphs and code spans with markdown-it and MyST's plugins, exact by construction.

site-build.yml (from the review of #106)

  • The cache save runs on always() with the outcome of the HTML build and of its execution report. A job that times out or is cancelled in a later step, the PDF build say, still keeps a cold build's execution. The header's cache paragraph and sites/README.md no longer say "after a green build".
  • The PDF copy step's grep: finding nothing (exit 1) is reported by the check after it. A real error (exit 2, such as an unreadable folder) now fails the step with grep's own message. || true had let that pass green.
  • sites/README.md's publishes row no longer says "the same way" twice, and a comment left short by rewrapping is rewrapped.

Checked

  • On the pool (at aa281d3): the reading is main's, so every pool lecture reads as on main (0 lines differ), and dp's --local-links plan is the same 31 links in 13 lectures, byte for byte.
  • Tests: 361 passed and 1 skipped (at 5498ef2). Each fix has a test that fails without it: the left-over original that matches (put back and staged again), a dangling link where an original goes, a folder there, and an originals folder that is a link or a file, at staging and at --clean.
  • The copy step, its script taken from the workflow and run under bash --noprofile --norc -eo pipefail on local cases:
    • a good build passes;
    • a wrong name fails with its message;
    • no link fails with its message;
    • an unreadable folder fails with grep's "Permission denied" (with || true it passed).
  • actionlint is clean; pool-check is clean.

This PR's site build runs all six sites, since it touches tools/stage-site. Every leg restores main's cache.

Copilot: not requested (Matt, 2026-11-22).

🤖 Generated with Claude Code

https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG

mmcky and others added 3 commits November 27, 2026 14:02
- A lecture's original left by an earlier --clean, which kept the lecture,
  no longer refuses staging when it holds what the pool's lecture holds
  now (put back by hand, say), since replacing it loses nothing. One that
  differs still refuses.
- The originals folder: staging refuses when it is a link or a file, and
  when a lecture's place in it holds a link, dangling ones included (a
  dangling link is not .exists(), and copying the original would have
  written through it). The confinement --clean reads refuses a folder that
  is itself a link, whose target it would otherwise confine to.
- The paragraph reading, as CommonMark has it: an ordered item other than
  1. ends a paragraph only in a list (`2024. Then` continues one), and an
  item indented four spaces or more only in a list, as a nested item. The
  docstring no longer lists these two among the misreadings.

On the pool the reading is unchanged, and dp's plan is the same 31 links in
13 lectures. Each fix has a test that fails on main (9f3a710).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
- The cache save runs on always() with the HTML build's outcome, so a job
  that times out or is cancelled in a later step (the PDF, say) still
  keeps a cold build's execution; the header's step 11 says so.
- The header's cache paragraph and sites/README.md no longer say the cache
  is saved "after a green build": it is after an HTML build that
  succeeded, whatever a later step did.
- The copy step's grep: finding nothing (exit 1) is the check's to report,
  and a real error (exit 2, an unreadable folder) now fails the step with
  grep's own message, where `|| true` let it pass green.
- sites/README.md's publishes row no longer says "the same way" twice; a
  comment left short by rewrapping is rewrapped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
@mmcky

mmcky commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Validation at db8cd72 (run 45955244743, green on every leg)

This PR changes how the site build saves its cache and how the PDF copy step reads grep's exit status. It changes no command that makes a page, a notebook or a PDF, and --local-links is on for no site. So its build should give what main's gives. I compared it with main's push build of aa281d3 (45954944901), file by file, across every leg's html-<key> artefact. Both builds took every page from the cache: each leg's execution report shows 0 executed in both (dp 53, intro 56, programming 27, jax 32, advanced 80, intermediate 161 cached).

Site Files, main / PR Byte-identical Differing
dp 639 / 639 586 53 notebooks
intro 914 / 914 800 113 notebooks, the PDF
programming 467 / 467 412 54 notebooks, the PDF
jax 469 / 469 402 65 notebooks, the PDF, 1 page
advanced 1041 / 1041 880 160 notebooks, the PDF
intermediate 1874 / 1874 1550 322 notebooks, the PDF, 1 page

No file is in one build and not the other. Every difference is something each build writes afresh:

  • Notebooks: each cell's random id and the notebook's metadata.date. With those two set aside, every notebook is identical.
  • Two pages: jax's hopenhayn.html and intermediate's divergence_measures.html, and their notebooks. These differ only in the random UUIDs Sphinx gives unlabelled amsmath equations (8 and 3 of them).
  • The five PDFs: their text (pdftotext) is identical, so the difference is in the file's own metadata.

The two behaviours that changed are tested apart from the build, as the PR body says: the tests for tools/stage-site, and the copy step's script run under bash -eo pipefail on local cases. The cache save's new condition acts only on main, so it shows first on this PR's merge.

mmcky and others added 2 commits November 27, 2026 18:50
stage-site's paragraph reading:
- A nested list numbered other than 1 cannot interrupt a paragraph, in a
  list or not: an ordered item numbered other than 1 ends one only at the
  indent of the list's last item or less (a sibling, or a parent's). The
  docstring said "as CommonMark has it" for a rule that read `- a` then
  `    2. b`, or `1. a` then `   14. b`, as items.
- A list ends at any block that is not indented and is not an item (a
  heading too), not only at a paragraph after a blank line.
- Against markdown-it with MyST's block plugin, on 21 cases: 0
  disagreements (db8cd72: 4, each a link in a literal rewritten).
- Tests: the review's three cases, `1. a` then `   2. b`, the list ending
  at a paragraph (it fails without the reset line) and at a heading, and a
  sibling a level up; an originals folder that is a plain file (it fails
  without that check). A link or folder where an original goes is refused
  as "not a plain file holding the lecture", not as "differs".

site-build:
- The cache save also needs the report's success: a cancel between the
  build and the report left `executed` empty, and the save ran.
- "first green run on main" in the header and sites/README.md is now the
  first run whose HTML build succeeds.

On the pool the reading is unchanged against main (aa281d3), and dp's plan
is the same 31 links in 13 lectures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
…ollows

The maintainer chose to split the paragraph reading out of this PR (Matt,
2026-11-27, in the project-monorepo session: "Split; markdown-it next
(Recommended)"). After four review rounds, the hand-written reading still
disagreed with markdown-it on 9 of 62 cases, against 21 for main's. A
separate PR will read paragraphs and code spans with markdown-it and
MyST's plugins, so the reading is exact by construction.

- tools/stage-site's prose_mask is main's (aa281d3) again, and the ten
  test cases written for the new reading go with it. The pool reads
  exactly as on main, and dp's plan is the same 31 links in 13 lectures.
- Kept: the left-over original that matches the lecture, the originals
  folder checks, and the site-build fixes.
- A test for a folder left where an original goes; it fails without
  `kept.is_file()`.
- site-build.yml and sites/README.md: the save follows the HTML build and
  its execution report, as the condition reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
@mmcky
mmcky merged commit 4b0ab02 into main Nov 27, 2026
12 checks passed
@mmcky
mmcky deleted the stage-site/follow-ups branch November 27, 2026 09:13
mmcky added a commit that referenced this pull request Nov 27, 2026
## Why

`tools/stage-site --local-links` rewrites a consumer site's links to lectures it carries (#102). It must leave alone a link that isn't one, such as an address inside an inline literal or a code cell. Until now it found those with hand-written rules for paragraphs and code spans. Four review rounds of #108 each found new list-indentation cases where those rules and CommonMark disagree. On the 62 cases the reviews checked against markdown-it, main's reading disagrees on 21. The maintainer chose to split that work out of #108 and read pages with markdown-it itself (Matt, 2026-11-27, in the project-monorepo session: "Split; markdown-it next (Recommended)").

## What it changes

- **`Reader`** builds the parser MyST itself uses, myst-parser's markdown-it (`create_md_parser`), with the extensions the site's `_config.yml` enables (`parse: myst_enable_extensions`). It wraps the parser's `link` and `myst_role` inline rules so that each records where its link or role starts and ends. A link counts only where the parser makes one, so none comes from a code cell, a literal block, an inline literal, a `%` comment, raw HTML or maths.
- **Placing back.** Each paragraph, heading or table cell the parser reads is found again in its source lines, one line for one, after any list indent or `>` it carried. Cells of one row are found left to right. A directive's body is read the same way, except for `LITERAL_DIRECTIVES` (code, math, raw). An edit is made only where the source holds, at the place found, exactly what the parser read there. Anything that can't be placed is left as it is, still linking out, as every link did before `--local-links`.
- **Gone:** `prose_mask` and its fence, backtick and block-start rules.
- **Dependencies:** `myst-parser` and `linkify-it-py` (for the sites' `linkify`) join the script's uv header and `tests.yml`. Every leg's environment has them, since Jupyter Book does (myst-parser 3.0.1, markdown-it-py 3.0.0). Without myst-parser, `--local-links` fails with a plain error. The site-build comment and `sites/README.md` say so.

## Checked

- **Against markdown-it:** on all 62 cases from the two oracles of #108's reviews (`mdit-oracle.py` and the organiser's 41), the rewrite makes exactly the links markdown-it renders as links. Those 62, and four more (table cells, a list item's next line, a blockquote, a directive in a list), are now a test: 66 cases, 21 of which fail on main's `tools/stage-site`.
- **On the pool** (at `4b0ab02`): dp's `--local-links` plan is the same 31 links in 13 lectures, byte for byte.
- **Tests:** 428 passed and 1 skipped, including the existing prose cases and a test for the missing-parser error. actionlint and pool-check are clean.

This PR's site build runs all six sites, since it touches `tools/stage-site`. No site sets `local_links`, so no page changes.

Copilot: not requested (Matt, 2026-11-22).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant