Conversation
5 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #2282 +/- ##
=======================================
Coverage 50.91% 50.92%
=======================================
Files 300 300
Lines 39867 39867
=======================================
+ Hits 20300 20302 +2
+ Misses 19567 19565 -2
🚀 New features to boost your workflow:
|
1a582d0 to
0f0a2ba
Compare
Replaces the earlier draft slide commands (slide-info, slide-prettify,
slide-update, slide-suppress-warnings) with a smaller surface focused on
the plaintext representation:
- `hazel slide-list` prints the names of every slide statically linked
into the binary (the docs under `src/web/init/docs/` plus `B2t2.Slides`).
- `hazel slide-decode <name>` looks up a slide by name and prints its
program as plaintext. Manual refractors are rendered with
`^^probe(...)` / `^^statics(...)` trigger syntax so the output is
reparseable.
- `hazel slide-encode --title T <text-or-->` builds a slide `.ml` from a
title and plaintext program, emitting the `let out : ...
PersistentSegment.t` module form. Refractors written with trigger
syntax in the input are rebuilt by the parser's Triggers module on
insertion.
Other transformations (prettify, suppress unused-var warnings, static
analysis) are no longer slide-specific - they now compose with the
existing `hazel format` / `hazel analyze` commands on plaintext, e.g.
./hazel slide-decode "Probes" \
| ./hazel format -w 60 - \
| ./hazel slide-encode --title "Probes" - -o src/web/init/docs/Probes.ml
Supporting changes:
- `hazel format` now parses to a zipper and threads `z.refractors.manuals`
through `Printer.of_segment`, so `^^probe(...)` / `^^statics(...)`
trigger syntax survives the pretty-print round-trip.
- `hazel analyze` gains `-W` / `--warnings` to also report warnings (e.g.
unused variables) alongside errors, with the same Rust-style source
context. README correspondingly updated.
- `src/web/init/Init.re` extracts `documentation_slides : list((string,
PersistentSegment.t))` as a top-level binding so the CLI can look up
slides by name without re-reading the on-disk `.ml` source files.
- `src/CLI/Slide.re` shrinks accordingly: the OCaml string-literal
scanner is gone; only the in-binary lookup and the `.ml` emitter
remain.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds three small
hazelCLI subcommands for working with the documentation slides linked into the binary (thelet out : ... PersistentSegment.tmodules undersrc/web/init/docs/andsrc/b2t2/slides/), plus two supporting tweaks toformatandanalyzeand a small CLI refactor.The design is deliberately minimal: slides are addressed by name, not by
.mlfile path, and the only slide-specific operations exposed aredecode(slide → plaintext) andencode(plaintext → slide). Every other transformation (prettify, suppress unused-var warnings, static analysis) is done generically on the plaintext via the existingformatandanalyzecommands.Note
This is intended as a stopgap. Once #1487 ("Build step for building Init.ml editors") lands — replacing the serialized
let out : ... PersistentSegment.tmodules with plain-text slide files compiled intoInit.mlat build time — these commands will likely be obviated or need to be reworked. At that pointslide-decodecollapses tocat,slide-encodecollapses to writing the plain-text file, and only the trigger-syntax round-tripping (which would presumably move into whatever textual syntax #1487 adopts for projectors/refractors) carries over.New slide commands
hazel slide-list— print the names of every slide statically linked into the binary.hazel slide-decode <NAME>— look up a slide by name and print its program as plaintext. Manual refractors are rendered with^^probe(...)/^^statics(...)trigger syntax so the output is reparseable.hazel slide-encode --title T <TEXT-or-->— build a slide.mlfrom a title and plaintext program, emitting thelet out : ... PersistentSegment.tmodule form. Use-oto write to a file (otherwise stdout). Refractors written with trigger syntax in the input are rebuilt by the parser'sTriggersmodule on insertion.The slides are looked up out of
Web.Init.documentation_slides : list((string, PersistentSegment.t)), a new top-level binding extracted from the existing inline list inInit.re. No on-disk.mlparsing is needed.Supporting changes
hazel formatnow preserves refractors. It parses to a zipper instead of just a segment and threadsz.refractors.manualsthroughPrinter.of_segment, so^^probe(...)/^^statics(...)trigger syntax survives the pretty-print round-trip.hazel analyzegains-W/--warnings. When set, warnings (currently just unused variables) are reported alongside errors using the same Rust-style source context.src/CLI/Diagnostic.re. Shared byanalyze's error and warning paths; replaces ~140 lines of duplicated formatting inCli.rewith one helper plus two ~15-line wrappers.src/CLI/README.mdupdated for the new commands, the--warningsflag, the correctedformat/analyzebehavior (the README had stale claims about both lacking source locations / preserving comments), and a note recommendingNODE_OPTIONS="--max-old-space-size=4096"foranalyzeon larger inputs.How they compose
A slide-level pretty-print is now just three commands piped together:
The same shape (
decode → transform → encode) covers every workflow the earlier draft hard-coded into bespokeslide-prettify/slide-update/slide-suppress-warningssubcommands.Test plan
make devbuilds cleanly./hazel slide-listprints all expected names (BasicReference, Probes, etc., plus b2t2 entries)./hazel slide-decode "Probes"emits plaintext with^^probe(...)markers intact./hazel slide-decode "Probes" | ./hazel format -w 60 -preserves refractor countdecode | format | encoderound-trip produces a slide.mlwhose re-decode matches refractor count (verified across all 50 docs+b2t2 slides)./hazel analyze -Won a program with an unused let-binding prints awarning: unused variable: <name>diagnostic with location🤖 Generated with Claude Code