Skip to content

Commit

Permalink
Docs fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben J. Ward committed Mar 1, 2018
1 parent 26abc4f commit d7806bd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 44 deletions.
32 changes: 2 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| **Release** | **Documentation** | **Maintainers** |
|:---------------------------------------------------------------:|:-------------------------------------------------------------------------------:|:-------------------------------------------:|
| [![][release-img]][release-url] [![][license-img]][license-url] | [![][docs-stable-img]][docs-stable-url] [![][docs-latest-img]][docs-latest-url] | ![][maintainer-a-img] |
| [![](https://img.shields.io/github/release/BioJulia/BufferedStreams.jl.svg)](https://github.com/BioJulia/BufferedStreams.jl/releases/latest) [![](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/BioJulia/BufferedStreams.jl/blob/master/LICENSE) | [![](https://img.shields.io/badge/docs-stable-blue.svg)](https://biojulia.github.io/BufferedStreams.jl/stable) [![](https://img.shields.io/badge/docs-latest-blue.svg)](https://biojulia.github.io/BufferedStreams.jl/latest) | ![](https://img.shields.io/badge/BioJulia%20Maintainer-Ward9250-orange.svg) |


## Description
Expand All @@ -31,7 +31,7 @@ BufferedStreams.jl is tested against Julia `0.6` and current `0.7-dev` on Linux,

| **PackageEvaluator** | **Latest Build Status** |
|:---------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------:|
| [![][pkg-0.6-img]][pkg-0.6-url] [![][pkg-0.7-img]][pkg-0.7-url] | [![][travis-img]][travis-url] [![][appveyor-img]][appveyor-url] [![][codecov-img]][codecov-url] |
| [![](https://pkg.julialang.org/badges/BufferedStreams_0.6.svg)](https://pkg.julialang.org/detail/BufferedStreams) [![](https://pkg.julialang.org/badges/BufferedStreams_0.7.svg)](https://pkg.julialang.org/detail/BufferedStreams) | [![](https://img.shields.io/travis/BioJulia/BufferedStreams.jl/master.svg?label=Linux+/+macOS)](https://travis-ci.org/BioJulia/BufferedStreams.jl) [![](https://ci.appveyor.com/api/projects/status/0f7jv901adjmp8o7?svg=true)](https://ci.appveyor.com/project/Ward9250/bufferedstreams-jl/branch/master) [![](https://codecov.io/gh/BioJulia/BufferedStreams.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/BioJulia/BufferedStreams.jl) |


## Contributing and Questions
Expand All @@ -45,31 +45,3 @@ If you have a question about
contributing or using this package, you are encouraged to use the
[Bio category of the Julia discourse
site](https://discourse.julialang.org/c/domain/bio).


[release-img]: https://img.shields.io/github/release/BioJulia/BufferedStreams.jl.svg
[release-url]: https://github.com/BioJulia/BufferedStreams.jl/releases/latest

[license-img]: https://img.shields.io/badge/license-MIT-green.svg
[license-url]: https://github.com/BioJulia/BufferedStreams.jl/blob/master/LICENSE

[docs-latest-img]: https://img.shields.io/badge/docs-latest-blue.svg
[docs-latest-url]: https://biojulia.github.io/BufferedStreams.jl/latest
[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg
[docs-stable-url]: https://biojulia.github.io/BufferedStreams.jl/stable

[maintainer-a-img]: https://img.shields.io/badge/BioJulia%20Maintainer-Ward9250-orange.svg

[pkg-0.6-img]: https://pkg.julialang.org/badges/BufferedStreams_0.6.svg
[pkg-0.6-url]: https://pkg.julialang.org/detail/BufferedStreams
[pkg-0.7-img]: https://pkg.julialang.org/badges/BufferedStreams_0.7.svg
[pkg-0.7-url]: https://pkg.julialang.org/detail/BufferedStreams

[travis-img]: https://img.shields.io/travis/BioJulia/BufferedStreams.jl/master.svg?label=Linux+/+macOS
[travis-url]: https://travis-ci.org/BioJulia/BufferedStreams.jl

[appveyor-img]: https://img.shields.io/appveyor/ci/BioJulia/BufferedStreams.jl/master.svg?label=Windows
[appveyor-url]: https://ci.appveyor.com/project/Ward9250/bufferedstreams-jl/branch/master

[codecov-img]: https://codecov.io/gh/BioJulia/BufferedStreams.jl/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/BioJulia/BufferedStreams.jl
9 changes: 3 additions & 6 deletions docs/src/inputstreams.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ end
```
# BufferedInputStream

```@example

```julia
BufferedInputStream(open(filename)) # wrap an IOStream
BufferedInputStream(rand(UInt8, 100)) # wrap a byte array
nothing # hide
```

`BufferedInputStream` wraps a source. A source can be any `IO` object, but more
Expand Down Expand Up @@ -46,7 +46,7 @@ return an array of the bytes from the anchored position to the currened
position, or `upanchor!` to return the index of the anchored position in the
buffer.

```@example
```julia
# print all numbers literals from a stream
stream = BufferedInputStream(source)
while !eof(stream)
Expand All @@ -58,9 +58,6 @@ while !eof(stream)
elseif isanchored(stream)
println(ASCIIString(takeanchored!(stream)))
end
read(stream, UInt8)
nothing # hide
end
```
8 changes: 3 additions & 5 deletions docs/src/outputstreams.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ end
```
# BufferedOutputStream

```@example
```julia
stream = BufferedOutputStream(open(filename, "w")) # wrap an IOStream
nothing # hide
```

`BufferedOutputStream` is the converse to `BufferedInputStream`, wrapping a sink
type. It also works on any writable `IO` type, as well the more specific sink
interface:

```@example
```julia
writebytes(sink::T, buffer::Vector{UInt8}, n::Int, eof::Bool)
nothing # hide
```

This function should consume the first `n` bytes of `buffer`. The `eof` argument
Expand All @@ -31,7 +29,7 @@ indicates data was processed but should not be evicted from the buffer.
`BufferedOutputStream` can be used as a simpler and often faster alternative to
`IOBuffer` for incrementally building strings.

```@example
```julia
out = BufferedOutputStream()
print(out, "Hello")
print(out, " World")
Expand Down
4 changes: 2 additions & 2 deletions src/bufferedoutputstream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function BufferedOutputStream(sink::T, bufsize::Integer=default_buffer_size) whe
if bufsize 0
throw(ArgumentError("buffer size must be positive"))
end
return BufferedOutputStream{T}(sink, Vector{UInt8}(bufsize), 1)
return BufferedOutputStream{T}(sink, Vector{UInt8}(uninitialized, bufsize), 1)
end

function Base.show(io::IO, stream::BufferedOutputStream{T}) where T
Expand Down Expand Up @@ -94,7 +94,7 @@ function Base.write(stream::BufferedOutputStream, data::Vector{UInt8})
written = n
while written < length(data)
flushbuffer!(stream)
n_avail = endof(stream.buffer) - stream.position + 1
n_avail = lastindex(stream.buffer) - stream.position + 1
@assert n_avail > 0
n = min(endof(data) - written, n_avail)
copyto!(stream.buffer, stream.position, data, written + 1, n)
Expand Down
2 changes: 1 addition & 1 deletion src/emptystream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ end
# ----------------------

function BufferedOutputStream()
return BufferedOutputStream(Vector{UInt8}(1024))
return BufferedOutputStream(Vector{UInt8}(uninitialized, 1024))
end

function BufferedOutputStream(data::Vector{UInt8})
Expand Down

0 comments on commit d7806bd

Please sign in to comment.