Hi there!
Does anyone know why doctests are not displayed in the REPL help mode?
For instance this works
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> """
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.
It should show up. It is even recommended (6. at Documentation · The Julia Language ).
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.
Are you using OhMyREPL
? I found the same exact issue and realized that it was OhMyREPL
that was causing it.
opened 04:58PM - 01 Mar 23 UTC
bug
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>
```
1 Like
let me try without OhMyREPL!
You’re right, that was it!
Feel free to comment on the issue.
1 Like