Skip to content

Commit 80ebeb9

Browse files
committed
Update docs after Markdown migration
1 parent 0a007f1 commit 80ebeb9

6 files changed

Lines changed: 38 additions & 22 deletions

File tree

.github/workflows/verify.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
cat /tmp/pythonbyexample-ci.log
3232
exit 1
3333
- name: Verify
34+
env:
35+
CHROME_PATH: /usr/bin/google-chrome
3436
run: |
3537
make verify
3638
scripts/check_example_migration_parity.py

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.1.0
1919
- Versioned Worker Cache API keys for rendered HTML.
2020
- `README.md` architecture, verification, deployment, and cache-busting documentation.
2121
- `docs/lessons-learned.md`.
22+
- Markdown-backed example sources with `:::program` and `:::cell` blocks.
23+
- Example source verifier, formatter, embedded-source build step, and golden parity check.
24+
- GitHub Actions verification workflow.
2225

2326
### Changed
2427

2528
- Example walkthroughs now pair prose, source fragments, and output evidence.
2629
- Read-only code highlighting is handled by Shiki; editable code highlighting is handled by CodeMirror.
2730
- Prototype routes under `/layout-options/*` bypass the Worker Cache API and return `Cache-Control: no-store`.
2831
- Static assets use immutable cache headers only on fingerprinted filenames.
29-
- Deployment flow now regenerates asset fingerprints first.
32+
- Deployment flow now regenerates embedded example data and asset fingerprints first.
33+
- `src/examples.py` is now a compatibility shim over Markdown example sources.
3034
- Output panels reserve space for execution timing to prevent layout shift after runs.
3135

3236
### Fixed

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,20 @@ http://localhost:9696
7777

7878
## Verification
7979

80-
Run the main checks before deploying or pushing:
80+
Run a local Worker before the full browser-backed verification:
81+
82+
```bash
83+
uv run --group workers pywrangler dev --port 9696
84+
```
85+
86+
Then run the main checks before deploying or pushing:
8187

8288
```bash
8389
make verify
8490
scripts/check_example_migration_parity.py
8591
scripts/format_examples.py --check
8692
make verify-python-version VERSION=3.13
93+
git diff --check
8794
```
8895

8996
`make seo-cache-lint` verifies that:
@@ -138,19 +145,14 @@ Prototype layout routes under `/layout-options/*` bypass the Worker Cache API an
138145
Run checks, then deploy:
139146

140147
```bash
141-
scripts/fingerprint_assets.py
142-
make test
143-
make seo-cache-lint
144-
make browser-layout-test
145-
uv run pywrangler deploy
146-
```
147-
148-
or:
149-
150-
```bash
148+
make verify
149+
scripts/check_example_migration_parity.py
150+
scripts/format_examples.py --check
151151
make deploy
152152
```
153153

154+
`make deploy` runs `make build` first, so embedded example data and cache fingerprints are regenerated before Wrangler deploys.
155+
154156
## Updating examples or Python version
155157

156158
Edit Markdown files under `src/example_sources/`.
@@ -169,6 +171,7 @@ make build
169171
make verify-examples
170172
scripts/format_examples.py --check
171173
scripts/check_example_migration_parity.py
174+
make check-generated
172175
```
173176

174177
`src/example_sources_data.py` is generated and committed so Cloudflare Workers can load examples in production. Do not edit it by hand.

docs/example-source-format-spec.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ Investigation and verification tasks come first because they decide the implemen
140140
- [ ] Smoke-test `https://www.pythonbyexample.dev`.
141141
- [ ] Smoke-test `https://pythonbyexample.adewale-883.workers.dev`.
142142
- [ ] Verify production asset caching and HTML cache-busting after an example-only edit.
143-
- [ ] Remove old hand-authored example catalog only after one successful production deployment.
144-
- [ ] Remove temporary golden parity scaffolding after cleanup is complete.
143+
- [ ] Keep the frozen golden fixture through at least one stable production release cycle and rollback window.
144+
- [ ] Remove temporary golden parity scaffolding only in a dedicated cleanup PR after CI and production confidence are established.
145145
- [ ] Update README contributor instructions to point contributors at Markdown examples, `make build`, and `make verify-examples`.
146146

