# Doctests all variables "variable not found"

**URL:** <https://discourse.julialang.org/t/doctests-all-variables-variable-not-found/29378>\
**Category:** General Usage\
**Created:** [October 1, 2019, 7:33pm UTC](https://discourse.julialang.org/t/doctests-all-variables-variable-not-found/29378 "2019-10-01T19:33:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![grahamas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grahamas/32/3401_2.png) [@grahamas](https://discourse.julialang.org/u/grahamas)\
**Post date:** [October 1, 2019, 7:33pm UTC](https://discourse.julialang.org/t/doctests-all-variables-variable-not-found/29378/1 "2019-10-01T19:33:03Z")

</div>

I’m stuck trying to run doctests; it seems that the module isn’t being loaded, but I’ve included what I think is the appropriate meta DocTestSetup block. I’ve been banging my head against this on and off for months, so any suggestions would be greatly appreciated. edit: When I try, e.g. `Simulation73.extent` I also get `Simulation73 is not defined`.

```julia
# docs/make.jl
using Documenter, Simulation73
  
makedocs(
    sitename="Simulation73",
    modules=[Simulation73],
    pages = [
       "Home" => "index.md",
       "Manual" => Any[
           "man/simulation.md"
       ],
       "Library" => Any[
           "Public" => "lib/public.md",
           hide("Internals" => "lib/internals.md",
            Any[joinpath("lib/internals", f) for f in readdir("docs/src/lib/internals")]
           )
       ]
   ]
)

deploydocs(
    repo = "github.com/grahamas/Simulation73.git"
)

```

```julia
# docs/src/index.md
# Simulation73 Documentation
  
``@meta
DocTestSetup = quote
    using Simulation73
end
``

## Manual

``@contents
Pages = joinpath.("man", ["simulation.md"])
``

## Library Documentation

``@contents
Pages = joinpath.("lib", ["public.md", "internals.md"])
``

```

```julia
# test/runtests.jl
using Test, Documenter, Simulation73
doctest(Simulation73)

```

When run, the test returns all errored because no variables defined in `Simulation73` exist. T̶h̶e̶ ̶p̶r̶o̶b̶l̶e̶m̶ ̶i̶s̶ ̶f̶i̶x̶e̶d̶ ̶b̶y̶ ̶q̶u̶a̶l̶i̶f̶y̶i̶n̶g̶ ̶a̶l̶l̶ ̶v̶a̶r̶i̶a̶b̶l̶e̶s̶ ̶(̶e̶.̶g̶.̶ ̶`̶S̶i̶m̶u̶l̶a̶t̶i̶o̶n̶7̶3̶.̶e̶x̶t̶e̶n̶t̶`̶)̶,̶ ̶b̶u̶t̶ ̶I̶’̶d̶ ̶r̶e̶a̶l̶l̶y̶ ̶r̶a̶t̶h̶e̶r̶ ̶n̶o̶t̶.̶

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 1, 2019, 7:38pm UTC](https://discourse.julialang.org/t/doctests-all-variables-variable-not-found/29378/2 "2019-10-01T19:38:16Z")

</div>

It works just as in the REPL, if `Simulation73` does not export the names you want, then you need to qualify.

---

<div class="post-metadata">

**Author:** ![grahamas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grahamas/32/3401_2.png) [@grahamas](https://discourse.julialang.org/u/grahamas)\
**Post date:** [October 1, 2019, 8:00pm UTC](https://discourse.julialang.org/t/doctests-all-variables-variable-not-found/29378/3 "2019-10-01T20:00:50Z")

</div>

Ah sorry I wasn’t clear (and I was wrong): I am exporting the names I want, and I have tested:

```julia
> activate ~/git/Simulation73/docs
> using Simulation73
> extent
extent (generic function with 1 method)

```

In fact, it doesn’t work with qualification. When I just tried to qualify, I get `Simulation73 is not defined`. (I think that was a previous iteration of this problem where I was able to qualify, and I assumed it was still true)

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 1, 2019, 8:25pm UTC](https://discourse.julialang.org/t/doctests-all-variables-variable-not-found/29378/4 "2019-10-01T20:25:59Z")

</div>

If you have your doctests in docstrings you might need to add the doctestmeta as described here: [Doctests · Documenter.jl](https://juliadocs.github.io/Documenter.jl/stable/man/doctests/#Module-level-metadata-1)

---

<div class="post-metadata">

**Author:** ![grahamas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grahamas/32/3401_2.png) [@grahamas](https://discourse.julialang.org/u/grahamas)\
**Post date:** [October 1, 2019, 9:03pm UTC](https://discourse.julialang.org/t/doctests-all-variables-variable-not-found/29378/5 "2019-10-01T21:03:31Z")

</div>

That works! Thank you so much!

edit: If someone else runs into the problem that `docs/make.jl` works but `]test` does not, don’t forget that you need the same `setdocmeta!` line in your `test/runtests.jl` as you had in your `docs/make.jl`.
