Skip to content

Commit 944a320

Browse files
authored
fix doctests (#73)
1 parent d2b16d5 commit 944a320

File tree

2 files changed

+7
-29
lines changed

2 files changed

+7
-29
lines changed

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Documenter
22
using TranscodingStreams
3+
using CodecZlib
34

45
makedocs(
56
sitename="TranscodingStreams.jl",

src/stream.jl

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,21 @@ Arguments
9494
Examples
9595
--------
9696
97-
```julia
97+
```jldoctest
9898
julia> using TranscodingStreams
9999
100100
julia> using CodecZlib
101101
102-
julia> file = open(Pkg.dir("TranscodingStreams", "test", "abra.gzip"));
102+
julia> file = open(joinpath(dirname(pathof(CodecZlib)), "..", "test", "abra.gz"));
103103
104104
julia> stream = TranscodingStream(GzipDecompressor(), file)
105-
TranscodingStreams.TranscodingStream{CodecZlib.GzipDecompressor,IOStream}(<mode=idle>)
105+
TranscodingStream{GzipDecompressor,IOStream}(<mode=idle>)
106106
107-
julia> readstring(stream)
107+
julia> String(read(stream))
108108
"abracadabra"
109109
110+
julia> close(stream)
111+
110112
```
111113
"""
112114
function TranscodingStream(codec::Codec, stream::IO;
@@ -251,31 +253,6 @@ Return the number of bytes read from or written to `stream`.
251253
Note that the returned value will be different from that of the underlying
252254
stream wrapped by `stream`. This is because `stream` buffers some data and the
253255
codec may change the length of data.
254-
255-
Examples
256-
--------
257-
258-
```
259-
julia> using CodecZlib, TranscodingStreams
260-
261-
julia> file = open(joinpath(dirname(pathof(CodecZlib)), "..", "test", "abra.gz"));
262-
263-
julia> stream = GzipDecompressorStream(file)
264-
TranscodingStream{GzipDecompressor,IOStream}(<mode=idle>)
265-
266-
julia> position(stream)
267-
0
268-
269-
julia> read(stream, 4)
270-
4-element Array{UInt8,1}:
271-
0x61
272-
0x62
273-
0x72
274-
0x61
275-
276-
julia> position(stream)
277-
4
278-
```
279256
"""
280257
function Base.position(stream::TranscodingStream)
281258
mode = stream.state.mode

0 commit comments

Comments
 (0)