Skip to content

Commit

Permalink
revert mistaken docstring change -- read! vs readbytes!
Browse files Browse the repository at this point in the history
update base/docs/helpdb/Base.jl

update rst docs, BBEditTextWrangler-julia.plist

replace missing chomp() in getmetabranch()

doc tweaks

make && make julia-genstdlib

more doc tweaks

whitespace tweak

doc: read!(stream or filename, ...)
  • Loading branch information
samoconnor committed Jan 14, 2016
1 parent 8279ec9 commit fd6b27f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 54 deletions.
36 changes: 14 additions & 22 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ the same object. `fill!(A, Foo())` will return `A` filled with the result of eva
fill!

"""
read!(stream, array::Array)
read!(stream or filename, array::Array)
Read binary data from a stream, filling in the argument `array`.
Read binary data from a stream or file, filling in the argument `array`.
"""
read!

Expand Down Expand Up @@ -452,7 +452,7 @@ the mantissa.
precision

"""
readlines(stream)
readlines(stream or filename)
Read all lines as an array.
"""
Expand Down Expand Up @@ -1018,7 +1018,7 @@ See `rounding` for available rounding modes.
Float32

"""
readuntil(stream, delim)
readuntil(stream or filename, delim)
Read a string, up to and including the given delimiter byte.
"""
Expand Down Expand Up @@ -2438,19 +2438,11 @@ the process.
triu!(M, k)

"""
readstring(stream::IO)
readstring(stream or filename)
Read the entire contents of an I/O stream as a string.
Read the entire contents of an I/O stream or a file as a string.
"""
readstring(stream::IO)

"""
readstring(filename::AbstractString)
Open `filename`, read the entire contents as a string, then close the file. Equivalent to
`open(readstring, filename)`.
"""
readstring(filename::AbstractString)
readstring

"""
poll_file(path, interval_s::Real, timeout_s::Real) -> (previous::StatStruct, current::StatStruct)
Expand All @@ -2468,9 +2460,9 @@ it is more reliable and efficient, although in some situations it may not be ava
poll_file

"""
eachline(stream)
eachline(stream or filename)
Create an iterable object that will yield each line from a stream.
Create an iterable object that will yield each line.
"""
eachline

Expand Down Expand Up @@ -4251,9 +4243,9 @@ Squared absolute value of `x`.
abs2

"""
write(stream, x)
write(stream or filename, x)
Write the canonical binary representation of a value to the given stream. Returns the number
Write the canonical binary representation of a value to the given stream or file. Returns the number
of bytes written into the stream.
You can write multiple values with the same :func:`write` call. i.e. the following are
Expand Down Expand Up @@ -6445,7 +6437,7 @@ Read at most `nb` bytes from the stream into `b`, returning the number of bytes
See `read` for a description of the `all` option.
"""
read!
readbytes!

"""
basename(path::AbstractString) -> AbstractString
Expand Down Expand Up @@ -7423,10 +7415,10 @@ Return the supertype of DataType `T`.
supertype

"""
readline(stream=STDIN)
readline(stream=STDIN or filename)
Read a single line of text, including a trailing newline character (if one is reached before
the end of the input), from the given `stream` (defaults to `STDIN`),
the end of the input), from the given stream or file (defaults to `STDIN`),
"""
readline

Expand Down
2 changes: 1 addition & 1 deletion base/pkg/dir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ end

function getmetabranch()
try
readline(joinpath(path(),"META_BRANCH"))
chomp(readline(joinpath(path(),"META_BRANCH")))
catch err
META_BRANCH
end
Expand Down
2 changes: 1 addition & 1 deletion base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ disassociate_julia_struct(handle::Ptr{Void}) =
function init_stdio(handle::Ptr{Void})
t = ccall(:jl_uv_handle_type, Int32, (Ptr{Void},), handle)
if t == UV_FILE
return File(RawFD(ccall(:jl_uv_file_handle,Int32,(Ptr{Void},),handle)))
return File(RawFD(ccall(:jl_uv_file_handle,Int32,(Ptr{Void},),handle)))
else
if t == UV_TTY
ret = TTY(handle)
Expand Down
3 changes: 1 addition & 2 deletions contrib/BBEditTextWrangler-julia.plist
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,9 @@
<string>rationalize</string>
<string>read</string>
<string>read!</string>
<string>readall</string>
<string>readstring</string>
<string>readandwrite</string>
<string>readavailable</string>
<string>readbytes</string>
<string>readbytes!</string>
<string>readchomp</string>
<string>readcsv</string>
Expand Down
6 changes: 3 additions & 3 deletions doc/manual/networking-and-streams.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ For example, to read a simple byte array, we could do::
However, since this is slightly cumbersome, there are several convenience methods provided. For example, we could have written the
above as::

julia> readbytes(STDIN,4)
julia> read(STDIN,4)
abcd
4-element Array{UInt8,1}:
0x61
Expand Down Expand Up @@ -142,7 +142,7 @@ as its first argument and filename as its second, opens the file, calls the func
an argument, and then closes it again. For example, given a function::

function read_and_capitalize(f::IOStream)
return uppercase(readall(f))
return uppercase(readstring(f))
end

You can call::
Expand All @@ -156,7 +156,7 @@ To avoid even having to define a named function, you can use the ``do`` syntax,
function on the fly::

