Skip to content

Commit

Permalink
Fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobjpeters committed Aug 6, 2024
1 parent 3f3b02a commit 85b0c19
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ pages(folder, names) = titlecase(replace(folder, "_" => " ")) => map(name -> joi

_setdocmeta!(_module, x) = setdocmeta!(_module, :DocTestSetup, quote
using Typstry
$x
using $x: $x
end; recursive = true)

_setdocmeta!(Typstry, nothing)
_setdocmeta!(Typstry, :Dates)

for extension in extensions
_module = get_extension(Typstry, Symbol(extension, :Extension))
_setdocmeta!(_module, :(using $(Symbol(extension))))
_setdocmeta!(_module, Symbol(extension))
push!(modules, _module)
push!(_examples, _module.examples)
end
Expand Down
6 changes: 3 additions & 3 deletions src/Strings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ static_parse(args...; filename, kwargs...) = @static VERSION < v"1.10" ?
## Dates.jl

"""
date_time(::Union{Date, Time, DateTime})
date_time(::Union{Dates.Date, Dates.Time, Dates.DateTime})
"""
date_time(::Date) = year, month, day
date_time(::Time) = hour, minute, second
Expand Down Expand Up @@ -521,10 +521,10 @@ duration(::Week) = :weeks
# Examples
```jldoctest
julia> Typstry.Strings.dates(Date(1))
julia> Typstry.Strings.dates(Dates.Date(1))
("datetime", (:year, :month, :day), (1, 1, 1))
julia> Typstry.Strings.dates(Day(1))
julia> Typstry.Strings.dates(Dates.Day(1))
("duration", (:days,), (TypstText{String}("1"),))
```
"""
Expand Down
6 changes: 3 additions & 3 deletions test/TestDocumenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ using ..TestTypstry: names, modules
using Typstry: Typstry

function test(_module, x)
setdocmeta!(_module, :DocTestSetup, :(using Typstry; $x); recursive = true)
setdocmeta!(_module, :DocTestSetup, :(using Typstry; using $x: $x); recursive = true)
doctest(_module; manual = "source", testset = "`$_module` Doctests")
end

disable_logging(Warn)

test(Typstry, nothing)
test(Typstry, :Dates)

for (name, _module) in zip(names, modules)
test(_module, :(using $name))
test(_module, name)
end

disable_logging(Debug)
Expand Down

0 comments on commit 85b0c19

Please sign in to comment.