julia> using CellListMap
julia> box = Box([100,70,130],12)
Box{OrthorhombicCell, 3, Float64, 9}
unit cell matrix: [100.0 0.0 0.0; 0.0 70.0 0.0; 0.0 0.0 130.0]
cutoff: 12.0
number of computing cells on each dimension: [10, 7, 12]
computing cell sizes: [12.5, 14.0, 13.0] (lcell: 1)
Total number of cells: 840
Do I really need using CellListMap there? I am getting Box undefined if I do not put it there, but that is a function of the package and exported by the package. I am using:
using Test, Documenter, CellListMap
doctest(CellListMap)
Is that the only solution? Where can I put that such that I donβt have to type it every time? I tried adding it to docs/make.jl but that didnβt work. That help entry, in particular, is within the comment block above the corresponding function.
Actually the whole jldoctest workflow is not working for me. My runtests.jl starts with:
using CellListMap
using StaticArrays
using Test
using Documenter
DocMeta.setdocmeta!(
CellListMap,
:DocTestSetup,
:(using CellListMap);
recursive=true
)
doctest(CellListMap)
But I wtill get Box undefined in a the jldoctest that is:
julia> box = Box([100,70,130],12)
Box{OrthorhombicCell, 3, Float64, 9}
unit cell matrix: [100.0 0.0 0.0; 0.0 70.0 0.0; 0.0 0.0 130.0]
cutoff: 12.0
number of computing cells on each dimension: [10, 7, 12]
computing cell sizes: [12.5, 14.0, 13.0] (lcell: 1)
Total number of cells: 840
and this one is in a regular .md file of the docs.
Also, I get loads of errors of the sort:
β Error: doctest failure in ~/.julia/dev/CellListMap/src/testing.jl
β
β ```jldoctest
β julia> box = Box([ 50. 0. 00.
β 0. 30. 30.
β 0. 00. 50. ], 2.)
β
β julia> x = 100*rand(SVector{3,Float64},10000);
β
β julia> p = [ CellListMap.wrap_to_first(x,box) for x in x ];
β
β julia> scatter(Tuple.(p),aspect_ratio=1,framestyle=:box,label=:none)
β ```
β
β Subexpression:
β
β x = 100*rand(SVector{3,Float64},10000);
β
β Evaluated output:
β
β ERROR: UndefVarError: SVector not defined
β Stacktrace:
β [1] top-level scope
β @ none:1
β
β Expected output:
β
β
β
β diff =
β ERROR: UndefVarError: SVector not defined
β Stacktrace:
β [1] top-level scope
β @ none:1
β @ Documenter.DocTests ~/.julia/packages/Documenter/R2HVS/src/DocTests.jl:385
But none of these fields are jldoctests, so they should not be evaluated. What even stranger is that the file where the error is indicated, testing.jl has nothing to do with that code block, which is another file (pbc.md), and is a standard julia block:
#```julia
julia> box = Box([ 50. 0. 00.
0. 30. 30.
0. 00. 50. ], 2.)
julia> x = 100*rand(SVector{3,Float64},10000);
julia> p = [ CellListMap.wrap_to_first(x,box) for x in x ];
julia> scatter(Tuple.(p),aspect_ratio=1,framestyle=:box,label=:none)
#```
I would also appreciate if some points to a package where jldoctests are being used both in the documentation and on function comments, such that I can copy them. I looked at some examples suggested in the Documenter docs page, but at least the ones I have checked didnβt seem to be using these features.
That block is was not a jldoctest block, I was not expecting it to be tested. And the doctests are trying to run many blocks that are not jldoctest blocks and throwing a lot of errors. The errors also, strangely, keep referencing my testing.jl file, which not only does not contain any jdoctest, but neither the blocks it is complaining about. Is a file named testing.jl a problem in principle for any reason? (edit: now I changed all julia blocks to julia-repl blocks, and it seems that this errors disappeared. Are julia blocks ran by doctests?
From reading the conversation, you want to make sure that you are exposing all the elements of the namespace you are referring to. For example, if you have using MyPkg and try calling magic which is not exposed by having export magic in MyPkg.jl you would still get that error.
What I tend to do is to run build the docs with the jldoctest as part of my test suite. For the documentation step of CI I just refer to the docs built during the testing.
It is exported. I have no idea whatβs wrong. For the moment I removed the tests. I tried to add a @meta block in the page as well, but that didnβt work either.
Looking at this error, the doctest is in a Markdown file? In that case, you need a DocTestSetup in an at-meta block in the same .md file before the doctest. That should fix this particular error at least.