Skip to content

Commit

Permalink
Improve internals documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobjpeters committed Aug 2, 2024
1 parent 5076d6f commit 7f9d622
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ end
"""
format(::Union{MIME"application/pdf", MIME"image/png", MIME"image/svg+xml"})
Return the image format acronym corresponding to the given `MIME`.
# Examples
```jldoctest
Expand All @@ -70,7 +72,7 @@ format(::MIME"image/svg+xml") = "svg"
TypstCommand(::TypstCommand; kwargs...)
TypstCommand(::TypstCommand, ignorestatus, flags, env, dir, cpus = nothing)
The Typst compiler.
The Typst compiler and its parameters.
!!! info
This type implements the `Cmd` interface.
Expand Down
27 changes: 25 additions & 2 deletions src/Strings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ end
"""
typst_mime
Equivalent to `MIME"text/typst"()`.
# Examples
```jldoctest
Expand Down Expand Up @@ -492,7 +494,17 @@ date_time(::Time) = hour, minute, second
date_time(::DateTime) = year, month, day, hour, minute, second

"""
duration(::Union{Day, Hour, Minute, Second, Week})
duration(::Union{Dates.Day, Dates.Hour, Dates.Minute, Dates.Second, Dates.Week})
# Examples
```jldoctest
julia> Typstry.Strings.duration(Dates.Day(1))
:days
julia> Typstry.Strings.duration(Dates.Hour(1))
:hours
```
"""
duration(::Day) = :days
duration(::Hour) = :hours
Expand All @@ -502,8 +514,19 @@ duration(::Week) = :weeks

"""
dates(::Union{
Date, DateTime, Day, Hour, Minute, Second, Time, Week
Dates.Date, Dates.DateTime, Dates.Day, Dates.Hour,
Dates.Minute, Dates.Second, Dates.Time, Dates.Week
})
# Examples
```jldoctest
julia> Typstry.Strings.dates(Date(1))
("datetime", (:year, :month, :day), (1, 1, 1))
julia> Typstry.Strings.dates(Day(1))
("duration", (:days,), (TypstText{String}("1"),))
```
"""
function dates(x::Union{Date, DateTime, Time})
fs = date_time(x)
Expand Down
3 changes: 3 additions & 0 deletions src/Typstry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export TypstCommand, TypstError, @typst_cmd, julia_mono, preamble, render

"""
compile_workload(examples)
Given an iterable of value-type pairs, interpolate each value into
a `@typst_str` within a `PrecompileTools.@compile_workload` block.
"""
compile_workload(examples) = @compile_workload for (x, _) in examples
typst"\(x)"
Expand Down

0 comments on commit 7f9d622

Please sign in to comment.