I’ve created a package and successfully pushed CI-Documenter-generated docs on its github page, but I’m having trouble adding doctests. They currently fail because of a mismatch in the output, and I’m not sure how I should resolve it.
Suppose the function I want documented is:
"""
euler_active(φ::Real, θ::Real, ψ::Real)
3D rotation matrix
- `φ`: Euler angle (longitude, in [0,2π])
- `θ`: Euler angle (colatitude, in [0,2π])
- `ψ`: Euler angle (rotation around z", in [0,2π])
# Examples
```jldoctest
julia> using StaticArrays
julia> euler_active(π/2,0,0)
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
6.12323e-17 -1.0 0.0
1.0 6.12323e-17 0.0
-0.0 0.0 1.0
```
"""
function euler_active(φ, θ, ψ = 0)
cosφ = cos(φ)
cosψ = cos(ψ)
cosθ = cos(θ)
sinφ = sin(φ)
sinψ = sin(ψ)
sinθ = sin(θ)
# filled by columns
R = SMatrix{3,3}(
cosφ * cosθ * cosψ - sinφ * sinψ,
sinφ * cosθ * cosψ + cosφ * sinψ,
-sinθ * cosψ,
-cosφ * cosθ * sinψ - sinφ * cosψ,
-sinφ * cosθ * sinψ + cosφ * cosψ,
sinθ * sinψ,
cosφ * sinθ,
sinφ * sinθ,
cosθ,
)
return R
end
My package’s main module loads StaticArrays (used throughout), with using StaticArrays
, so I never need to prefix its functions.
The error I’m getting on github’s CI side is:
┌ Error: doctest failure in ~/work/CoupledDipole.jl/CoupledDipole.jl/src/Utils.jl:15-22
│
│ ```jldoctest
│ julia> using StaticArrays
│ julia> euler_active(π/2,0,0)
│ 3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
│ 6.12323e-17 -1.0 0.0
│ 1.0 6.12323e-17 0.0
│ -0.0 0.0 1.0
│ ```
│
│ Subexpression:
│
│ euler_active(π/2,0,0)
│
│ Evaluated output:
│
│ 3×3 StaticArrays.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
│ 6.12323e-17 -1.0 0.0
│ 1.0 6.12323e-17 0.0
│ -0.0 0.0 1.0
│
│ Expected output:
│
│ using StaticArrays
│
│ diff =
│ Warning: Diff output requires color.
│ using StaticArrays3×3 StaticArrays.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
│ 6.12323e-17 -1.0 0.0
│ 1.0 6.12323e-17 0.0
│ -0.0 0.0 1.0
How should I remedy this? Ideally all docs examples would be run in an environment where StaticArrays is loaded, but I don’t really see where to add this. Also curious about resolving the colour issue.