Skip to content

Commit 8dd8ea9

Browse files
authored
Move many IO docstrings inline, cleanup (#19405)
Move many IO docstrings inline, cleanup
1 parent 9a3acdc commit 8dd8ea9

File tree

6 files changed

+65
-77
lines changed

6 files changed

+65
-77
lines changed

base/datafmt.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ invalid_dlm(::Type{UInt32}) = 0xfffffffe
1616
const offs_chunk_size = 5000
1717

1818
countlines(f::AbstractString, eol::Char='\n') = open(io->countlines(io,eol), f)::Int
19+
20+
"""
21+
countlines(io::IO, eol::Char='\\n')
22+
23+
Read `io` until the end of the stream/file and count the number of lines. To specify a file
24+
pass the filename as the first argument. EOL markers other than `'\\n'` are supported by
25+
passing them as the second argument.
26+
"""
1927
function countlines(io::IO, eol::Char='\n')
2028
isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported"))
2129
aeol = UInt8(eol)

base/docs/helpdb/Base.jl

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -764,13 +764,6 @@ Sum elements of `A` over the singleton dimensions of `r`, and write results to `
764764
"""
765765
sum!
766766

767-
"""
768-
parentindexes(A)
769-
770-
From an array view `A`, returns the corresponding indexes in the parent.
771-
"""
772-
parentindexes
773-
774767
"""
775768
display(x)
776769
display(d::Display, x)
@@ -851,16 +844,6 @@ julia> num2hex(2.2)
851844
"""
852845
num2hex
853846

854-
"""
855-
displayable(mime) -> Bool
856-
displayable(d::Display, mime) -> Bool
857-
858-
Returns a boolean value indicating whether the given `mime` type (string) is displayable by
859-
any of the displays in the current display stack, or specifically by the display `d` in the
860-
second variant.
861-
"""
862-
displayable
863-
864847
"""
865848
truncate(file,n)
866849
@@ -924,24 +907,6 @@ creating a new stream.
924907
"""
925908
accept
926909

927-
"""
928-
readstring(stream::IO)
929-
readstring(filename::AbstractString)
930-
931-
Read the entire contents of an I/O stream or a file as a string.
932-
The text is assumed to be encoded in UTF-8.
933-
"""
934-
readstring
935-
936-
"""
937-
eachline(stream::IO)
938-
eachline(filename::AbstractString)
939-
940-
Create an iterable object that will yield each line from an I/O stream or a file.
941-
The text is assumed to be encoded in UTF-8.
942-
"""
943-
eachline
944-
945910
"""
946911
Mmap.Anonymous(name, readonly, create)
947912
@@ -1704,16 +1669,6 @@ julia> minimum(A, 2)
17041669
"""
17051670
minimum(A,dims)
17061671

1707-
"""
1708-
view(A, inds...)
1709-
1710-
Like [`getindex`](:func:`getindex`), but returns a view into the parent array `A` with the
1711-
given indices instead of making a copy. Calling [`getindex`](:func:`getindex`) or
1712-
[`setindex!`](:func:`setindex!`) on the returned [`SubArray`](:obj:`SubArray`) computes the
1713-
indices to the parent array on the fly without checking bounds.
1714-
"""
1715-
view
1716-
17171672
"""
17181673
cot(x)
17191674
@@ -2358,15 +2313,6 @@ Assign `x` to a named field in `value` of composite type. The syntax `a.b = c` c
23582313
"""
23592314
setfield!
23602315

2361-
"""
2362-
countlines(io,[eol::Char])
2363-
2364-
Read `io` until the end of the stream/file and count the number of lines. To specify a file
2365-
pass the filename as the first argument. EOL markers other than '\\n' are supported by
2366-
passing them as the second argument.
2367-
"""
2368-
countlines
2369-
23702316
"""
23712317
.\\(x, y)
23722318
@@ -2429,15 +2375,6 @@ Get the system time in seconds since the epoch, with fairly high (typically, mic
24292375
"""
24302376
time()
24312377

2432-
"""
2433-
TextDisplay(stream)
2434-
2435-
Returns a `TextDisplay <: Display`, which can display any object as the text/plain MIME type
2436-
(only), writing the text representation to the given I/O stream. (The text representation is
2437-
the same as the way an object is printed in the Julia REPL.)
2438-
"""
2439-
TextDisplay
2440-
24412378
"""
24422379
ismatch(r::Regex, s::AbstractString) -> Bool
24432380
@@ -2676,15 +2613,6 @@ Similar to [`show`](:func:`show`), except shows all elements of arrays.
26762613
"""
26772614
showall
26782615

2679-
"""
2680-
mimewritable(mime, x)
2681-
2682-
Returns a boolean value indicating whether or not the object `x` can be written as the given
2683-
`mime` type. (By default, this is determined automatically by the existence of the
2684-
corresponding [`show`](:func:`show`) function for `typeof(x)`.)
2685-
"""
2686-
mimewritable
2687-
26882616
"""
26892617
match(r::Regex, s::AbstractString[, idx::Integer[, addopts]])
26902618

base/io.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ Open a file and read its contents. `args` is passed to `read`: this is equivalen
156156
"""
157157
read(filename::AbstractString, args...) = open(io->read(io, args...), filename)
158158
read!(filename::AbstractString, a) = open(io->read!(io, a), filename)
159-
readstring(filename::AbstractString) = open(readstring, filename)
160159

161160
"""
162161
readuntil(stream::IO, delim)
@@ -499,7 +498,15 @@ function read(s::IO, nb=typemax(Int))
499498
return resize!(b, nr)
500499
end
501500

501+
"""
502+
readstring(stream::IO)
503+
readstring(filename::AbstractString)
504+
505+
Read the entire contents of an I/O stream or a file as a string.
506+
The text is assumed to be encoded in UTF-8.
507+
"""
502508
readstring(s::IO) = String(read(s))
509+
readstring(filename::AbstractString) = open(readstring, filename)
503510

504511
## high-level iterator interfaces ##
505512

@@ -509,6 +516,14 @@ type EachLine
509516
EachLine(stream) = EachLine(stream, ()->nothing)
510517
EachLine(stream, ondone) = new(stream, ondone)
511518
end
519+
520+
"""
521+
eachline(stream::IO)
522+
eachline(filename::AbstractString)
523+
524+
Create an iterable object that will yield each line from an I/O stream or a file.
525+
The text is assumed to be encoded in UTF-8.
526+
"""
512527
eachline(stream::IO) = EachLine(stream)
513528
function eachline(filename::AbstractString)
514529
s = open(filename)

base/multimedia.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ end
2626
# For any type T one can define show(io, ::MIME"type", x::T) = ...
2727
# in order to provide a way to export T as a given mime type.
2828

29+
"""
30+
mimewritable(mime, x)
31+
32+
Returns a boolean value indicating whether or not the object `x` can be written as the given
33+
`mime` type. (By default, this is determined automatically by the existence of the
34+
corresponding [`show`](:func:`show`) method for `typeof(x)`.)
35+
"""
2936
mimewritable{mime}(::MIME{mime}, x) =
3037
method_exists(show, Tuple{IO, MIME{mime}, typeof(x)})
3138

@@ -118,10 +125,27 @@ abstract Display
118125
# it is convenient to accept strings instead of ::MIME
119126
display(d::Display, mime::AbstractString, x) = display(d, MIME(mime), x)
120127
display(mime::AbstractString, x) = display(MIME(mime), x)
128+
129+
"""
130+
displayable(mime) -> Bool
131+
displayable(d::Display, mime) -> Bool
132+
133+
Returns a boolean value indicating whether the given `mime` type (string) is displayable by
134+
any of the displays in the current display stack, or specifically by the display `d` in the
135+
second variant.
136+
"""
121137
displayable(d::Display, mime::AbstractString) = displayable(d, MIME(mime))
122138
displayable(mime::AbstractString) = displayable(MIME(mime))
123139

124140
# simplest display, which only knows how to display text/plain
141+
142+
"""
143+
TextDisplay(io::IO)
144+
145+
Returns a `TextDisplay <: Display`, which can display any object as the text/plain MIME type
146+
(only), writing the text representation to the given I/O stream. (The text representation is
147+
the same as the way an object is printed in the Julia REPL.)
148+
"""
125149
immutable TextDisplay <: Display
126150
io::IO
127151
end

base/subarray.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ parent(V::SubArray) = V.parent
5858
parentindexes(V::SubArray) = V.indexes
5959

6060
parent(a::AbstractArray) = a
61+
"""
62+
parentindexes(A)
63+
64+
From an array view `A`, returns the corresponding indexes in the parent.
65+
"""
6166
parentindexes(a::AbstractArray) = ntuple(i->OneTo(size(a,i)), ndims(a))
6267

6368
## SubArray creation
@@ -68,6 +73,14 @@ parentindexes(a::AbstractArray) = ntuple(i->OneTo(size(a,i)), ndims(a))
6873
_maybe_reshape_parent(A::AbstractArray, ::NTuple{1, Bool}) = reshape(A, Val{1})
6974
_maybe_reshape_parent{_,N}(A::AbstractArray{_,N}, ::NTuple{N, Bool}) = A
7075
_maybe_reshape_parent{N}(A::AbstractArray, ::NTuple{N, Bool}) = reshape(A, Val{N}) # TODO: DEPRECATE FOR #14770
76+
"""
77+
view(A, inds...)
78+
79+
Like [`getindex`](:func:`getindex`), but returns a view into the parent array `A` with the
80+
given indices instead of making a copy. Calling [`getindex`](:func:`getindex`) or
81+
[`setindex!`](:func:`setindex!`) on the returned [`SubArray`](:obj:`SubArray`) computes the
82+
indices to the parent array on the fly without checking bounds.
83+
"""
7184
function view(A::AbstractArray, I::ViewIndex...)
7285
@_inline_meta
7386
@boundscheck checkbounds(A, I...)

doc/stdlib/io-network.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,11 @@ General I/O
398398
399399
Advance the stream until before the first character for which ``predicate`` returns ``false``\ . For example ``skipchars(stream, isspace)`` will skip all whitespace. If keyword argument ``linecomment`` is specified, characters from that character through the end of a line will also be skipped.
400400

401-
.. function:: countlines(io,[eol::Char])
401+
.. function:: countlines(io::IO, eol::Char='\\n')
402402

403403
.. Docstring generated from Julia source
404404
405-
Read ``io`` until the end of the stream/file and count the number of lines. To specify a file pass the filename as the first argument. EOL markers other than '\\n' are supported by passing them as the second argument.
405+
Read ``io`` until the end of the stream/file and count the number of lines. To specify a file pass the filename as the first argument. EOL markers other than ``'\n'`` are supported by passing them as the second argument.
406406

407407
.. function:: PipeBuffer(data::Vector{UInt8}=UInt8[],[maxsize::Int=typemax(Int)])
408408

@@ -780,7 +780,7 @@ Julia environments (such as the IPython-based IJulia notebook).
780780

781781
.. Docstring generated from Julia source
782782
783-
Returns a boolean value indicating whether or not the object ``x`` can be written as the given ``mime`` type. (By default, this is determined automatically by the existence of the corresponding :func:`show` function for ``typeof(x)``\ .)
783+
Returns a boolean value indicating whether or not the object ``x`` can be written as the given ``mime`` type. (By default, this is determined automatically by the existence of the corresponding :func:`show` method for ``typeof(x)``\ .)
784784

785785
.. function:: reprmime(mime, x)
786786

@@ -835,7 +835,7 @@ stack with:
835835
836836
Pop the topmost backend off of the display-backend stack, or the topmost copy of ``d`` in the second variant.
837837

838-
.. function:: TextDisplay(stream)
838+
.. function:: TextDisplay(io::IO)
839839

840840
.. Docstring generated from Julia source
841841

0 commit comments

Comments
 (0)