Skip to content

Commit 042504d

Browse files
mortenpifredrikekre
authored andcommitted
Add a few methods to manual & fix doctests (#32417)
* Don't share doctest state between docstrings This is not, strictly speaking, well defined. There is no official rule as to which docstring should get executed first. This will not be supported in a future version of Documenter. * Add Channel(::Function) to the manual Also fix the doctest in the docstring. The simpler println variant seems to be more reliable when printing from a another task (with at-show, the "Hello" string did not actually get printed). * Fix Base.splat doctest The function is not exported. Note that it does not currently get doctested, but will be tested in a future Documenter version. * Fix doctest in at-locals docstring This is not currently included in the manual and therefore not doctested, but will be in the future. * Fix doctest in Base.isambiguous docstring Not currently doctested since it is not included in the manual, but will be in the future. * Add findnext/last(::AbstractChar,...) to manual Also fix a doctest in one of the docstrings. * Add BLAS.dot and axpby! to manual And fix the doctests in the docstrings. * Fix doctests of unexported functions Fix doctests in the docstrings of LinearAlgebra.isbanded, LinearAlgebra.promote_leaf_eltypes and SparseArrays.dropstored!. All the functions are unexported and not included in the manual. They are currently not being doctested, but will be with a future version of Documenter.
1 parent 7bda2c1 commit 042504d

File tree

11 files changed

+28
-23
lines changed

11 files changed

+28
-23
lines changed

base/array.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ If specified, replacement values from an ordered
12811281
collection will be spliced in place of the removed item.
12821282
12831283
# Examples
1284-
```jldoctest splice!
1284+
```jldoctest
12851285
julia> A = [6, 5, 4, 3, 2, 1]; splice!(A, 5)
12861286
2
12871287
@@ -1352,8 +1352,8 @@ To insert `replacement` before an index `n` without removing any items, use
13521352
`splice!(collection, n:n-1, replacement)`.
13531353
13541354
# Examples
1355-
```jldoctest splice!
1356-
julia> splice!(A, 4:3, 2)
1355+
```jldoctest
1356+
julia> A = [-1, -2, -3, 5, 4, 3, -1]; splice!(A, 4:3, 2)
13571357
0-element Array{Int64,1}
13581358
13591359
julia> A

base/channels.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ Referencing the created task:
8484
```jldoctest
8585
julia> taskref = Ref{Task}();
8686
87-
julia> chnl = Channel(c->(@show take!(c)); taskref=taskref);
87+
julia> chnl = Channel(c -> println(take!(c)); taskref=taskref);
8888
8989
julia> istaskdone(taskref[])
9090
false
9191
9292
julia> put!(chnl, "Hello");
93-
take!(c) = "Hello"
93+
Hello
9494
9595
julia> istaskdone(taskref[])
9696
true

base/operators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ passes a tuple as that single argument.
10281028
10291029
# Example usage:
10301030
```jldoctest
1031-
julia> map(splat(+), zip(1:3,4:6))
1031+
julia> map(Base.splat(+), zip(1:3,4:6))
10321032
3-element Array{Int64,1}:
10331033
5
10341034
7

base/reflection.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ julia> function f(x)
295295
end;
296296
297297
julia> f(42)
298-
Dict{Symbol,Any}(:x=>42)
299-
Dict{Symbol,Any}(:i=>1,:x=>42)
300-
Dict{Symbol,Any}(:y=>2,:x=>42)
298+
Dict{Symbol,Any}(:x => 42)
299+
Dict{Symbol,Any}(:i => 1,:x => 42)
300+
Dict{Symbol,Any}(:y => 2,:x => 42)
301301
```
302302
"""
303303
macro locals()
@@ -1274,7 +1274,7 @@ foo (generic function with 2 methods)
12741274
julia> m1, m2 = collect(methods(foo));
12751275
12761276
julia> typeintersect(m1.sig, m2.sig)
1277-
Tuple{#foo,Complex{Union{}}}
1277+
Tuple{typeof(foo),Complex{Union{}}}
12781278
12791279
julia> Base.isambiguous(m1, m2, ambiguous_bottom=true)
12801280
true

base/strings/search.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ Find the next occurrence of character `ch` in `string` starting at position `sta
284284
285285
# Examples
286286
```jldoctest
287-
julia> findnext(`z`, "Hello to the world", 1) === nothing
287+
julia> findnext('z', "Hello to the world", 1) === nothing
288288
true
289289
290-
julia> findnext(`o`, "Hello to the world", 6)
290+
julia> findnext('o', "Hello to the world", 6)
291291
8
292292
```
293293
"""

doc/src/base/parallel.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Base.islocked
4444
Base.ReentrantLock
4545
4646
Base.Channel
47+
Base.Channel(::Function)
4748
Base.put!(::Channel, ::Any)
4849
Base.take!(::Channel)
4950
Base.isready(::Channel)

doc/src/base/strings.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ Base.lpad
3939
Base.rpad
4040
Base.findfirst(::AbstractString, ::AbstractString)
4141
Base.findnext(::AbstractString, ::AbstractString, ::Integer)
42+
Base.findnext(::AbstractChar, ::AbstractString, ::Integer)
4243
Base.findlast(::AbstractString, ::AbstractString)
44+
Base.findlast(::AbstractChar, ::AbstractString)
4345
Base.findprev(::AbstractString, ::AbstractString, ::Integer)
4446
Base.occursin
4547
Base.reverse(::Union{String,SubString{String}})

stdlib/LinearAlgebra/docs/src/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,14 @@ the input argument belongs on (`side`). The possibilities are:
520520

521521
```@docs
522522
LinearAlgebra.BLAS
523+
LinearAlgebra.BLAS.dot
523524
LinearAlgebra.BLAS.dotu
524525
LinearAlgebra.BLAS.dotc
525526
LinearAlgebra.BLAS.blascopy!
526527
LinearAlgebra.BLAS.nrm2
527528
LinearAlgebra.BLAS.asum
528529
LinearAlgebra.axpy!
530+
LinearAlgebra.axpby!
529531
LinearAlgebra.BLAS.scal!
530532
LinearAlgebra.BLAS.scal
531533
LinearAlgebra.BLAS.iamax

stdlib/LinearAlgebra/src/blas.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ Dot product of two vectors consisting of `n` elements of array `X` with stride `
238238
239239
# Examples
240240
```jldoctest
241-
julia> dot(10, fill(1.0, 10), 1, fill(1.0, 20), 2)
241+
julia> BLAS.dot(10, fill(1.0, 10), 1, fill(1.0, 20), 2)
242242
10.0
243243
```
244244
"""
@@ -495,9 +495,9 @@ julia> y = [4., 5, 6];
495495
496496
julia> BLAS.axpby!(2., x, 3., y)
497497
3-element Array{Float64,1}:
498-
14.0
499-
19.0
500-
24.0
498+
14.0
499+
19.0
500+
24.0
501501
```
502502
"""
503503
function axpby! end

stdlib/LinearAlgebra/src/generic.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,21 +1183,21 @@ julia> a = [1 2; 2 -1]
11831183
1 2
11841184
2 -1
11851185
1186-
julia> isbanded(a, 0, 0)
1186+
julia> LinearAlgebra.isbanded(a, 0, 0)
11871187
false
11881188
1189-
julia> isbanded(a, -1, 1)
1189+
julia> LinearAlgebra.isbanded(a, -1, 1)
11901190
true
11911191
11921192
julia> b = [1 0; -im -1] # lower bidiagonal
11931193
2×2 Array{Complex{Int64},2}:
11941194
1+0im 0+0im
11951195
0-1im -1+0im
11961196
1197-
julia> isbanded(b, 0, 0)
1197+
julia> LinearAlgebra.isbanded(b, 0, 0)
11981198
false
11991199
1200-
julia> isbanded(b, -1, 0)
1200+
julia> LinearAlgebra.isbanded(b, -1, 0)
12011201
true
12021202
```
12031203
"""
@@ -1423,7 +1423,7 @@ julia> a = [[1,2, [3,4]], 5.0, [6im, [7.0, 8.0]]]
14231423
5.0
14241424
Any[0+6im,[7.0,8.0]]
14251425
1426-
julia> promote_leaf_eltypes(a)
1426+
julia> LinearAlgebra.promote_leaf_eltypes(a)
14271427
Complex{Float64}
14281428
```
14291429
"""

stdlib/SparseArrays/src/sparsevector.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ julia> x = sparsevec([1, 3], [1.0, 2.0])
325325
[1] = 1.0
326326
[3] = 2.0
327327
328-
julia> Base.SparseArrays.dropstored!(x, 3)
328+
julia> SparseArrays.dropstored!(x, 3)
329329
3-element SparseVector{Float64,Int64} with 1 stored entry:
330330
[1] = 1.0
331331
332-
julia> Base.SparseArrays.dropstored!(x, 2)
332+
julia> SparseArrays.dropstored!(x, 2)
333333
3-element SparseVector{Float64,Int64} with 1 stored entry:
334334
[1] = 1.0
335335
```

0 commit comments

Comments
 (0)