# Doctests don't appear in REPL help mode

**URL:** https://discourse.julialang.org/t/doctests-dont-appear-in-repl-help-mode/98534
**Category:** General Usage
**Tags:** documentation, documenter, repl, doctest
**Created:** [May 9, 2023, 7:40am UTC](https://discourse.julialang.org/t/doctests-dont-appear-in-repl-help-mode/98534 "2023-05-09T07:40:01Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [May 9, 2023, 7:40am UTC](https://discourse.julialang.org/t/doctests-dont-appear-in-repl-help-mode/98534/1 "2023-05-09T07:40:02Z")

</div>

Hi there!  
Does anyone know why doctests are not displayed in the REPL help mode?  
For instance this works

````julia
julia> """
           foo(x)
       
       Compute the foo.
       
       # Example
       ```julia
       foo(0) == 1 # true
       ```
       """
       foo(x) = 1
foo

help?> foo
search: foo floor pointer_from_objref OverflowError RoundFromZero unsafe_copyto! functionloc

  foo(x)

  Compute the foo.

  Example
  ≡≡≡≡≡≡≡≡≡

  foo(0) == 1 # true

````

But this doesn’t.

````julia
julia> """
           bar(x)
       
       Compute the bar.
       
       # Example
       ```jldoctest
       bar(0)
       
       # output
       
       2
       ```
       """
       bar(x) = 2
bar

help?> bar
search: bar baremodule SubArray GlobalRef clipboard BitArray backtrace BitMatrix

  bar(x)

  Compute the bar.

  Example
  ≡≡≡≡≡≡≡≡≡

````

As you can see the example block shows up empty.

My best guess is that Documenter.jl is not “core Julia” and so a block tagged with `jldoctest` has no reason to show up, but it is still a bit annoying.

---

<div class="post-metadata">

### Author: ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)
#### Post date: [May 9, 2023, 7:55am UTC](https://discourse.julialang.org/t/doctests-dont-appear-in-repl-help-mode/98534/2 "2023-05-09T07:55:51Z")

</div>

It should show up. It is even recommended (6. at [Documentation · The Julia Language](https://docs.julialang.org/en/v1/manual/documentation/#Writing-Documentation)).

What Julia version are you using? I tried running both your snippets in 1.8.5 and 1.9.0-rc3, and both examples show up for me in both versions.

---

<div class="post-metadata">

### Author: ![navidcy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/navidcy/32/2750_2.png) [@navidcy](https://discourse.julialang.org/u/navidcy)
#### Post date: [May 9, 2023, 7:56am UTC](https://discourse.julialang.org/t/doctests-dont-appear-in-repl-help-mode/98534/3 "2023-05-09T07:56:33Z")

</div>

Are you using `OhMyREPL`? I found the same exact issue and realized that it was `OhMyREPL` that was causing it.

> <https://github.com/KristofferC/OhMyREPL.jl/issues/293>
>
> I've been struggling with this for a bit and I think it has something to do with… OhMyREPL.
> 
> I define a function \`foo\` with a docstring that includes a doctest \[with a "script" example\](https://documenter.juliadocs.org/stable/man/doctests/#%22Script%22-Examples). Then I ask for the \`help?\> foo\` and if OhMyREPL is loaded then the doctest does not appear!
> 
> (Note that if I used a \[REPL example doctest\](https://documenter.juliadocs.org/stable/man/doctests/#REPL-Examples) then all is good!)
> 
> Here's a MWE.
> 
> Af first I load Julia \_without\_ OhMyREPL. Everything looks OK. If then I load OhMyREPL and ask again of the docstring of \`foo\` the example is disappeared!
> 
> \`\`\`Julia
> \_
> \_ \_ \_(\_)\_ | Documentation: https://docs.julialang.org
> (\_) | (\_) (\_) |
> \_ \_ \_| |\_ \_\_ \_ | Type "?" for help, "\]?" for Pkg help.
> | | | | | | |/ \_\` | |
> | | |\_| | | | (\_| | | Version 1.8.5 (2023-01-08)
> \_/ |\\\_\_'\_|\_|\_|\\\_\_'\_| |
> |\_\_/ |
> 
> 
> julia\> """
> foo(x)
> 
> A function called foo.
> 
> Example
> =======
> \`\`\`jldoctest
> foo(2)
> # output
> 2
> \`\`\`
> """
> foo(x) = x
> foo
> 
> help?\> foo
> search: foo floor pointer\_from\_objref OverflowError RoundFromZero unsafe\_copyto! functionloc
> 
> foo(x)
> 
> A function called foo.
> 
> Example
> ≡≡≡≡≡≡≡≡≡
> 
> foo(2)
> # output
> 2
> 
> julia\> using OhMyREPL
> 
> help?\> foo
> search: foo floor pointer\_from\_objref OverflowError RoundFromZero unsafe\_copyto! functionloc
> 
> foo(x)
> 
> 
> A function called foo.
> 
> Example
> ≡≡≡≡≡≡≡≡≡
> 
> 
> julia\>
> \`\`\`

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [May 9, 2023, 7:58am UTC](https://discourse.julialang.org/t/doctests-dont-appear-in-repl-help-mode/98534/4 "2023-05-09T07:58:09Z")

</div>

let me try without OhMyREPL!

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [May 9, 2023, 8:00am UTC](https://discourse.julialang.org/t/doctests-dont-appear-in-repl-help-mode/98534/5 "2023-05-09T08:00:58Z")

</div>

You’re right, that was it!

---

<div class="post-metadata">

### Author: ![navidcy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/navidcy/32/2750_2.png) [@navidcy](https://discourse.julialang.org/u/navidcy)
#### Post date: [May 9, 2023, 8:01am UTC](https://discourse.julialang.org/t/doctests-dont-appear-in-repl-help-mode/98534/6 "2023-05-09T08:01:36Z")

</div>

Feel free to comment on the issue.
