# Expanding \`@repl\` blocks in REPL and Jupyter

**URL:** https://discourse.julialang.org/t/expanding-repl-blocks-in-repl-and-jupyter/105288
**Category:** General Usage
**Tags:** question, documentation, documenter, repl
**Created:** [October 22, 2023, 6:24pm UTC](https://discourse.julialang.org/t/expanding-repl-blocks-in-repl-and-jupyter/105288 "2023-10-22T18:24:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![gdmsl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdmsl/32/2876_2.png) [@gdmsl](https://discourse.julialang.org/u/gdmsl)
#### Post date: [October 22, 2023, 6:24pm UTC](https://discourse.julialang.org/t/expanding-repl-blocks-in-repl-and-jupyter/105288/1 "2023-10-22T18:24:52Z")

</div>

While writing documentation, I am making large use of the `@repl` blocks with Documenter.jl. However, it seems that these blocks are not expanded automatically in the REPL or in Jupyter.

Is there a way to expand the `@repl` blocks in the REPL, when accessing the documentation with `?` ?

---

<div class="post-metadata">

### Author: ![mortenpi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mortenpi/32/158_2.png) [@mortenpi](https://discourse.julialang.org/u/mortenpi)
#### Post date: [October 24, 2023, 3:37am UTC](https://discourse.julialang.org/t/expanding-repl-blocks-in-repl-and-jupyter/105288/2 "2023-10-24T03:37:53Z")

</div>

Nope. The evaluation of at-repl blocks is provided by Documenter, so base Julia doesn’t know anything about them. Also, note that Documenter does not evaluate at-repl blocks that are in docstrings either (just the ones on Markdown pages).

_Theoretically_, one could implement some sort of [DocStringExtensions](https://github.com/JuliaDocs/DocStringExtensions.jl)-like approach for this. But this requires the code to actually be evaluated when you pull up docstrings, and that can be expensive, and I feel that this will likely be a footgun, often leading to bad UX.

Instead, you should use [doctests](https://documenter.juliadocs.org/stable/man/doctests/) for this. Documenter can help you keep them up to date.

---

<div class="post-metadata">

### Author: ![gdmsl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdmsl/32/2876_2.png) [@gdmsl](https://discourse.julialang.org/u/gdmsl)
#### Post date: [October 24, 2023, 9:00am UTC](https://discourse.julialang.org/t/expanding-repl-blocks-in-repl-and-jupyter/105288/3 "2023-10-24T09:00:17Z")

</div>

Thanks! Yeah, I feared so. Manually updating a bunch of `jldoctests` felt painful. I didn’t know that you could have Documenter to [fix them automatically](https://documenter.juliadocs.org/stable/man/doctests/#Fixing-Outdated-Doctests), thanks!

---

<div class="post-metadata">

### Author: ![mortenpi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mortenpi/32/158_2.png) [@mortenpi](https://discourse.julialang.org/u/mortenpi)
#### Post date: [October 24, 2023, 9:26am UTC](https://discourse.julialang.org/t/expanding-repl-blocks-in-repl-and-jupyter/105288/4 "2023-10-24T09:26:48Z")

</div>

Yep. For new doctests, my strategy sometimes is to just write something like

````julia
```jldoctest
julia> foo()

julia> bar()

```

````

commit that (in case doctest fixing messes it up somehow), and then run the doctest fixing functionality on them, to populate the outputs.
