From e24a84a2912887bd745e288c58d8d7a2a03a03c1 Mon Sep 17 00:00:00 2001 From: Daniel Wennberg Date: Mon, 2 Dec 2024 11:52:11 -0800 Subject: [PATCH 1/5] Update annotated.jl docstrings according to #55741 --- base/strings/annotated.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/base/strings/annotated.jl b/base/strings/annotated.jl index c5c330fe0dfcd..860613cc2d24a 100644 --- a/base/strings/annotated.jl +++ b/base/strings/annotated.jl @@ -57,7 +57,7 @@ like [`string`](@ref) but preserves any annotations present in the arguments. ```julia-repl julia> AnnotatedString("this is an example annotated string", - [(1:18, :A => 1), (12:28, :B => 2), (18:35, :C => 3)]) + [(1:18, :A, 1), (12:28, :B, 2), (18:35, :C, 3)]) "this is an example annotated string" ``` """ @@ -88,7 +88,7 @@ AnnotatedChar(s::S, annotations::Vector{$Annotation}) # Examples ```julia-repl -julia> AnnotatedChar('j', :label => 1) +julia> AnnotatedChar('j', (:label, 1)) 'j': ASCII/Unicode U+006A (category Ll: Letter, lowercase) ``` """ @@ -236,7 +236,7 @@ See also [`AnnotatedString`](@ref) and [`AnnotatedChar`](@ref). julia> annotatedstring("now a AnnotatedString") "now a AnnotatedString" -julia> annotatedstring(AnnotatedString("annotated", [(1:9, :label => 1)]), ", and unannotated") +julia> annotatedstring(AnnotatedString("annotated", [(1:9, :label, 1)]), ", and unannotated") "annotated, and unannotated" ``` """ @@ -344,7 +344,7 @@ end annotate!(str::AnnotatedString, [range::UnitRange{Int}], label::Symbol, value) annotate!(str::SubString{AnnotatedString}, [range::UnitRange{Int}], label::Symbol, value) -Annotate a `range` of `str` (or the entire string) with a labeled value (`label` => `value`). +Annotate a `range` of `str` (or the entire string) with a labeled value `(label, value)`. To remove existing `label` annotations, use a value of `nothing`. The order in which annotations are applied to `str` is semantically meaningful, @@ -365,7 +365,7 @@ annotate!(s::SubString{<:AnnotatedString}, label::Symbol, @nospecialize(val::Any """ annotate!(char::AnnotatedChar, label::Symbol, value::Any) -Annotate `char` with the pair `label => value`. +Annotate `char` with the labeled value `(label, value)`. """ annotate!(c::AnnotatedChar, label::Symbol, @nospecialize(val::Any)) = (push!(c.annotations, Annotation((; label, val))); c) From 1b5fbd21d36cb6ef928ee3e3d6d5772467e3425c Mon Sep 17 00:00:00 2001 From: Daniel Wennberg Date: Mon, 2 Dec 2024 14:16:08 -0800 Subject: [PATCH 2/5] `julia-repl` -> `jldoctest` --- base/strings/annotated.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/strings/annotated.jl b/base/strings/annotated.jl index 860613cc2d24a..742df6b997cc2 100644 --- a/base/strings/annotated.jl +++ b/base/strings/annotated.jl @@ -55,7 +55,7 @@ like [`string`](@ref) but preserves any annotations present in the arguments. # Examples -```julia-repl +```jldoctest julia> AnnotatedString("this is an example annotated string", [(1:18, :A, 1), (12:28, :B, 2), (18:35, :C, 3)]) "this is an example annotated string" @@ -87,7 +87,7 @@ AnnotatedChar(s::S, annotations::Vector{$Annotation}) # Examples -```julia-repl +```jldoctest julia> AnnotatedChar('j', (:label, 1)) 'j': ASCII/Unicode U+006A (category Ll: Letter, lowercase) ``` @@ -232,7 +232,7 @@ See also [`AnnotatedString`](@ref) and [`AnnotatedChar`](@ref). ## Examples -```julia-repl +```jldoctest julia> annotatedstring("now a AnnotatedString") "now a AnnotatedString" From 609d00f3f8ea3ad1e141220aaf5ac4d790c1c963 Mon Sep 17 00:00:00 2001 From: Daniel Wennberg Date: Mon, 2 Dec 2024 15:03:46 -0800 Subject: [PATCH 3/5] Fix doctests --- base/strings/annotated.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/base/strings/annotated.jl b/base/strings/annotated.jl index 742df6b997cc2..7273ed71a3f2d 100644 --- a/base/strings/annotated.jl +++ b/base/strings/annotated.jl @@ -55,7 +55,7 @@ like [`string`](@ref) but preserves any annotations present in the arguments. # Examples -```jldoctest +```jldoctest; setup=:(using StyledStrings) julia> AnnotatedString("this is an example annotated string", [(1:18, :A, 1), (12:28, :B, 2), (18:35, :C, 3)]) "this is an example annotated string" @@ -87,8 +87,8 @@ AnnotatedChar(s::S, annotations::Vector{$Annotation}) # Examples -```jldoctest -julia> AnnotatedChar('j', (:label, 1)) +```jldoctest; setup=:(using StyledStrings) +julia> AnnotatedChar('j', [(:label, 1)]) 'j': ASCII/Unicode U+006A (category Ll: Letter, lowercase) ``` """ @@ -232,7 +232,7 @@ See also [`AnnotatedString`](@ref) and [`AnnotatedChar`](@ref). ## Examples -```jldoctest +```jldoctest; setup=:(using StyledStrings) julia> annotatedstring("now a AnnotatedString") "now a AnnotatedString" From d4a1b3ea73eb4d8856562d67a3e0d135b4671a0a Mon Sep 17 00:00:00 2001 From: Daniel Wennberg Date: Mon, 2 Dec 2024 20:28:42 -0800 Subject: [PATCH 4/5] Don't load StyledStrings in doctests --- base/strings/annotated.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/strings/annotated.jl b/base/strings/annotated.jl index 7273ed71a3f2d..5a81c25eac90f 100644 --- a/base/strings/annotated.jl +++ b/base/strings/annotated.jl @@ -55,7 +55,7 @@ like [`string`](@ref) but preserves any annotations present in the arguments. # Examples -```jldoctest; setup=:(using StyledStrings) +```jldoctest; setup=:(using Base: AnnotatedString) julia> AnnotatedString("this is an example annotated string", [(1:18, :A, 1), (12:28, :B, 2), (18:35, :C, 3)]) "this is an example annotated string" @@ -87,7 +87,7 @@ AnnotatedChar(s::S, annotations::Vector{$Annotation}) # Examples -```jldoctest; setup=:(using StyledStrings) +```jldoctest; setup=:(using Base: AnnotatedChar) julia> AnnotatedChar('j', [(:label, 1)]) 'j': ASCII/Unicode U+006A (category Ll: Letter, lowercase) ``` @@ -232,7 +232,7 @@ See also [`AnnotatedString`](@ref) and [`AnnotatedChar`](@ref). ## Examples -```jldoctest; setup=:(using StyledStrings) +```jldoctest; setup=:(using Base: annotatedstring) julia> annotatedstring("now a AnnotatedString") "now a AnnotatedString" From 3f543307a50e9a0348822d214c11dfe4c2bfb050 Mon Sep 17 00:00:00 2001 From: Daniel Wennberg Date: Mon, 2 Dec 2024 21:39:49 -0800 Subject: [PATCH 5/5] fixup! Don't load StyledStrings in doctests --- base/strings/annotated.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/strings/annotated.jl b/base/strings/annotated.jl index 5a81c25eac90f..814ee2afa9d55 100644 --- a/base/strings/annotated.jl +++ b/base/strings/annotated.jl @@ -232,7 +232,7 @@ See also [`AnnotatedString`](@ref) and [`AnnotatedChar`](@ref). ## Examples -```jldoctest; setup=:(using Base: annotatedstring) +```jldoctest; setup=:(using Base: AnnotatedString, annotatedstring) julia> annotatedstring("now a AnnotatedString") "now a AnnotatedString"