Skip to content

Commit

Permalink
Use julia-repl in documentation
Browse files Browse the repository at this point in the history
With the highlighting updates in Documenter v0.10.1 it is now possible
to have specialized highlighting for REPL blocks via the julia-repl
attribute on code blocks. Doctests already use this, so this makes the
highlighting for non-doctest REPL blocks consistent.
  • Loading branch information
mortenpi committed May 25, 2017
1 parent 298fffb commit 014c5d5
Show file tree
Hide file tree
Showing 38 changed files with 215 additions and 216 deletions.
6 changes: 3 additions & 3 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ default is an `Array{element_type}(dims...)`.
For example, `similar(1:10, 1, 4)` returns an uninitialized `Array{Int,2}` since ranges are
neither mutable nor support 2 dimensions:
```julia
```julia-repl
julia> similar(1:10, 1, 4)
1×4 Array{Int64,2}:
4419743872 4374413872 4419743888 0
Expand All @@ -489,7 +489,7 @@ julia> similar(1:10, 1, 4)
Conversely, `similar(trues(10,10), 2)` returns an uninitialized `BitVector` with two
elements since `BitArray`s are both mutable and can support 1-dimensional arrays:
```julia
```julia-repl
julia> similar(trues(10,10), 2)
2-element BitArray{1}:
false
Expand All @@ -499,7 +499,7 @@ julia> similar(trues(10,10), 2)
Since `BitArray`s can only store elements of type `Bool`, however, if you request a
different element type it will create a regular `Array` instead:
```julia
```julia-repl
julia> similar(falses(10), Float64, 2, 4)
2×4 Array{Float64,2}:
2.18425e-314 2.18425e-314 2.18425e-314 2.18425e-314
Expand Down
2 changes: 1 addition & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ julia> resize!([6, 5, 4, 3, 2, 1], 3)
4
```
```julia
```julia-repl
julia> resize!([6, 5, 4, 3, 2, 1], 8)
8-element Array{Int64,1}:
6
Expand Down
2 changes: 1 addition & 1 deletion base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ end
Construct an uninitialized `BitArray` with the given dimensions.
Behaves identically to the [`Array`](@ref) constructor.
```julia
```julia-repl
julia> BitArray(2, 2)
2×2 BitArray{2}:
false false
Expand Down
2 changes: 1 addition & 1 deletion base/distributed/pmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ which is then returned inline with the results to the caller.
Consider the following two examples. The first one returns the exception object inline,
the second a 0 in place of any exception:
```julia
```julia-repl
julia> pmap(x->iseven(x) ? error("foo") : x, 1:4; on_error=identity)
4-element Array{Any,1}:
1
Expand Down
5 changes: 2 additions & 3 deletions base/libgit2/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ is in the repository.
# Example
```julia
```julia-repl
julia> repo = LibGit2.GitRepo(repo_path);
julia> LibGit2.add!(repo, test_file);
Expand Down Expand Up @@ -220,7 +220,7 @@ Returns `true` if `a`, a [`GitHash`](@ref) in string form, is an ancestor of
# Example
```julia
```julia-repl
julia> repo = LibGit2.GitRepo(repo_path);
julia> LibGit2.add!(repo, test_file1);
Expand Down Expand Up @@ -954,4 +954,3 @@ end


end # module

2 changes: 1 addition & 1 deletion base/libgit2/reference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ end
Returns a shortened version of the name of `ref` that's
"human-readable".
```julia
```julia-repl
julia> repo = LibGit2.GitRepo(path_to_repo);
julia> branch_ref = LibGit2.head(repo);
Expand Down
8 changes: 4 additions & 4 deletions base/libgit2/remote.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Get the URL of a remote git repository.
# Example
```julia
```julia-repl
julia> repo_url = "https://github.com/JuliaLang/Example.jl";
julia> repo = LibGit2.clone(cache_repo, "test_directory");
Expand All @@ -104,7 +104,7 @@ the name will be an empty string `""`.
# Example
```julia
```julia-repl
julia> repo_url = "https://github.com/JuliaLang/Example.jl";
julia> repo = LibGit2.clone(cache_repo, "test_directory");
Expand Down Expand Up @@ -158,7 +158,7 @@ Add a *fetch* refspec for the specified `rmt`. This refspec will contain
information about which branch(es) to fetch from.
# Example
```julia
```julia-repl
julia> LibGit2.add_fetch!(repo, remote, "upstream");
julia> LibGit2.fetch_refspecs(remote)
Expand All @@ -178,7 +178,7 @@ Add a *push* refspec for the specified `rmt`. This refspec will contain
information about which branch(es) to push to.
# Example
```julia
```julia-repl
julia> LibGit2.add_push!(repo, remote, "refs/heads/master");
julia> remote = LibGit2.get(LibGit2.GitRemote, repo, branch);
Expand Down
2 changes: 1 addition & 1 deletion base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ their indices; any offset results in a (circular) wraparound. If the
arrays have overlapping indices, then on the domain of the overlap
`dest` agrees with `src`.
```julia
```julia-repl
julia> src = reshape(collect(1:16), (4,4))
4×4 Array{Int64,2}:
1 5 9 13
Expand Down
2 changes: 1 addition & 1 deletion base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ after the ending quote, to change its behaviour:
For example, this regex has all three flags enabled:
```julia
```julia-repl
julia> match(r"a+.*b+.*?d\$"ism, "Goodbye,\\nOh, angry,\\nBad world\\n")
RegexMatch("angry,\\nBad world")
```
Expand Down
16 changes: 8 additions & 8 deletions base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ gc_bytes() = ccall(:jl_gc_total_bytes, Int64, ())
Set a timer to be read by the next call to [`toc`](@ref) or [`toq`](@ref). The
macro call `@time expr` can also be used to time evaluation.
```julia
```julia-repl
julia> tic()
0x0000c45bc7abac95
Expand All @@ -105,7 +105,7 @@ end
Return, but do not print, the time elapsed since the last [`tic`](@ref). The
macro calls `@timed expr` and `@elapsed expr` also return evaluation time.
```julia
```julia-repl
julia> tic()
0x0000c46477a9675d
Expand All @@ -132,7 +132,7 @@ end
Print and return the time elapsed since the last [`tic`](@ref). The macro call
`@time expr` can also be used to time evaluation.
```julia
```julia-repl
julia> tic()
0x0000c45bc7abac95
Expand Down Expand Up @@ -219,7 +219,7 @@ returning the value of the expression.
See also [`@timev`](@ref), [`@timed`](@ref), [`@elapsed`](@ref), and
[`@allocated`](@ref).
```julia
```julia-repl
julia> @time rand(10^6);
0.001525 seconds (7 allocations: 7.630 MiB)
Expand Down Expand Up @@ -253,7 +253,7 @@ expression.
See also [`@time`](@ref), [`@timed`](@ref), [`@elapsed`](@ref), and
[`@allocated`](@ref).
```julia
```julia-repl
julia> @timev rand(10^6);
0.001006 seconds (7 allocations: 7.630 MiB)
elapsed time (ns): 1005567
Expand Down Expand Up @@ -282,7 +282,7 @@ number of seconds it took to execute as a floating-point number.
See also [`@time`](@ref), [`@timev`](@ref), [`@timed`](@ref),
and [`@allocated`](@ref).
```julia
```julia-repl
julia> @elapsed sleep(0.3)
0.301391426
```
Expand Down Expand Up @@ -314,7 +314,7 @@ for the effects of compilation.
See also [`@time`](@ref), [`@timev`](@ref), [`@timed`](@ref),
and [`@elapsed`](@ref).
```julia
```julia-repl
julia> @allocated rand(10^6)
8000080
```
Expand Down Expand Up @@ -343,7 +343,7 @@ counters.
See also [`@time`](@ref), [`@timev`](@ref), [`@elapsed`](@ref), and
[`@allocated`](@ref).
```julia
```julia-repl
julia> val, t, bytes, gctime, memallocs = @timed rand(10^6);
julia> t
Expand Down
2 changes: 1 addition & 1 deletion doc/src/devdocs/backtraces.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ No matter the error, we will always need to know what version of Julia you are r
first starts up, a header is printed out with a version number and date. If your version is
`0.2.0` or higher, please include the output of `versioninfo()` in any report you create:

```julia
```julia-repl
julia> versioninfo()
Julia Version 0.3.3-pre+25
Commit 417b50a* (2014-11-03 11:32 UTC)
Expand Down
2 changes: 1 addition & 1 deletion doc/src/devdocs/cartesian.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ is `@nref 3 A i` (as in `A[i_1,i_2,i_3]`, where the array comes first).
If you're developing code with Cartesian, you may find that debugging is easier when you examine
the generated code, using `macroexpand`:

```julia
```julia-repl
julia> macroexpand(:(@nref 2 A i))
:(A[i_1,i_2])
```
Expand Down
14 changes: 7 additions & 7 deletions doc/src/devdocs/reflection.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The names of `DataType` fields may be interrogated using [`fieldnames()`](@ref).
given the following type, `fieldnames(Point)` returns an arrays of [`Symbol`](@ref) elements representing
the field names:

```julia
```julia-repl
julia> struct Point
x::Int
y
Expand All @@ -29,7 +29,7 @@ julia> fieldnames(Point)
The type of each field in a `Point` object is stored in the `types` field of the `Point` variable
itself:

```julia
```julia-repl
julia> Point.types
svec(Int64,Any)
```
Expand All @@ -39,7 +39,7 @@ defaults to the `Any` type.

Types are themselves represented as a structure called `DataType`:

