feat: cleanup with respect to core
Build, test, deploy / site (push) Failing after 1m37s

This commit is contained in:
alexm committed 2026-10-06 10:30:36 -04:00
1 parent e525f1d26f
commit ce45d30cc7
10 files changed
+22 -22

No files matched your search

+2 -2
View File
@@ -25,8 +25,8 @@ The site's suite takes under a minute. While iterating, build and run one file:
## Hard rules ## Hard rules
1. **A change to what programs mean belongs in core.** A translator, the checker, the interpreter, the prover, the fuzzer, the machine model, the catalog's problems, the Mojo corpus: change them in pplus-core under its rules (its own commit, its own gate), then move the `core` pointer here in a commit that says what it brings. Never edit `core/` from a site change without that. The site imports core only as `#core/<path>.js` (the import map in `index.html`, `imports` in `package.json`), from its built `core/dist/`. 1. **A change to what programs mean belongs in core.** A translator, the checker, the interpreter, the prover, the fuzzer, the machine model, the catalog's problems, the Mojo corpus: change them in pplus-core under its rules (its own commit, its own gate), then move the `core` pointer here in a commit that says what it brings. Never edit `core/` from a site change without that. The site imports core only as `#core/<path>.js` (the import map in `index.html`, `imports` in `package.json`), from its built `core/dist/`.
2. **Do not edit generated files by hand.** `quarto/_extensions/pplus/pplus-views.css` comes from `styles.css`, `pplus-hw.css` and `course/*.css` beside it from `styles/course/`, and `syntax/mojo.xml` from core's `core/syntax/mojo.xml` (`pixi run quarto-css`; a test fails while they are out of date, so run it after changing a rule the views use). Core's generated files are listed in its AGENTS.md. 2. **Do not edit generated files by hand.** `quarto/_extensions/pplus/pplus-views.css` comes from `styles.css`, `pplus-hw.css` and `course/*.css` beside it from `styles/course/`, and `syntax/mojo.xml` from core's `core/library/syntax/mojo.xml` (`pixi run quarto-css`; a test fails while they are out of date, so run it after changing a rule the views use). Core's generated files are listed in its AGENTS.md.
3. **Never claim Mojo compiles, runs, or prints something without the real compiler's answer.** Mojo is pinned to 1.1.0 by core. What the app shows about Mojo comes from core's checker and interpreter and from godbolt's answers (stored in `core/mojo/golden/`, or asked live by Compile & run); the site never invents a verdict, and every Mojo construct written into the app must pass `checkMojo`. 3. **Never claim Mojo compiles, runs, or prints something without the real compiler's answer.** Mojo is pinned to 1.1.0 by core. What the app shows about Mojo comes from core's checker and interpreter and from godbolt's answers (stored in `core/library/mojo/golden/`, or asked live by Compile & run); the site never invents a verdict, and every Mojo construct written into the app must pass `checkMojo`.
4. **Never show "proved" for something that is not a proof.** The badges and verdicts are in [core/docs/trust.md](core/docs/trust.md); the site shows what core decided and does not soften or upgrade it. 4. **Never show "proved" for something that is not a proof.** The badges and verdicts are in [core/docs/trust.md](core/docs/trust.md); the site shows what core decided and does not soften or upgrade it.
5. **No new dependencies.** TypeScript is the only npm package. There is no bundler, no framework, and no runtime dependency. CodeMirror is vendored as one built module (`src/vendor/`), rebuilt only by `scripts/vendor/codemirror.sh`. 5. **No new dependencies.** TypeScript is the only npm package. There is no bundler, no framework, and no runtime dependency. CodeMirror is vendored as one built module (`src/vendor/`), rebuilt only by `scripts/vendor/codemirror.sh`.
6. **You have no network** in most sandboxes. Godbolt (Compile & run) needs one, and so do core's network tasks. Never fake their results; leave those steps to the owner and list them. 6. **You have no network** in most sandboxes. Godbolt (Compile & run) needs one, and so do core's network tasks. Never fake their results; leave those steps to the owner and list them.
+1 -1
View File
@@ -43,7 +43,7 @@ Every command is a pixi task (`pixi task list` shows them with their description
| `test` | Build, then run every test of the site | | `test` | Build, then run every test of the site |
| `check-pages <dir>` | Run every program embedded in the Quarto pages under a folder ([quarto/README.md](quarto/README.md)) | | `check-pages <dir>` | Run every program embedded in the Quarto pages under a folder ([quarto/README.md](quarto/README.md)) |
| **Quarto** | | | **Quarto** | |
| `quarto-export <name> <dir>` | Copy a `core/mojo/local/` program, its x86-64 and setup beside a Quarto page, and print the shortcode | | `quarto-export <name> <dir>` | Copy a `core/library/mojo/local/` program, its x86-64 and setup beside a Quarto page, and print the shortcode |
| `quarto-css` | Regenerate the extension's generated files (a test fails while they are out of date) | | `quarto-css` | Regenerate the extension's generated files (a test fails while they are out of date) |
| `quarto-engine <dir>` | Copy a built Programming+ and core into a site's `_extensions/pplus/engine`, for the rendered views ([quarto/README.md](quarto/README.md)) | | `quarto-engine <dir>` | Copy a built Programming+ and core into a site's `_extensions/pplus/engine`, for the rendered views ([quarto/README.md](quarto/README.md)) |
| `quarto-example` | Render the example site in `quarto/example`, every shortcode on real pages (needs Quarto) | | `quarto-example` | Render the example site in `quarto/example`, every shortcode on real pages (needs Quarto) |
+4 -4
View File
@@ -70,7 +70,7 @@ A rule is `{ id, title, why, docUrl, example, apis, detect }`. The starting rule
- **Bridge:** the Best practices dock tab lists each finding with the Mojo line, the pseudo line it came from (the hub's line map), the reason, before and after, the manual link, and, where true, how to write the pseudo so the translator writes the better form. Clicking one lights both lines. The Mojo is read-only, so rewrites are shown, not applied. **Show idiomatic version** (in the Mojo tab, off until chosen) shows a copy with the safe rewrites applied, only if it passes the checker no worse than the literal one and the interpreter prints exactly what the literal one prints; it keeps the generated label ("Generated from pseudo, with N best-practice rewrites"). - **Bridge:** the Best practices dock tab lists each finding with the Mojo line, the pseudo line it came from (the hub's line map), the reason, before and after, the manual link, and, where true, how to write the pseudo so the translator writes the better form. Clicking one lights both lines. The Mojo is read-only, so rewrites are shown, not applied. **Show idiomatic version** (in the Mojo tab, off until chosen) shows a copy with the safe rewrites applied, only if it passes the checker no worse than the literal one and the interpreter prints exactly what the literal one prints; it keeps the generated label ("Generated from pseudo, with N best-practice rewrites").
- **Developer:** findings are `note` diagnostics with origin "best practices" (never an error or a warning, so they never look like the compiler) in Problems and the gutter, each with a one-click fix where the rewrite is safe. A rule that cannot promise a safe rewrite (`comptime`) explains and leaves the editing to the student. - **Developer:** findings are `note` diagnostics with origin "best practices" (never an error or a warning, so they never look like the compiler) in Problems and the gutter, each with a one-click fix where the rewrite is safe. A rule that cannot promise a safe rewrite (`comptime`) explains and leaves the editing to the student.
- **Tests** (`core/tests/practices.test.mjs`): every rule's example passes the checker, runs, and prints the same before and after, and the rule's fix turns one into the other; every method a rewrite names is in the harvested index; a false-positive gate runs the rules over Modular's own tested programs in `core/mojo/corpus/manual/` against a reviewed allowlist; each exercise's findings are pinned by a snapshot; applying every fix to each exercise's generated Mojo and each `core/mojo/local/` program keeps it checking and printing the same. - **Tests** (`core/tests/practices.test.mjs`): every rule's example passes the checker, runs, and prints the same before and after, and the rule's fix turns one into the other; every method a rewrite names is in the harvested index; a false-positive gate runs the rules over Modular's own tested programs in `core/library/mojo/corpus/manual/` against a reviewed allowlist; each exercise's findings are pinned by a snapshot; applying every fix to each exercise's generated Mojo and each `core/library/mojo/local/` program keeps it checking and printing the same.
### Saved versions ### Saved versions
@@ -123,7 +123,7 @@ The **Share** button in the app produces the app link, a ready-to-paste `<iframe
- **matho pane**: equations as a source language, written in LaTeX (`core/src/services/matho.ts`). One `FUNCTION` per equation; `\sum` and `\prod` become accumulator loops, subscripts become positions (with the 1-based shift when the sum starts at 1), `\begin{cases}` becomes `IF`/`ELSEIF`, Greek letters become names, references to earlier equations become calls hoisted out of loops when their arguments do not change. Every decision is a note on the equation's line; integrals, infinity, limits and derivatives are refused with the finite procedure to write instead. The trace steps the pseudo with the marker on the equation each step came from. - **matho pane**: equations as a source language, written in LaTeX (`core/src/services/matho.ts`). One `FUNCTION` per equation; `\sum` and `\prod` become accumulator loops, subscripts become positions (with the 1-based shift when the sum starts at 1), `\begin{cases}` becomes `IF`/`ELSEIF`, Greek letters become names, references to earlier equations become calls hoisted out of loops when their arguments do not change. Every decision is a note on the equation's line; integrals, infinity, limits and derivatives are refused with the finite procedure to write instead. The trace steps the pseudo with the marker on the equation each step came from.
- **Numerics**: `SUM_OF MEAN_OF VARIANCE_OF STDEV_OF MEDIAN_OF DOT NORM_OF FILL CHOOSE RANDN FLOOR CEIL LOG10 SIN COS TAN ATAN2 PI()`, and `PARALLEL FOR`, a loop whose passes may run at once, checked at run time: two passes touching one location stop the run with a data race that names the location and the passes. - **Numerics**: `SUM_OF MEAN_OF VARIANCE_OF STDEV_OF MEDIAN_OF DOT NORM_OF FILL CHOOSE RANDN FLOOR CEIL LOG10 SIN COS TAN ATAN2 PI()`, and `PARALLEL FOR`, a loop whose passes may run at once, checked at run time: two passes touching one location stop the run with a data race that names the location and the passes.
- **Mojo for every exercise with pseudo**: each has its Mojo in `core/mojo/local/`, so the Developer and Hardware areas always have something to show for it; `core/tests/mojo.test.mjs` runs each Mojo program in the interpreter and checks it prints what the exercise expects. - **Mojo for every exercise with pseudo**: each has its Mojo in `core/library/mojo/local/`, so the Developer and Hardware areas always have something to show for it; `core/tests/mojo.test.mjs` runs each Mojo program in the interpreter and checks it prints what the exercise expects.
- **Panes**: the area's own (see the table above), dimmed when empty (a dimmed tab opens an empty pane to write in), as tabs over one editor (CodeMirror: search and replace with Ctrl+F, go to line with Ctrl+G, bracket matching, undo and redo; Tab indents, Ctrl+/ comments). The editor is never split: in the Bridge a short note in the pane head says the other tabs update as you type (lingo and matho update the pseudo, and the pseudo the Mojo made from it), and clicking a line marks the lines it became in the next tab down; Hardware does the same between Mojo and x86-64. Drag the dividers to resize (double-click resets); the widths, the dock tab, and what is folded are remembered in the share link. - **Panes**: the area's own (see the table above), dimmed when empty (a dimmed tab opens an empty pane to write in), as tabs over one editor (CodeMirror: search and replace with Ctrl+F, go to line with Ctrl+G, bracket matching, undo and redo; Tab indents, Ctrl+/ comments). The editor is never split: in the Bridge a short note in the pane head says the other tabs update as you type (lingo and matho update the pseudo, and the pseudo the Mojo made from it), and clicking a line marks the lines it became in the next tab down; Hardware does the same between Mojo and x86-64. Drag the dividers to resize (double-click resets); the widths, the dock tab, and what is folded are remembered in the share link.
- **The side column** is the inspect panel. Its tabs are offered only when they mean something for the pane (Prove for the pseudo family) and dimmed, with the reason, when the run has nothing for them yet. - **The side column** is the inspect panel. Its tabs are offered only when they mean something for the pane (Prove for the pseudo family) and dimmed, with the reason, when the run has nothing for them yet.
- **The Run view** (the first tab, in the Bridge and the Developer area; `src/core/runview.ts`, drawn by `src/ui/views/run.ts`) is the whole run read top to bottom, one row per step: its number, its line, what ran (indented by call depth, with what it printed), and a column for each variable you **follow**, holding its value after that step: in color where the step wrote it (with the position, `[5, 6]`, when it wrote one element), faded where it carries over, underlined where the step reads it, hatched where it is not in scope. The lifecycle of the value a variable names (Mojo: made ●, copied ⧉, moved in ⇢, moved out ⇥, destroyed ✕) is marked in the same cell; events of values no column names are noted beside the step. Above the rows, the followed variables as they stand at the stepper's position, with a ruler for a string or list and a grid for a table, the element just written and the one about to be read marked. **+ variables** opens a picker of every variable in the run, by routine; until you choose, it follows the variables of the routine that does the most work. The choice is kept per area (`layout.follow`). "Only steps that change something" hides the rest. Click a row to step there; the stepper keeps its row in view. It replaces the Variables panel, the trace table, the table of values and the Lifetimes tab, which each showed part of this. - **The Run view** (the first tab, in the Bridge and the Developer area; `src/core/runview.ts`, drawn by `src/ui/views/run.ts`) is the whole run read top to bottom, one row per step: its number, its line, what ran (indented by call depth, with what it printed), and a column for each variable you **follow**, holding its value after that step: in color where the step wrote it (with the position, `[5, 6]`, when it wrote one element), faded where it carries over, underlined where the step reads it, hatched where it is not in scope. The lifecycle of the value a variable names (Mojo: made ●, copied ⧉, moved in ⇢, moved out ⇥, destroyed ✕) is marked in the same cell; events of values no column names are noted beside the step. Above the rows, the followed variables as they stand at the stepper's position, with a ruler for a string or list and a grid for a table, the element just written and the one about to be read marked. **+ variables** opens a picker of every variable in the run, by routine; until you choose, it follows the variables of the routine that does the most work. The choice is kept per area (`layout.follow`). "Only steps that change something" hides the rest. Click a row to step there; the stepper keeps its row in view. It replaces the Variables panel, the trace table, the table of values and the Lifetimes tab, which each showed part of this.
@@ -149,7 +149,7 @@ Pseudo is the hub: every other notation translates to or from it, so four langua
- It never invents Mojo. A line with no faithful spelling (a loop condition that would need such a loop, a built-in the standard library lacks) becomes `raise Error("not translated: pseudo line N")` and a `translate-gap` warning on the pseudo line; the program stops there instead of printing a plausible wrong answer. The pseudo's own mistakes (`unsupported`) are reported, not translated. - It never invents Mojo. A line with no faithful spelling (a loop condition that would need such a loop, a built-in the standard library lacks) becomes `raise Error("not translated: pseudo line N")` and a `translate-gap` warning on the pseudo line; the program stops there instead of printing a plausible wrong answer. The pseudo's own mistakes (`unsupported`) are reported, not translated.
- Two behaviors differ by design, and a literal translation keeps Mojo's: dividing a `FLOAT` by zero stops the notation but gives `nan` in Mojo, and `PARALLEL FOR` runs its passes in order with no race detector. Translation notes (`translate-divide`, `translate-each-order`, and so on) say so on the line. - Two behaviors differ by design, and a literal translation keeps Mojo's: dividing a `FLOAT` by zero stops the notation but gives `nan` in Mojo, and `PARALLEL FOR` runs its passes in order with no race detector. Translation notes (`translate-divide`, `translate-each-order`, and so on) say so on the line.
`core/tests/sync-mojo.test.mjs` holds the translation to the pseudo: for every exercise with pseudo and every program in `core/tests/corpus/`, the generated Mojo has no checker errors, runs in the interpreter, and prints what the pseudo prints (compared by value, not text: `TRUE` and `True`, `3` and `3.0`, a map's keys in any order). Programs it cannot hold to that are listed in the test with a reason (the interpreter declines `chr`, `ord`, random numbers and the math functions; the checker is right about the two programs that read an unset variable), and `AGREE_AT_LEAST` is a floor that can only rise. A snapshot of the generated Mojo for every exercise is in `core/tests/snapshots/sync-mojo/`; when a change to the translator is wanted, run the test with `UPDATE_SNAPSHOTS=1` and review the diff. `core/tests/sync-mojo.test.mjs` holds the translation to the pseudo: for every exercise with pseudo and every program in `core/library/pseudo/programs/`, the generated Mojo has no checker errors, runs in the interpreter, and prints what the pseudo prints (compared by value, not text: `TRUE` and `True`, `3` and `3.0`, a map's keys in any order). Programs it cannot hold to that are listed in the test with a reason (the interpreter declines `chr`, `ord`, random numbers and the math functions; the checker is right about the two programs that read an unset variable), and `AGREE_AT_LEAST` is a floor that can only rise. A snapshot of the generated Mojo for every exercise is in `core/tests/snapshots/sync-mojo/`; when a change to the translator is wanted, run the test with `UPDATE_SNAPSHOTS=1` and review the diff.
**pseudo → lingo** (`core/src/sync/pseudo-to-lingo.ts`) writes the English that the lingo reader (`readSteps` in the course engine's `english.js`) understands, so the lingo pane can follow the pseudo pane. The grammar belongs to the reader, and the translator is held to it: before returning, it reads its own output back and checks that the same routines come out with the same kinds of input. If English cannot say something the way the reader needs it, the result is `unsupported` with a warning on the pseudo line, and the pane keeps its last good text instead of showing English that does not read. **pseudo → lingo** (`core/src/sync/pseudo-to-lingo.ts`) writes the English that the lingo reader (`readSteps` in the course engine's `english.js`) understands, so the lingo pane can follow the pseudo pane. The grammar belongs to the reader, and the translator is held to it: before returning, it reads its own output back and checks that the same routines come out with the same kinds of input. If English cannot say something the way the reader needs it, the result is `unsupported` with a warning on the pseudo line, and the pane keeps its last good text instead of showing English that does not read.
@@ -193,7 +193,7 @@ Everything is pinned to **Mojo 1.1.0** and checked against the real compiler on
**Compile & run** (Ctrl+Enter on the Mojo pane) sends the program to godbolt.org in one request: the compiler's answer, the program's output (the input box feeds `input()`), and the listing. The **Compiler** view shows them. The compiler's messages land on their lines with its fix-its as one-click fixes (an implicit copy offers "transferring the value with '^'" or "copy it explicitly with '.copy()'"). The listing is grouped by function, your own first, in Intel syntax translated from godbolt's AT&T (or the original). **Send to x86-64 pane** puts one function, and the functions of yours it calls, on the model machine with its arguments' registers ready and the listing's read-only strings placed in memory; each call into the standard library becomes a stub that stops the run where the real program would enter the library, and says so. `core/docs/asm-coverage.md` is the census of every instruction compiled Mojo uses against what the machine models (everything but 256-bit AVX2), and `core/tests/asm-coverage.test.mjs` keeps it that way. Build "as written" (`-O0`, the default, which keeps every function you wrote) or "optimized" (what `mojo build` does: small functions fold into their callers). An edit after compiling marks the answer stale rather than showing it on the wrong lines. **Step through** runs the Mojo pane in Programming+'s own interpreter (`core/src/mojo/interp.ts`): line by line, with the variables it follows, what each line reads and writes, loop passes, breakpoints, and each value's lifetime, in the Run view. `core/tests/mojo-run.test.mjs` holds it to godbolt: on every program godbolt ran, it prints exactly what that run printed, or declines and says why. **Compile & run** (Ctrl+Enter on the Mojo pane) sends the program to godbolt.org in one request: the compiler's answer, the program's output (the input box feeds `input()`), and the listing. The **Compiler** view shows them. The compiler's messages land on their lines with its fix-its as one-click fixes (an implicit copy offers "transferring the value with '^'" or "copy it explicitly with '.copy()'"). The listing is grouped by function, your own first, in Intel syntax translated from godbolt's AT&T (or the original). **Send to x86-64 pane** puts one function, and the functions of yours it calls, on the model machine with its arguments' registers ready and the listing's read-only strings placed in memory; each call into the standard library becomes a stub that stops the run where the real program would enter the library, and says so. `core/docs/asm-coverage.md` is the census of every instruction compiled Mojo uses against what the machine models (everything but 256-bit AVX2), and `core/tests/asm-coverage.test.mjs` keeps it that way. Build "as written" (`-O0`, the default, which keeps every function you wrote) or "optimized" (what `mojo build` does: small functions fold into their callers). An edit after compiling marks the answer stale rather than showing it on the wrong lines. **Step through** runs the Mojo pane in Programming+'s own interpreter (`core/src/mojo/interp.ts`): line by line, with the variables it follows, what each line reads and writes, loop passes, breakpoints, and each value's lifetime, in the Run view. `core/tests/mojo-run.test.mjs` holds it to godbolt: on every program godbolt ran, it prints exactly what that run printed, or declines and says why.
**An exercise's Mojo** is a program in `core/mojo/local/`, named by the exercise's `mojoProgram`. `corpus.py verify` checks it on godbolt, and the pane's badge says "verified on Mojo 1.1.0" only when godbolt's answer passed the program's own expectation. **An exercise's Mojo** is a program in `core/library/mojo/local/`, named by the exercise's `mojoProgram`. `corpus.py verify` checks it on godbolt, and the pane's badge says "verified on Mojo 1.1.0" only when godbolt's answer passed the program's own expectation.
**The corpus** behind all of this (the compiler's own words, Modular's tested programs, our probes, and godbolt's stored answers) is described in [mojo-corpus.md](../core/docs/mojo-corpus.md). **The corpus** behind all of this (the compiler's own words, Modular's tested programs, our probes, and godbolt's stored answers) is described in [mojo-corpus.md](../core/docs/mojo-corpus.md).
+2 -2
View File
@@ -17,7 +17,7 @@ platforms = ["linux-64", "osx-arm64"]
version = "0.1.0" version = "0.1.0"
[dependencies] [dependencies]
mojo = "==1.1.0" # for the Quarto views that run a page's Mojo on a real compiler (core/mojo/pin.json) mojo = "==1.1.0" # for the Quarto views that run a page's Mojo on a real compiler (core/library/mojo/pin.json)
nodejs = ">=26.10.0,<26.11" # building core and the site, and the tests nodejs = ">=26.10.0,<26.11" # building core and the site, and the tests
python = ">=3.14.7,<3.15" # the dev server and the package script (standard library only) python = ">=3.14.7,<3.15" # the dev server and the package script (standard library only)
@@ -34,7 +34,7 @@ test = { cmd = "node --test tests/*.test.mjs", depends-on = ["build"], descripti
check-pages = { cmd = "node scripts/check-pages.mjs {{ dir }}", args = ["dir"], depends-on = ["build"], description = "Run every program embedded in the Quarto pages under <dir> (quarto/README.md)" } check-pages = { cmd = "node scripts/check-pages.mjs {{ dir }}", args = ["dir"], depends-on = ["build"], description = "Run every program embedded in the Quarto pages under <dir> (quarto/README.md)" }
# --- Quarto ------------------------------------------------------------------ # --- Quarto ------------------------------------------------------------------
quarto-export = { cmd = "node scripts/quarto-export.mjs {{ name }} {{ dir }}", args = ["name", "dir"], depends-on = ["build"], description = "Copy core/mojo/local/<name>.mojo, its x86-64 and setup beside a Quarto page, and print the shortcode" } quarto-export = { cmd = "node scripts/quarto-export.mjs {{ name }} {{ dir }}", args = ["name", "dir"], depends-on = ["build"], description = "Copy core/library/mojo/local/<name>.mojo, its x86-64 and setup beside a Quarto page, and print the shortcode" }
quarto-css = { cmd = "node scripts/quarto-css.mjs", depends-on = ["build"], description = "Regenerate the extension's generated files: pplus-views.css, pplus-hw.css, course/*.css and syntax/mojo.xml (from core)" } quarto-css = { cmd = "node scripts/quarto-css.mjs", depends-on = ["build"], description = "Regenerate the extension's generated files: pplus-views.css, pplus-hw.css, course/*.css and syntax/mojo.xml (from core)" }
quarto-engine = { cmd = "node scripts/quarto-engine.mjs {{ dir }}", args = ["dir"], depends-on = ["build"], description = "Copy a built Programming+ (and core) into a site's _extensions/pplus/engine, for the rendered views (quarto/README.md)" } quarto-engine = { cmd = "node scripts/quarto-engine.mjs {{ dir }}", args = ["dir"], depends-on = ["build"], description = "Copy a built Programming+ (and core) into a site's _extensions/pplus/engine, for the rendered views (quarto/README.md)" }
quarto-example = { cmd = "quarto render quarto", depends-on = ["build"], description = "Render the example site in quarto/example with every shortcode (needs Quarto on the PATH)" } quarto-example = { cmd = "quarto render quarto", depends-on = ["build"], description = "Render the example site in quarto/example with every shortcode (needs Quarto on the PATH)" }
+2 -2
View File
@@ -157,14 +157,14 @@ In a format other than HTML (a PDF, a Word file), a rendered view becomes Markdo
Or arrange it in the playground itself and paste the result: **Share** → *embed which view* → **Quarto** gives a `{{< pplus-playground state="…" >}}` or `{{< pplus-embed state="…" view="…" >}}` shortcode for exactly what you see, layout and step included. Or arrange it in the playground itself and paste the result: **Share** → *embed which view* → **Quarto** gives a `{{< pplus-playground state="…" >}}` or `{{< pplus-embed state="…" view="…" >}}` shortcode for exactly what you see, layout and step included.
### A Mojo program from `core/mojo/local/`, with its assembly ### A Mojo program from `core/library/mojo/local/`, with its assembly
```bash ```bash
pixi run --manifest-path core/pixi.toml play demo # verify it, and store the compiler's listing pixi run --manifest-path core/pixi.toml play demo # verify it, and store the compiler's listing
pixi run quarto-export demo ../site/programmingplus/demo pixi run quarto-export demo ../site/programmingplus/demo
``` ```
This writes `demo.mojo`, `demo.asm` (the x86-64 pane's program) and `demo.setup` next to the page, and prints the shortcode that embeds them. The `# origin:`/`# probe:`/... header of a `core/mojo/local/` file is left out of the pane and the listing. Its `# expect-stdout:` lines count as `EXPECT` lines. This writes `demo.mojo`, `demo.asm` (the x86-64 pane's program) and `demo.setup` next to the page, and prints the shortcode that embeds them. The `# origin:`/`# probe:`/... header of a `core/library/mojo/local/` file is left out of the pane and the listing. Its `# expect-stdout:` lines count as `EXPECT` lines.
## The machine ## The machine
+3 -3
View File
@@ -11,7 +11,7 @@
* dark (`body.quarto-dark`, or Bootstrap's `data-bs-theme="dark"`); the paper and ink follow the page's own. * dark (`body.quarto-dark`, or Bootstrap's `data-bs-theme="dark"`); the paper and ink follow the page's own.
* *
* It also copies the course's stylesheets for the machine views (course/*.css), writes pplus-hw.css from * It also copies the course's stylesheets for the machine views (course/*.css), writes pplus-hw.css from
* styles/course/bridge.css, and copies pplus-core's KDE syntax for Mojo (core/syntax/mojo.xml, which core's corpus * styles/course/bridge.css, and copies pplus-core's KDE syntax for Mojo (core/library/syntax/mojo.xml, which core's corpus
* pipeline writes) to syntax/mojo.xml, for the listings Pandoc highlights. * pipeline writes) to syntax/mojo.xml, for the listings Pandoc highlights.
* *
* node scripts/quarto-css.mjs --check exit 1 if a file is not what this would write * node scripts/quarto-css.mjs --check exit 1 if a file is not what this would write
@@ -38,7 +38,7 @@ for (const id of ['count-base', 'count-base-proved', 'match-off-by-one', 'five-b
const files = Object.fromEntries(Object.entries(p.sources).filter(([, v]) => typeof v === 'string' && v.trim())); const files = Object.fromEntries(Object.entries(p.sources).filter(([, v]) => typeof v === 'string' && v.trim()));
for (const lang of Object.keys(files)) samples.push({ files, lang, call: p.call ?? null, setup: p.setup, machine: p.machine }); for (const lang of Object.keys(files)) samples.push({ files, lang, call: p.call ?? null, setup: p.setup, machine: p.machine });
} }
samples.push({ files: { mojo: fs.readFileSync(path.join(ROOT, 'core/mojo/stress/lifecycle-moves.mojo'), 'utf8') }, lang: 'mojo' }); samples.push({ files: { mojo: fs.readFileSync(path.join(ROOT, 'core/library/mojo/stress/lifecycle-moves.mojo'), 'utf8') }, lang: 'mojo' });
const used = new Set(); const used = new Set();
for (const s of samples) for (const view of STATIC_VIEWS.filter((v) => v !== 'hw')) { for (const s of samples) for (const view of STATIC_VIEWS.filter((v) => v !== 'hw')) {
let html = ''; let html = '';
@@ -148,7 +148,7 @@ outputs.push([path.join(EXT, 'pplus-hw.css'), `/* pplus-hw.css: GENERATED by \`p
page already has the colors and fonts those files read (--bs-body-bg, --bs-body-color, body.quarto-dark). */ page already has the colors and fonts those files read (--bs-body-bg, --bs-body-color, body.quarto-dark). */
${afterRoot}`]); ${afterRoot}`]);
outputs.push([path.join(EXT, 'syntax', 'mojo.xml'), fs.readFileSync(path.join(ROOT, 'core/syntax/mojo.xml'), 'utf8')]); outputs.push([path.join(EXT, 'syntax', 'mojo.xml'), fs.readFileSync(path.join(ROOT, 'core/library/syntax/mojo.xml'), 'utf8')]);
if (process.argv.includes('--check')) { if (process.argv.includes('--check')) {
const stale = outputs.filter(([file, want]) => !fs.existsSync(file) || fs.readFileSync(file, 'utf8') !== want).map(([file]) => path.relative(ROOT, file)); const stale = outputs.filter(([file, want]) => !fs.existsSync(file) || fs.readFileSync(file, 'utf8') !== want).map(([file]) => path.relative(ROOT, file));
+2 -2
View File
@@ -23,8 +23,8 @@ const [name, outDir] = process.argv.slice(2).filter((a) => !a.startsWith('--'));
const die = (m) => { console.error(`quarto:export: ${m}`); process.exit(1); }; const die = (m) => { console.error(`quarto:export: ${m}`); process.exit(1); };
if (!name || !outDir) die('usage: pixi run quarto-export <program in mojo/local/> <folder beside the .qmd page>'); if (!name || !outDir) die('usage: pixi run quarto-export <program in mojo/local/> <folder beside the .qmd page>');
const src = path.join(ROOT, 'core/mojo/local', `${name}.mojo`); const src = path.join(ROOT, 'core/library/mojo/local', `${name}.mojo`);
if (!fs.existsSync(src)) die(`core/mojo/local/${name}.mojo does not exist`); if (!fs.existsSync(src)) die(`core/library/mojo/local/${name}.mojo does not exist`);
const listingsJs = path.join(ROOT, 'core/dist/mojo/generated/listings.js'); const listingsJs = path.join(ROOT, 'core/dist/mojo/generated/listings.js');
if (!fs.existsSync(listingsJs)) die('core/dist/ is missing; run `pixi run build` first'); if (!fs.existsSync(listingsJs)) die('core/dist/ is missing; run `pixi run build` first');
const { MOJO_LISTINGS } = await import(pathToFileURL(listingsJs).href); const { MOJO_LISTINGS } = await import(pathToFileURL(listingsJs).href);
+3 -3
View File
@@ -191,10 +191,10 @@ test('Mojo beside x86-64: the line table the compiler left in the pane links eac
// a real listing, as Open in Hardware makes it from godbolt's saved answer // a real listing, as Open in Hardware makes it from godbolt's saved answer
const ROOT = new URL('..', import.meta.url).pathname; const ROOT = new URL('..', import.meta.url).pathname;
let checked = 0; let checked = 0;
for (const f of fs.readdirSync(ROOT + 'core/mojo/probes').filter((x) => x.endsWith('.mojo'))) { for (const f of fs.readdirSync(ROOT + 'core/library/mojo/probes').filter((x) => x.endsWith('.mojo'))) {
const text = fs.readFileSync(ROOT + 'core/mojo/probes/' + f, 'utf8'); const text = fs.readFileSync(ROOT + 'core/library/mojo/probes/' + f, 'utf8');
if (!/^# mode: (asm|both)/m.test(text)) continue; if (!/^# mode: (asm|both)/m.test(text)) continue;
const r = buildListing(text, ROOT + 'core/mojo/golden', { forSimulator, simulatorSetup, listingFunctions }); const r = buildListing(text, ROOT + 'core/library/mojo/golden', { forSimulator, simulatorSetup, listingFunctions });
if (r.why) continue; if (r.why) continue;
const table = asmMojoLines(r.asm); const table = asmMojoLines(r.asm);
if (!table.size) continue; if (!table.size) continue;
+2 -2
View File
@@ -6,8 +6,8 @@ import { normalize } from '../dist/core/state.js';
import { Session } from '../dist/core/session.js'; import { Session } from '../dist/core/session.js';
// godbolt's stored answers, in pplus-core // godbolt's stored answers, in pplus-core
const goldens = fs.readdirSync(new URL('../core/mojo/golden/', import.meta.url)).filter((f) => /^[0-9a-f]{64}\.json$/.test(f)) const goldens = fs.readdirSync(new URL('../core/library/mojo/golden/', import.meta.url)).filter((f) => /^[0-9a-f]{64}\.json$/.test(f))
.map((f) => JSON.parse(fs.readFileSync(new URL(`../core/mojo/golden/${f}`, import.meta.url), 'utf8'))); .map((f) => JSON.parse(fs.readFileSync(new URL(`../core/library/mojo/golden/${f}`, import.meta.url), 'utf8')));
test('the session keeps each answer with the source it answered, and says when it is stale', async () => { test('the session keeps each answer with the source it answered, and says when it is stale', async () => {
const s = new Session(normalize({ v: 3, lang: 'mojo', sources: { mojo: 'fn main():\n print(1)\n' } })); const s = new Session(normalize({ v: 3, lang: 'mojo', sources: { mojo: 'fn main():\n print(1)\n' } }));
+1 -1
View File
@@ -121,7 +121,7 @@ test('every rendered view draws for a program that has what it needs, with the a
assert.match(tests.html, /way of failing/); assert.match(tests.html, /way of failing/);
const machine = renderStatic({ view: 'machine', files: { asm: problemById('asm-two-pointers').sources.asm }, setup: problemById('asm-two-pointers').setup }); const machine = renderStatic({ view: 'machine', files: { asm: problemById('asm-two-pointers').sources.asm }, setup: problemById('asm-two-pointers').setup });
assert.match(machine.markdown, /\| instructions \| \d+ \|/); assert.match(machine.markdown, /\| instructions \| \d+ \|/);
const life = renderStatic({ view: 'life', files: { mojo: fs.readFileSync(ROOT + 'core/mojo/stress/lifecycle-moves.mojo', 'utf8') } }); const life = renderStatic({ view: 'life', files: { mojo: fs.readFileSync(ROOT + 'core/library/mojo/stress/lifecycle-moves.mojo', 'utf8') } });
assert.ok((life.html.match(/life-row/g) ?? []).length >= 3); assert.ok((life.html.match(/life-row/g) ?? []).length >= 3);
assert.doesNotMatch(life.html, /Click a mark/, 'a page has no stepper to move'); assert.doesNotMatch(life.html, /Click a mark/, 'a page has no stepper to move');
assert.equal(STATIC_VIEWS.length, 12); assert.equal(STATIC_VIEWS.length, 12);