Skip to content

Commit 2435f96

Browse files
authored
Add many "see also" links to docstrings (#38606)
1 parent b67d706 commit 2435f96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+747
-79
lines changed

base/abstractarray.jl

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
Supertype for `N`-dimensional arrays (or array-like types) with elements of type `T`.
99
[`Array`](@ref) and other types are subtypes of this. See the manual section on the
1010
[`AbstractArray` interface](@ref man-interface-array).
11+
12+
See also: [`AbstractVector`](@ref), [`AbstractMatrix`](@ref), [`eltype`](@ref), [`ndims`](@ref).
1113
"""
1214
AbstractArray
1315

@@ -24,6 +26,8 @@ dimension to just get the length of that dimension.
2426
Note that `size` may not be defined for arrays with non-standard indices, in which case [`axes`](@ref)
2527
may be useful. See the manual chapter on [arrays with custom indices](@ref man-custom-indices).
2628
29+
See also: [`length`](@ref), [`ndims`](@ref), [`eachindex`](@ref), [`sizeof`](@ref).
30+
2731
# Examples
2832
```jldoctest
2933
julia> A = fill(1, (2,3,4));
@@ -75,6 +79,8 @@ end
7579
7680
Return the tuple of valid indices for array `A`.
7781
82+
See also: [`size`](@ref), [`keys`](@ref), [`eachindex`](@ref).
83+
7884
# Examples
7985
8086
```jldoctest
@@ -174,6 +180,8 @@ For dictionary types, this will be a `Pair{KeyType,ValType}`. The definition
174180
instead of types. However the form that accepts a type argument should be defined for new
175181
types.
176182
183+
See also: [`keytype`](@ref), [`typeof`](@ref).
184+
177185
# Examples
178186
```jldoctest
179187
julia> eltype(fill(1f0, (2,2)))
@@ -202,6 +210,8 @@ elsize(A::AbstractArray) = elsize(typeof(A))
202210
203211
Return the number of dimensions of `A`.
204212
213+
See also: [`size`](@ref), [`axes`](@ref).
214+
205215
# Examples
206216
```jldoctest
207217
julia> A = fill(1, (3,4,5));
@@ -220,6 +230,8 @@ Return the number of elements in the collection.
220230
221231
Use [`lastindex`](@ref) to get the last valid index of an indexable collection.
222232
233+
See also: [`size`](@ref), [`ndims`](@ref), [`eachindex`](@ref).
234+
223235
# Examples
224236
```jldoctest
225237
julia> length(1:5)
@@ -336,6 +348,8 @@ Return the last index of `collection`. If `d` is given, return the last index of
336348
The syntaxes `A[end]` and `A[end, end]` lower to `A[lastindex(A)]` and
337349
`A[lastindex(A, 1), lastindex(A, 2)]`, respectively.
338350
351+
See also: [`axes`](@ref), [`firstindex`](@ref), [`eachindex`](@ref), [`prevind`](@ref).
352+
339353
# Examples
340354
```jldoctest
341355
julia> lastindex([1,2,4])
@@ -354,6 +368,11 @@ lastindex(a, d) = (@_inline_meta; last(axes(a, d)))
354368
355369
Return the first index of `collection`. If `d` is given, return the first index of `collection` along dimension `d`.
356370
371+
The syntaxes `A[begin]` and `A[1, begin]` lower to `A[firstindex(A)]` and
372+
`A[1, firstindex(A, 2)]`, respectively.
373+
374+
See also: [`first`](@ref), [`axes`](@ref), [`lastindex`](@ref), [`nextind`](@ref).
375+
357376
# Examples
358377
```jldoctest
359378
julia> firstindex([1,2,4])
@@ -374,6 +393,8 @@ first(a::AbstractArray) = a[first(eachindex(a))]
374393
Get the first element of an iterable collection. Return the start point of an
375394
[`AbstractRange`](@ref) even if it is empty.
376395
396+
See also: [`only`](@ref), [`firstindex`](@ref), [`last`](@ref).
397+
377398
# Examples
378399
```jldoctest
379400
julia> first(2:2:10)
@@ -395,6 +416,8 @@ end
395416
Get the first `n` elements of the iterable collection `itr`, or fewer elements if `itr` is not
396417
long enough.
397418
419+
See also: [`startswith`](@ref), [`Iterators.take`](@ref).
420+
398421
!!! compat "Julia 1.6"
399422
This method requires at least Julia 1.6.
400423
@@ -426,6 +449,8 @@ Get the last element of an ordered collection, if it can be computed in O(1) tim
426449
accomplished by calling [`lastindex`](@ref) to get the last index. Return the end
427450
point of an [`AbstractRange`](@ref) even if it is empty.
428451
452+
See also [`first`](@ref), [`endswith`](@ref).
453+
429454
# Examples
430455
```jldoctest
431456
julia> last(1:2:10)
@@ -472,6 +497,8 @@ end
472497
473498
Return a tuple of the memory strides in each dimension.
474499
500+
See also: [`stride`](@ref).
501+
475502
# Examples
476503
```jldoctest
477504
julia> A = fill(1, (3,4,5));
@@ -487,6 +514,8 @@ function strides end
487514
488515
Return the distance in memory (in number of elements) between adjacent elements in dimension `k`.
489516
517+
See also: [`strides`](@ref).
518+
490519
# Examples
491520
```jldoctest
492521
julia> A = fill(1, (3,4,5));
@@ -660,6 +689,8 @@ Return `true` if the given `index` is within the bounds of
660689
arrays can extend this method in order to provide a specialized bounds
661690
checking implementation.
662691
692+
See also [`checkbounds`](@ref).
693+
663694
# Examples
664695
```jldoctest
665696
julia> checkindex(Bool, 1:20, 8)
@@ -735,6 +766,7 @@ julia> similar(falses(10), Float64, 2, 4)
735766
2.18425e-314 2.18425e-314 2.18425e-314 2.18425e-314
736767
```
737768
769+
See also: [`undef`](@ref), [`isassigned`](@ref).
738770
"""
739771
similar(a::AbstractArray{T}) where {T} = similar(a, T)
740772
similar(a::AbstractArray, ::Type{T}) where {T} = similar(a, T, to_shape(axes(a)))
@@ -791,6 +823,8 @@ similar(::Type{T}, dims::Dims) where {T<:AbstractArray} = T(undef, dims)
791823
792824
Create an empty vector similar to `v`, optionally changing the `eltype`.
793825
826+
See also: [`empty!`](@ref), [`isempty`](@ref), [`isassigned`](@ref).
827+
794828
# Examples
795829
796830
```jldoctest
@@ -815,6 +849,7 @@ elements in `dst`.
815849
If `dst` and `src` are of the same type, `dst == src` should hold after
816850
the call. If `dst` and `src` are multidimensional arrays, they must have
817851
equal [`axes`](@ref).
852+
818853
See also [`copyto!`](@ref).
819854
820855
!!! compat "Julia 1.1"
@@ -922,11 +957,12 @@ end
922957
"""
923958
copyto!(dest::AbstractArray, src) -> dest
924959
925-
926960
Copy all elements from collection `src` to array `dest`, whose length must be greater than
927961
or equal to the length `n` of `src`. The first `n` elements of `dest` are overwritten,
928962
the other elements are left untouched.
929963
964+
See also [`copy!`](@ref Base.copy!), [`copy`](@ref).
965+
930966
# Examples
931967
```jldoctest
932968
julia> x = [1., 0., 3., 0., 5.];
@@ -2130,18 +2166,28 @@ end
21302166
foreach(f, c...) -> Nothing
21312167
21322168
Call function `f` on each element of iterable `c`.
2133-
For multiple iterable arguments, `f` is called elementwise.
2134-
`foreach` should be used instead of `map` when the results of `f` are not
2169+
For multiple iterable arguments, `f` is called elementwise, and iteration stops when
2170+
any iterator is finished.
2171+
2172+
`foreach` should be used instead of [`map`](@ref) when the results of `f` are not
21352173
needed, for example in `foreach(println, array)`.
21362174
21372175
# Examples
21382176
```jldoctest
2139-
julia> a = 1:3:7;
2177+
julia> tri = 1:3:7; res = Int[];
21402178
2141-
julia> foreach(x -> println(x^2), a)
2142-
1
2143-
16
2144-
49
2179+
julia> foreach(x -> push!(res, x^2), tri)
2180+
2181+
julia> res
2182+
3-element Vector{$(Int)}:
2183+
1
2184+
16
2185+
49
2186+
2187+
julia> foreach((x, y) -> println(x, " with ", y), tri, 'a':'z')
2188+
1 with a
2189+
4 with b
2190+
7 with c
21452191
```
21462192
"""
21472193
foreach(f) = (f(); nothing)
@@ -2162,6 +2208,8 @@ colons go in this expression. The results are concatenated along the remaining d
21622208
For example, if `dims` is `[1,2]` and `A` is 4-dimensional, `f` is called on `A[:,:,i,j]`
21632209
for all `i` and `j`.
21642210
2211+
See also [`eachcol`](@ref), [`eachslice`](@ref).
2212+
21652213
# Examples
21662214
```jldoctest
21672215
julia> a = reshape(Vector(1:16),(2,2,2,2))
@@ -2308,9 +2356,9 @@ mapany(f, itr) = Any[f(x) for x in itr]
23082356
map(f, c...) -> collection
23092357
23102358
Transform collection `c` by applying `f` to each element. For multiple collection arguments,
2311-
apply `f` elementwise.
2359+
apply `f` elementwise, and stop when when any of them is exhausted.
23122360
2313-
See also: [`mapslices`](@ref)
2361+
See also: [`map!`](@ref), [`foreach`](@ref), [`mapreduce`](@ref), [`mapslices`](@ref), [`zip`](@ref), [`Iterators.map`](@ref).
23142362
23152363
# Examples
23162364
```jldoctest
@@ -2320,7 +2368,7 @@ julia> map(x -> x * 2, [1, 2, 3])
23202368
4
23212369
6
23222370
2323-
julia> map(+, [1, 2, 3], [10, 20, 30])
2371+
julia> map(+, [1, 2, 3], [10, 20, 30, 400, 5000])
23242372
3-element Vector{Int64}:
23252373
11
23262374
22
@@ -2365,7 +2413,9 @@ end
23652413
map!(function, destination, collection...)
23662414
23672415
Like [`map`](@ref), but stores the result in `destination` rather than a new
2368-
collection. `destination` must be at least as large as the first collection.
2416+
collection. `destination` must be at least as large as the smallest collection.
2417+
2418+
See also: [`map`](@ref), [`foreach`](@ref), [`zip`](@ref), [`copyto!`](@ref).
23692419
23702420
# Examples
23712421
```jldoctest
@@ -2378,6 +2428,14 @@ julia> a
23782428
2.0
23792429
4.0
23802430
6.0
2431+
2432+
julia> map!(+, zeros(Int, 5), 100:999, 1:3)
2433+
5-element Vector{$(Int)}:
2434+
101
2435+
103
2436+
105
2437+
0
2438+
0
23812439
```
23822440
"""
23832441
function map!(f::F, dest::AbstractArray, As::AbstractArray...) where {F}

base/abstractarraymath.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ julia> vec(1:3)
3636
1:3
3737
```
3838
39-
See also [`reshape`](@ref).
39+
See also [`reshape`](@ref), [`dropdims`](@ref).
4040
"""
4141
vec(a::AbstractArray) = reshape(a,length(a))
4242
vec(a::AbstractVector) = a
@@ -52,6 +52,8 @@ Remove the dimensions specified by `dims` from array `A`.
5252
Elements of `dims` must be unique and within the range `1:ndims(A)`.
5353
`size(A,i)` must equal 1 for all `i` in `dims`.
5454
55+
See also: [`reshape`](@ref), [`vec`](@ref).
56+
5557
# Examples
5658
```jldoctest
5759
julia> a = reshape(Vector(1:4),(2,2,1,1))
@@ -106,6 +108,8 @@ Return a view of all the data of `A` where the index for dimension `d` equals `i
106108
107109
Equivalent to `view(A,:,:,...,i,:,:,...)` where `i` is in position `d`.
108110
111+
See also: [`eachslice`](@ref).
112+
109113
# Examples
110114
```jldoctest
111115
julia> A = [1 2 3 4; 5 6 7 8]
@@ -143,6 +147,8 @@ Circularly shift, i.e. rotate, the data in an array. The second argument is a tu
143147
vector giving the amount to shift in each dimension, or an integer to shift only in the
144148
first dimension.
145149
150+
See also: [`circshift!`](@ref), [`circcopy!`](@ref), [`bitrotate`](@ref), [`<<`](@ref).
151+
146152
# Examples
147153
```jldoctest
148154
julia> b = reshape(Vector(1:16), (4,4))
@@ -190,8 +196,6 @@ julia> circshift(a, -1)
190196
1
191197
1
192198
```
193-
194-
See also [`circshift!`](@ref).
195199
"""
196200
function circshift(a::AbstractArray, shiftamt)
197201
circshift!(similar(a), a, map(Integer, (shiftamt...,)))
@@ -204,6 +208,8 @@ end
204208
205209
Construct an array by repeating array `A` a given number of times in each dimension, specified by `counts`.
206210
211+
See also: [`fill`](@ref), [`Iterators.repeated`](@ref), [`Iterators.cycle`](@ref).
212+
207213
# Examples
208214
```jldoctest
209215
julia> repeat([1, 2, 3], 2)
@@ -397,7 +403,7 @@ end#module
397403
Create a generator that iterates over the first dimension of vector or matrix `A`,
398404
returning the rows as `AbstractVector` views.
399405
400-
See also [`eachcol`](@ref) and [`eachslice`](@ref).
406+
See also [`eachcol`](@ref), [`eachslice`](@ref), [`mapslices`](@ref).
401407
402408
!!! compat "Julia 1.1"
403409
This function requires at least Julia 1.1.
@@ -465,7 +471,7 @@ the data from the other dimensions in `A`.
465471
Only a single dimension in `dims` is currently supported. Equivalent to `(view(A,:,:,...,i,:,:
466472
...)) for i in axes(A, dims))`, where `i` is in position `dims`.
467473
468-
See also [`eachrow`](@ref), [`eachcol`](@ref), and [`selectdim`](@ref).
474+
See also [`eachrow`](@ref), [`eachcol`](@ref), [`mapslices`](@ref), and [`selectdim`](@ref).
469475
470476
!!! compat "Julia 1.1"
471477
This function requires at least Julia 1.1.

base/abstractset.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ copy!(dst::AbstractSet, src::AbstractSet) = union!(empty!(dst), src)
1313
1414
Construct the union of sets. Maintain order with arrays.
1515
16+
See also: [`intersect`](@ref), [`isdisjoint`](@ref), [`vcat`](@ref), [`Iterators.flatten`](@ref).
17+
1618
# Examples
1719
```jldoctest
1820
julia> union([1, 2], [3, 4])
@@ -101,6 +103,8 @@ end
101103
Construct the intersection of sets.
102104
Maintain order with arrays.
103105
106+
See also: [`setdiff`](@ref), [`isdisjoint`](@ref), [`issubset`](@ref Base.issubset), [`issetequal`](@ref).
107+
104108
# Examples
105109
```jldoctest
106110
julia> intersect([1, 2, 3], [3, 4, 5])
@@ -145,6 +149,8 @@ intersect!(s::AbstractSet, itr) =
145149
Construct the set of elements in `s` but not in any of the iterables in `itrs`.
146150
Maintain order with arrays.
147151
152+
See also [`setdiff!`](@ref), [`union`](@ref) and [`intersect`](@ref).
153+
148154
# Examples
149155
```jldoctest
150156
julia> setdiff([1,2,3], [3,4,5])
@@ -194,6 +200,8 @@ Construct the symmetric difference of elements in the passed in sets.
194200
When `s` is not an `AbstractSet`, the order is maintained.
195201
Note that in this case the multiplicity of elements matters.
196202
203+
See also [`symdiff!`](@ref), [`setdiff`](@ref), [`union`](@ref) and [`intersect`](@ref).
204+
197205
# Examples
198206
```jldoctest
199207
julia> symdiff([1,2,3], [3,4,5], [4,5,6])
@@ -246,7 +254,7 @@ function ⊇ end
246254
247255
Determine whether every element of `a` is also in `b`, using [`in`](@ref).
248256
249-
See also [`⊊`](@ref), [`⊈`](@ref).
257+
See also [`⊊`](@ref), [`⊈`](@ref), [`∩`](@ref intersect), [`∪`](@ref union), [`contains`](@ref).
250258
251259
# Examples
252260
```jldoctest
@@ -357,6 +365,8 @@ false
357365
Determine whether `a` and `b` have the same elements. Equivalent
358366
to `a ⊆ b && b ⊆ a` but more efficient when possible.
359367
368+
See also: [`isdisjoint`](@ref), [`union`](@ref).
369+
360370
# Examples
361371
```jldoctest
362372
julia> issetequal([1, 2], [1, 2, 3])
@@ -390,6 +400,8 @@ end
390400
Return whether the collections `v1` and `v2` are disjoint, i.e. whether
391401
their intersection is empty.
392402
403+
See also: [`issetequal`](@ref), [`intersect`](@ref).
404+
393405
!!! compat "Julia 1.5"
394406
This function requires at least Julia 1.5.
395407
"""

0 commit comments

Comments
 (0)