Skip to content

Implement with doc and with repl (§18.5) #537

Closed

Description

@ehartford

Summary

The CLI recognizes with doc and with repl, but both commands are explicit self-hosted compiler stubs. The spec lists both as stable toolchain commands, so each needs a real implementation or a deliberately scoped first milestone.

Spec

docs/with-specification.md:9608-9624 lists with doc [--open] and with repl as commands provided by the single with binary.

Current state

src/main.w:731-736 handles repl and doc by printing not yet available in self-hosted compiler errors and returning exit code 1. src/main.w:2485-2511 also omits both commands from the general usage output.

Implementation plan

  1. Split the work into two independently shippable command implementations.
  2. For with doc:
    • parse with doc [--open] and optional project/source selection,
    • reuse parser/sema metadata to collect public modules, declarations, signatures, doc comments, and links,
    • emit deterministic HTML or markdown into out/doc or a documented default,
    • make --open best-effort only after successful generation.
  3. For with repl:
    • start with a line-oriented interactive loop that parses and typechecks snippets through the normal compiler pipeline,
    • keep state for previous bindings where feasible, or fail loudly for unsupported persistent-state cases,
    • avoid introducing a separate mini-language or interpreter semantics that diverge from compiled With.
  4. Update help text and the inventory gate from Add the spec inventory gate (keywords/attributes/CLI/modules vs spec tables) #410 once behavior exists.

Test plan

  • Add CLI tests that with doc --help and with repl --help succeed once help is defined.
  • Add a deterministic with doc smoke test for a tiny project with one public declaration and one private declaration.
  • Add a REPL smoke test using piped input if the command supports non-interactive stdin; otherwise add a lower-level test for the REPL evaluator/session component.
  • Add negative tests for unsupported doc/repl inputs that must fail loudly and specifically.

Acceptance criteria

  • with doc and with repl are no longer placeholder commands.
  • Help text lists both commands consistently with the spec.
  • Unsupported subfeatures fail loudly with actionable diagnostics.
  • with build, with build :fixpoint, with build :test, and with build :test-green pass before this issue is closed.

Dependencies

Related to #410 for keeping the CLI command inventory synchronized with the spec.

Traceability

From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 18.5.1.1.

Activity

  1. ehartford commented on Jun 11, 2026

    @ehartford
    ContributorAuthor

    Implemented in a17be5a. Added real with doc and with repl commands: docs generate deterministic Markdown for public functions/types across reachable project modules using compiler metadata and doc comments; repl runs accepted line snippets through the normal compile/link/run pipeline and rejects unsupported persistent declarations loudly. Added CLI self-host coverage for doc/repl help, doc public/private filtering including imported project modules, missing doc source diagnostics, repl smoke input, and repl persistent-declaration diagnostics. Verification passed: WITH=$PWD/out/bin/with ./out/bin/with build, WITH=$PWD/out/bin/with ./out/release/bin/with build :fixpoint, WITH=$PWD/out/bin/with ./out/release/bin/with build :test, and WITH=$PWD/out/bin/with ./out/release/bin/with build :test-green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions