Skip to content

Commit

Permalink
Merge pull request #21866 from mortenpi/mp/julia-repl
Browse files Browse the repository at this point in the history
Use julia-repl in manual & other edits
  • Loading branch information
KristofferC authored May 25, 2017
2 parents bac32d3 + 1d20519 commit eaace3b
Show file tree
Hide file tree
Showing 41 changed files with 274 additions and 282 deletions.
6 changes: 3 additions & 3 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,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 @@ -496,7 +496,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 @@ -506,7 +506,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 @@ -713,7 +713,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
2 changes: 1 addition & 1 deletion base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ julia> convert(Int, 3.0)
julia> convert(Int, 3.5)
ERROR: InexactError()
Stacktrace:
[1] convert(::Type{Int64}, ::Float64) at ./float.jl:679
[1] convert(::Type{Int64}, ::Float64) at ./float.jl:680
```
If `T` is a `AbstractFloat` or `Rational` type,
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/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ Get the directory part of a path.
```jldoctest
julia> dirname("/home/myuser")
"/home"
```
See also: [`basename`](@ref)
```
"""
dirname(path::AbstractString) = splitdir(path)[1]

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
```jldoctest
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
14 changes: 2 additions & 12 deletions doc/src/devdocs/backtraces.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,8 @@ 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> versioninfo()
Julia Version 0.3.3-pre+25
Commit 417b50a* (2014-11-03 11:32 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i7 CPU L 640 @ 2.13GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Nehalem)
LAPACK: libopenblas
LIBM: libopenlibm
LLVM: libLLVM-3.3
```@repl
versioninfo()
```

## Segfaults during bootstrap (`sysimg.jl`)
Expand Down
14 changes: 12 additions & 2 deletions doc/src/devdocs/cartesian.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,19 @@ 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
```@meta
DocTestSetup = quote
import Base.Cartesian: @nref
end
```

```jldoctest
julia> macroexpand(:(@nref 2 A i))
:(A[i_1,i_2])
:(A[i_1, i_2])
```

```@meta
DocTestSetup = nothing
```

### Supplying the number of expressions
Expand Down
22 changes: 11 additions & 11 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
```jldoctest struct_point
julia> struct Point
x::Int
y
Expand All @@ -29,17 +29,17 @@ julia> fieldnames(Point)
The type of each field in a `Point` object is stored in the `types` field of the `Point` variable
itself:

```julia
```jldoctest struct_point
julia> Point.types
svec(Int64,Any)
svec(Int64, Any)
```

While `x` is annotated as an `Int`, `y` was unannotated in the type definition, therefore `y`
defaults to the `Any` type.

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

```julia
```jldoctest struct_point
julia> typeof(Point)
DataType
```
Expand All @@ -52,9 +52,9 @@ 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
```jldoctest
julia> subtypes(AbstractFloat)
4-element Array{DataType,1}:
4-element Array{Union{DataType, UnionAll},1}:
BigFloat
Float16
Float32
Expand Down Expand Up @@ -83,9 +83,9 @@ 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
```jldoctest
julia> macroexpand( :(@edit println("")) )
:((Base.edit)(println,(Base.typesof)("")))
:((Base.edit)(println, (Base.typesof)("")))
```

The functions `Base.Meta.show_sexpr()` and [`dump()`](@ref) are used to display S-expr style views
Expand All @@ -95,11 +95,11 @@ 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
```jldoctest
julia> expand( :(f() = 1) )
:(begin
$(Expr(:method, :f))
$(Expr(:method, :f, :((Core.svec)((Core.svec)((Core.Typeof)(f)),(Core.svec)())), CodeInfo(:(begin # none, line 1:
$(Expr(:method, :f, :((Core.svec)((Core.svec)((Core.Typeof)(f)), (Core.svec)())), CodeInfo(:(begin # none, line 1:
return 1
end)), false))
return f
Expand All @@ -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
Loading

0 comments on commit eaace3b

Please sign in to comment.