Skip to content

docs: every block that shows output now produces it - #35

Open
sotashimozono wants to merge 2 commits into
mainfrom
docs/every-shown-output-is-executed
Open

docs: every block that shows output now produces it#35
sotashimozono wants to merge 2 commits into
mainfrom
docs/every-shown-output-is-executed

Conversation

@sotashimozono

Copy link
Copy Markdown
Member

Measured before touching anything: 33 fenced ```julia blocks across docs/src, of which 12
displayed output typed by hand
. Those 12 are the ones that can be wrong — and three of them were.

All 12 now execute (@setup fixtures plus @repl/@example), and the build fails if their output
stops matching.

before after
blocks showing typed output 12 0
```julia 33 20 (input-only)
```@example / ```@repl / ```@setup 16 / 0 / 0 22 / 7 / 7

What executing them found

@experimental "why" Base.sum(x::Int) = x is documented as refused. It is accepted. Method
marks on another module's generic landed in #13 and this page was never revisited. The refusal
example is now one that is still refused — a bare Sub.g — rendered from the real message:

ArgumentError: @experimental: `Sub.g` names another module's generic without saying WHICH
method — mark the definition instead: @experimental "why" Sub.g(::MyType) = …

…and the accepted-forms list gains the foreign-method case, with the note that it is reported by
contributed_methods rather than by the name audit.

mark(Archeion, :ingest) was shown without its signature: line, which the real display has.

The entered() transcript carried a reason for not being executable — "Documenter evaluates
doctests in a sandbox whose module does not print as Main". Measured: an @repl block renders
Main.MyModel.energy, so the reason no longer holds. It is now entered(MyModel), asked about a
module because the process-wide answer includes every fixture the documentation built.

Two blocks now show what a docs build genuinely gets

…and say so, rather than showing what a user would get:

  • record's timings are missing — a documentation build does not load Profile
  • coverage(...) is missing — it has no --code-coverage counters

Both are the documented contract, demonstrated instead of described.

Also record(; paths = false) on the observing page: a captured path is the whole call stack, and
in a docs build that starts at _start and runs through makedocs.

1253 assertions, green; docs build clean.

🤖 Generated with Claude Code

Measured: 33 fenced ```julia blocks across `docs/src`, of which **12 displayed output that had
been typed by hand**. Those 12 are the ones that can be wrong, and three of them were.

All 12 now execute — `@setup` fixtures plus `@repl`/`@example` — and the build fails if their
output stops matching. Typed-output blocks remaining: 0.

What executing them found:

  * `@experimental "why" Base.sum(x::Int) = x` is documented as REFUSED. It is accepted: method
    marks on another module's generic landed in #13, and the page was never revisited. The
    refusal example is now one that is still refused (a bare `Sub.g`), rendered from the real
    message, and the accepted-forms list gains the foreign-method case with the note that it is
    reported by `contributed_methods` rather than by the name audit.
  * `mark(Archeion, :ingest)` was shown without its `signature:` line, which the real display has.
  * The `entered()` transcript carried a reason for not being executable — "Documenter evaluates
    doctests in a sandbox whose module does not print as `Main`". Measured: an `@repl` block shows
    `Main.MyModel.energy`, so the reason no longer holds. It is now `entered(MyModel)`, asked about
    a module because the process-wide answer includes every fixture the documentation built.

Two blocks show what a documentation build genuinely gets rather than what a user would, and say
so: `record`'s timings are `missing` because a docs build does not load `Profile`, and
`coverage(...)` is `missing` because it has no `--code-coverage` counters. Both are the documented
contract, now demonstrated instead of described.

`record(; paths = false)` on the observing page: a captured path is the whole call stack, and in a
docs build that starts at `_start` and runs through `makedocs`.

1253 assertions, green; docs build clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

📚 Docs preview: https://codes.sota-shimozono.com/ExperimentalAPI.jl/previews/PR35/

(updates on each push to this PR)

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…y the macro

The walkthrough showed

    value = ExperimentalAPI.@entered Ising.report(βs)
    -1.8886

— the value, and nothing else. The report is the whole of what `@entered` is for.

Not the macro. `IOCapture`, which is what Documenter captures with, sees it:

    captured output = "┌ @entered S.f(1.0)   at cap.jl:8\n│   Main.S.f  ×1 — r\n└ 0 of 1 …\n"
    value           = 2.0

Measured on a minimal Documenter site, with the control that settles it:

    block                                   value    rendered
    @entered S.f(1.0)                       2.0      2.0
    println("plain println"); 99            99       99          ← the println is lost too
    println("plain println only")           nothing  plain println only

An `@example` renders the block's value when it has one and its captured output only when the
value is `nothing`. A plain `println` followed by a non-`nothing` value loses its line exactly the
same way, which is what says this is Documenter and not us.

So the walkthrough uses `@entered <io> expr` and prints the buffer — the form `observing.md`
already used for the same reason — and the page now says why, with the control, and adds that a
reader at a terminal writes the plain form. All three `@entered` blocks in the built docs now
carry their report.

1250 assertions, green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant