From 537710709271712ee0a6be97502c3abd8eff32dd Mon Sep 17 00:00:00 2001 From: Jakob Peters Date: Thu, 30 May 2024 03:32:11 -0700 Subject: [PATCH] Improve documentation --- NEWS.md | 2 +- docs/make.jl | 1 + docs/src/assets/strings.svg | 125 +++++++++++++++++++++++++++++------- src/strings.jl | 48 ++++++++------ 4 files changed, 133 insertions(+), 43 deletions(-) diff --git a/NEWS.md b/NEWS.md index a6183fb..f419a9d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,7 +12,7 @@ - Replace `typst_text` constructor with `TypstText` wrapper - `show_typst` - Implement `show_typst(x)` which prints to `stdout` - - Implemented for `AbstractArray`, `Tuple`, `Typst`, and `Unsigned` + - Implemented for `AbstractArray`, `Tuple`, `Typst`, `TypstText`, and `Unsigned` - `nothing` now corresponds to Typst's `none` - `AbtractMatrix` and `AbstractVector` in `code` mode now correspond to a Typst array - `OrdinalRange{<:Integer, <:Integer}` and `StepRangeLen{<:Integer, <:Integer, <:Integer}` diff --git a/docs/make.jl b/docs/make.jl index 00f2c33..a95ba9f 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -53,6 +53,7 @@ open(strings * ".typ"; truncate = true) do file if is_vector print(file, "\"[true, 1, Any[1.2, 1//2]]\"") elseif v isa StepRangeLen print(file, "\"StepRangeLen(0, 2, 4)\"") elseif v isa Text print(file, "\"text\\\"[\\\\\\\"a\\\\\\\"]\\\"\"") + elseif v isa Typst print(file, "\"Typst(1)\"") elseif v isa TypstText print(file, "\"TypstText([1, 2, 3, 4])\"") else show(file, repr(v)) end diff --git a/docs/src/assets/strings.svg b/docs/src/assets/strings.svg index 30fe254..1ee09f2 100644 --- a/docs/src/assets/strings.svg +++ b/docs/src/assets/strings.svg @@ -1,25 +1,25 @@ - + - + - + - + - + - + - + - + @@ -87,6 +87,9 @@ + + + @@ -2924,6 +2927,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2975,7 +3056,7 @@ - + @@ -2996,7 +3077,7 @@ - + @@ -3009,7 +3090,7 @@ - + @@ -3024,7 +3105,7 @@ - + @@ -3045,7 +3126,7 @@ - + @@ -3119,7 +3200,7 @@ - + @@ -3138,7 +3219,7 @@ - + @@ -3155,7 +3236,7 @@ - + @@ -3174,7 +3255,7 @@ - + @@ -3225,7 +3306,7 @@ - + @@ -3239,7 +3320,7 @@ - + @@ -3257,7 +3338,7 @@ - + @@ -3270,7 +3351,7 @@ - + @@ -3283,7 +3364,7 @@ - + diff --git a/src/strings.jl b/src/strings.jl index 045733b..de677fc 100644 --- a/src/strings.jl +++ b/src/strings.jl @@ -536,30 +536,37 @@ with the same name as in Typst, except that dashes are replaced with underscores For additional information on settings and parameters, see also [`context`](@ref) and the [Typst Documentation](https://typst.app/docs/), respectively. +!!! info + `...` indicates that the method may call + [`show(::IO,\u00A0::MIME"text/typst",\u00A0::Typst)`](@ref) + to format a value which may require additional settings. + !!! warning This function's methods are incomplete. Please file an issue or create a pull-request for missing methods. -| Type | Settings | Parameters | -|:----------------------------------------------------------|:---------------------------------------|:--------------------------------------------------------| -| `AbstractArray` | `:block`, `:depth`, `:indent`, `:mode` | `:delim`, `:gap` | -| `AbstractChar` | `:mode` | | -| `AbstractFloat` | | | -| `AbstractMatrix` | `:block`, `:depth`, `:indent`, `:mode` | `:augment`, `:column_gap`, `:delim`, `:gap`, `:row_gap` | -| `AbstractString` | `:mode` | | -| `Bool` | `:mode` | | -| `Complex` | `:block`, `:mode`, `:parenthesize` | | -| `Irrational` | `:mode` | | -| `Nothing` | `:mode` | | -| `OrdinalRange{<:Integer,\u00A0<:Integer}` | `:mode` | | -| `Rational` | `:block`, `:mode`, `:parenthesize` | | -| `Regex` | `:mode` | | -| `Signed` | | | -| `StepRangeLen{<:Integer,\u00A0<:Integer,\u00A0<:Integer}` | `:mode` | | -| `Text` | `:mode` | | -| `Typst` | | | -| `TypstString` | | | -| `TypstText` | | | +| Type | Settings | Parameters | +|:----------------------------------------------------------|:--------------------------------------------|:--------------------------------------------------------| +| `AbstractArray` | `:block`, `:depth`, `:indent`, `:mode`, ... | `:delim`, `:gap` | +| `AbstractChar` | `:mode` | | +| `AbstractFloat` | | | +| `AbstractMatrix` | `:block`, `:depth`, `:indent`, `:mode`, ... | `:augment`, `:column_gap`, `:delim`, `:gap`, `:row_gap` | +| `AbstractString` | `:mode` | | +| `Bool` | `:mode` | | +| `Complex` | `:block`, `:mode`, `:parenthesize`, ... | | +| `Irrational` | `:mode`, ... | | +| `Nothing` | `:mode` | | +| `OrdinalRange{<:Integer,\u00A0<:Integer}` | `:mode`, ... | | +| `Rational` | `:block`, `:mode`, `:parenthesize`, ... | | +| `Regex` | `:mode` | | +| `Signed` | | | +| `StepRangeLen{<:Integer,\u00A0<:Integer,\u00A0<:Integer}` | `:mode`, ... | | +| `Text` | `:mode`, ... | | +| `Tuple` | `:block`, `:depth`, `:indent`, `:mode`, ... | `:delim`, `:gap` | +| `Typst` | ... | | +| `TypstString` | | | +| `TypstText` | | | +| `Unsigned` | `:mode` | | # Examples ```jldoctest @@ -875,6 +882,7 @@ const examples = [ StepRangeLen(0, 2, 4) => StepRangeLen{<:Integer, <:Integer, <:Integer}, text"[\"a\"]" => Text, (true, 1, 1.2, 1 // 2) => Tuple, + Typst(1) => Typst, typst"[\"a\"]" => TypstString, TypstText([1, 2, 3, 4]) => TypstText, 0xff => Unsigned