julia> open("hello.txt") do f
uppercase(readall(f))
uppercase(readstring(f))
end
"HELLO AGAIN."

Expand Down
8 changes: 4 additions & 4 deletions doc/manual/running-external-programs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ The ``hello`` is the output of the ``echo`` command, sent to :const:`STDOUT`.
The run method itself returns ``nothing``, and throws an :exc:`ErrorException`
if the external command fails to run successfully.

If you want to read the output of the external command, :func:`readall`
If you want to read the output of the external command, :func:`readstring`
can be used instead:

.. doctest::

julia> a=readall(`echo hello`)
julia> a=readstring(`echo hello`)
"hello\n"

julia> (chomp(a)) == "hello"
Expand Down Expand Up @@ -314,7 +314,7 @@ When reading and writing to both ends of a pipeline from a single process,
it is important to avoid forcing the kernel to buffer all of the data.

For example, when reading all of the output from a command,
call ``readall(out)``, not ``wait(process)``, since the former
call ``read(out)``, not ``wait(process)``, since the former
will actively consume all of the data written by the process,
whereas the latter will attempt to store the data in the kernel's
buffers while waiting for a reader to be connected.
Expand All @@ -323,7 +323,7 @@ Another common solution is to separate the reader and writer
of the pipeline into separate Tasks::

writer = @async writeall(process, "data")
reader = @async do_compute(readall(process))
reader = @async do_compute(read(process))
wait(process)
fetch(reader)

Expand Down
36 changes: 15 additions & 21 deletions doc/stdlib/io-network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ General I/O
Apply the function ``f`` to the result of ``open(args...)`` and close the resulting file descriptor upon completion.

**Example**: ``open(readall, "file.txt")``
**Example**: ``open(readstring, "file.txt")``

.. function:: IOBuffer() -> IOBuffer

Expand Down Expand Up @@ -121,11 +121,11 @@ General I/O
Close an I/O stream. Performs a ``flush`` first.

.. function:: write(stream, x)
.. function:: write(stream or filename, x)

.. Docstring generated from Julia source
Write the canonical binary representation of a value to the given stream. Returns the number of bytes written into the stream.
Write the canonical binary representation of a value to the given stream or file. Returns the number of bytes written into the stream.

You can write multiple values with the same :func:``write`` call. i.e. the following are equivalent:

Expand All @@ -146,7 +146,7 @@ General I/O
Read a series of values of the given type from a stream, in canonical binary representation. ``dims`` is either a tuple or a series of integer arguments specifying the size of ``Array`` to return.

.. function:: read!(stream, array::Array)
.. function:: read!(stream or filename, array::Array)

.. Docstring generated from Julia source
Expand All @@ -158,9 +158,9 @@ General I/O
Read at most ``nb`` bytes from the stream into ``b``\ , returning the number of bytes read (increasing the size of ``b`` as needed).

See ``readbytes`` for a description of the ``all`` option.
See ``read`` for a description of the ``all`` option.

.. function:: readbytes(stream, nb=typemax(Int); all=true)
.. function:: read(stream, nb=typemax(Int); all=true)

.. Docstring generated from Julia source
Expand Down Expand Up @@ -330,7 +330,7 @@ General I/O

.. Docstring generated from Julia source
Read the entirety of ``x`` as a string but remove trailing newlines. Equivalent to ``chomp(readall(x))``\ .
Read the entirety of ``x`` as a string but remove trailing newlines. Equivalent to ``chomp(readstring(x))``\ .

.. function:: truncate(file,n)

Expand Down Expand Up @@ -493,41 +493,35 @@ Text I/O
Show all structure of a value, including all fields of objects.

.. function:: readall(stream::IO)
.. function:: readstring(stream or filename)

.. Docstring generated from Julia source
Read the entire contents of an I/O stream as a string.
Read the entire contents of an I/O stream or a file as a string.

.. function:: readall(filename::AbstractString)
.. function:: readline(stream=STDIN or filename)

.. Docstring generated from Julia source
Open ``filename``\ , read the entire contents as a string, then close the file. Equivalent to ``open(readall, filename)``\ .
Read a single line of text, including a trailing newline character (if one is reached before the end of the input), from the given stream or file (defaults to ``STDIN``\ ),

.. function:: readline(stream=STDIN)

.. Docstring generated from Julia source
Read a single line of text, including a trailing newline character (if one is reached before the end of the input), from the given ``stream`` (defaults to ``STDIN``\ ),

.. function:: readuntil(stream, delim)
.. function:: readuntil(stream or filename, delim)

.. Docstring generated from Julia source
Read a string, up to and including the given delimiter byte.

.. function:: readlines(stream)
.. function:: readlines(stream or filename)

.. Docstring generated from Julia source
Read all lines as an array.

.. function:: eachline(stream)
.. function:: eachline(stream or filename)

.. Docstring generated from Julia source
Create an iterable object that will yield each line from a stream.
Create an iterable object that will yield each line.

.. function:: readdlm(source, delim::Char, T::Type, eol::Char; header=false, skipstart=0, skipblanks=true, use_mmap, ignore_invalid_chars=false, quotes=true, dims, comments=true, comment_char='#')

Expand Down

0 comments on commit fd6b27f

Please sign in to comment.