147147
## Implementation milestones
@@ -151,7 +151,7 @@ This migration must not be implemented as one large switch-over.
151151
1. **Tooling-only milestone** — add Markdown sources, canonical loader, build scripts, verifier, formatter, and golden parity checks while the live app still imports `src/examples.py`.
152152
2. **Dual-read milestone** — allow tests to load both `src/examples.py` and Markdown examples; keep `src/examples.py` as the public catalog until parity is clean.
153153
3. **App switch milestone** — switch `src/examples.py` to a thin compatibility layer over the Markdown loader only after local Worker startup, browser layout checks, and 100% golden parity pass.
154-
4. **Cleanup milestone** — remove the old hand-authored catalog and golden fixture only after one successful deploy and smoke test on both `www.pythonbyexample.dev` and the `workers.dev` hostname.
154+
4. **Cleanup milestone** — remove the old hand-authored catalog immediately after the app switch, but keep the golden fixture until a stable production release cycle, rollback window, and dedicated cleanup PR.
155155

156156
Each milestone should be independently reviewable and revertible.
157157

docs/lessons-learned.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ This document records project lessons that should guide future changes to Python
3434
- Avoid decorative labels that do not teach. Labels such as `Cell 1 · <<fragment-1>>` add noise unless the fragment name is meaningful to the learner.
3535
- If a source fragment only prepares state and has no output, merge it with the next fragment that produces output. Every displayed cell should have evidence.
3636
- Keep the complete editable program visible because it is the thing that actually runs.
37+
- When storing examples as Markdown, keep the full editable program in `:::program` and teaching fragments in separate `:::cell` blocks. Do not concatenate cells to recreate the editor source.
38+
- Fine-grained cells can restate definitions to stay executable. This is better than collapsing class, property, recursion, match, or type-hint examples into one large cell.
39+
- Preserve a frozen golden catalog while migrating source formats. Full stdout parity is not enough; rendered teaching-cell structure must also match.
3740

3841
## Layout and mobile
3942

@@ -47,16 +50,18 @@ This document records project lessons that should guide future changes to Python
4750
- Unit tests are good for catalog integrity, rendering contracts, Dynamic Worker code generation, and cache-policy source checks.
4851
- Browser tests are necessary for Shiki/CodeMirror layout behavior and visual regressions.
4952
- SEO and cache-busting deserve a dedicated linter because errors are easy to reintroduce when adding pages or assets.
50-
- Always run the full pre-push set before publishing:
53+
- Always run the full pre-push set before publishing. Start `pywrangler dev --port 9696`, then run:
5154

5255
```bash
53-
make fingerprint
54-
make test
55-
make seo-cache-lint
56-
make browser-layout-test
57-
make lint
56+
make verify
57+
scripts/check_example_migration_parity.py
58+
scripts/format_examples.py --check
59+
make verify-python-version VERSION=3.13
60+
git diff --check
5861
```
5962

63+
- `make check-generated` should fail if embedded example data, asset manifests, or cache headers are stale.
64+
6065
## Documentation and GitHub readiness
6166

6267
- Keep generated runtime directories out of Git: `.wrangler/`, `.venv/`, `.venv-workers/`, and `python_modules/`.

scripts/check_browser_layout.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { mkdtemp, rm } from 'node:fs/promises';
44
import { tmpdir } from 'node:os';
55
import path from 'node:path';
66

7-
const chromePath = process.env.CHROME_PATH || '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
7+
const chromePath = process.env.CHROME_PATH || (process.platform === 'darwin'
8+
? '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
9+
: '/usr/bin/google-chrome');
810
const target = process.argv[2] || 'http://127.0.0.1:9696/layout-options/mobile-run-first';
911
const url = `${target}${target.includes('?') ? '&' : '?'}browser_layout_check=${Date.now()}`;
1012
const port = 9333 + Math.floor(Math.random() * 1000);

0 commit comments

Comments
 (0)