```julia
```julia-repl
julia> typeof(Point)
DataType
```
Expand All @@ -52,7 +52,7 @@ of these fields is the `types` field observed in the example above.
The *direct* subtypes of any `DataType` may be listed using [`subtypes()`](@ref). For example,
the abstract `DataType``AbstractFloat` has four (concrete) subtypes:

```julia
```julia-repl
julia> subtypes(AbstractFloat)
4-element Array{DataType,1}:
BigFloat
Expand Down Expand Up @@ -83,7 +83,7 @@ the unquoted and interpolated expression (`Expr`) form for a given macro. To use
`quote` the expression block itself (otherwise, the macro will be evaluated and the result will
be passed instead!). For example:

```julia
```julia-repl
julia> macroexpand( :(@edit println("")) )
:((Base.edit)(println,(Base.typesof)("")))
```
Expand All @@ -95,7 +95,7 @@ Finally, the [`expand()`](@ref) function gives the `lowered` form of any express
particular interest for understanding both macros and top-level statements such as function declarations
and variable assignments:

```julia
```julia-repl
julia> expand( :(f() = 1) )
:(begin
$(Expr(:method, :f))
Expand Down Expand Up @@ -123,7 +123,7 @@ generation for any function which has not previously been called).
For convenience, there are macro versions of the above functions which take standard function
calls and expand argument types automatically:

```julia
```julia-repl
julia> @code_llvm +(1,1)
; Function Attrs: sspreq
Expand Down
8 changes: 4 additions & 4 deletions doc/src/devdocs/subarrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ If in our example above `A` is a `Array{Float64, 3}`, our `S1` case above would
Note in particular the tuple parameter, which stores the types of the indices used to create
`S1`. Likewise,

```julia
```julia-repl
julia> S1.indexes
(Colon(),5,2:6)
```
Expand Down Expand Up @@ -137,7 +137,7 @@ For `SubArray` types, the availability of efficient linear indexing is based pur
of the indices, and does not depend on values like the size of the parent array. You can ask whether
a given set of indices supports fast linear indexing with the internal `Base.viewindexing` function:

```julia
```julia-repl
julia> Base.viewindexing(S1.indexes)
IndexCartesian()
Expand All @@ -152,7 +152,7 @@ we can define dispatch directly on `SubArray{T,N,A,I,true}` without any intermed
Since this computation doesn't depend on runtime values, it can miss some cases in which the stride
happens to be uniform:

```julia
```julia-repl
julia> A = reshape(1:4*2, 4, 2)
4×2 Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}}:
1 5
Expand All @@ -171,7 +171,7 @@ A view constructed as `view(A, 2:2:4, :)` happens to have uniform stride, and th
indexing indeed could be performed efficiently. However, success in this case depends on the
size of the array: if the first dimension instead were odd,

```julia
```julia-repl
julia> A = reshape(1:5*2, 5, 2)
5×2 Base.ReshapedArray{Int64,2,UnitRange{Int64},Tuple{}}:
1 6
Expand Down
8 changes: 4 additions & 4 deletions doc/src/devdocs/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Array{T,N}
These can be distinguished by examining the `name` field of the type, which is an object of type
`TypeName`:

```julia
```julia-repl
julia> dump(Array{Int,1}.name)
TypeName
name: Symbol Array
Expand Down Expand Up @@ -207,7 +207,7 @@ TypeName
In this case, the relevant field is `wrapper`, which holds a reference to the top-level type used
to make new `Array` types.

```julia
```julia-repl
julia> pointer_from_objref(Array)
Ptr{Void} @0x00007fcc7de64850
Expand Down Expand Up @@ -299,7 +299,7 @@ Union{}

What is the "primary" tuple-type?

```julia
```julia-repl
julia> pointer_from_objref(Tuple)
Ptr{Void} @0x00007f5998a04370
Expand Down Expand Up @@ -461,7 +461,7 @@ Build Julia with `make debug` and fire up Julia within a debugger.
Because the subtyping code is used heavily in the REPL itself--and hence breakpoints in this
code get triggered often--it will be easiest if you make the following definition:

```julia
```julia-repl
julia> function mysubtype(a,b)
ccall(:jl_breakpoint, Void, (Any,), nothing)
issubtype(a, b)
Expand Down
Loading

0 comments on commit 014c5d5

Please sign in to comment.