Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move things out of helpDB, add some xrefs #22889

Merged
merged 3 commits into from
Jul 21, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 0 additions & 82 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,6 @@ Neither `convert` nor `cconvert` should take a Julia object and turn it into a `
"""
cconvert

"""
assert(cond)

Throw an [`AssertionError`](@ref) if `cond` is `false`.
Also available as the macro `@assert expr`.
"""
assert

"""
unsafe_copy!(dest::Ptr{T}, src::Ptr{T}, N)

Expand Down Expand Up @@ -430,13 +422,6 @@ Show every part of the representation of a value.
"""
dump

"""
isinteractive() -> Bool

Determine whether Julia is running an interactive session.
"""
isinteractive

"""
display(x)
display(d::Display, x)
Expand All @@ -457,14 +442,6 @@ application/postscript) or `x::Vector{UInt8}` (for binary MIME types).
"""
display

"""
print_shortest(io, x)

Print the shortest possible representation, with the minimum number of consecutive non-zero
digits, of number `x`, ensuring that it would parse to the exact same number.
"""
print_shortest

"""
tuple(xs...)

Expand Down Expand Up @@ -677,27 +654,6 @@ julia> copysign(-1, 2)
"""
copysign

"""
@show

Show an expression and result, returning the result.
"""
:@show

"""
showcompact(x)

Show a compact representation of a value.

This is used for printing array elements without repeating type information (which would
be redundant with that printed once for the whole array), and without line breaks inside
the representation of an element.

To offer a compact representation different from its standard one, a custom type should
test `get(io, :compact, false)` in its normal `show` method.
"""
showcompact

"""
getfield(value, name::Symbol)

Expand Down Expand Up @@ -1194,14 +1150,6 @@ Convert a number to a maximum precision representation (typically [`BigInt`](@re
"""
big

"""
quit()

Quit the program indicating that the processes completed successfully. This function calls
`exit(0)` (see [`exit`](@ref)).
"""
quit

"""
typejoin(T, S)

Expand Down Expand Up @@ -1364,14 +1312,6 @@ proceeding.
"""
wait

"""
atexit(f)

Register a zero-argument function `f()` to be called at process exit. `atexit()` hooks are
called in last in first out (LIFO) order and run before object finalizers.
"""
atexit

"""
copy(x)

Expand Down Expand Up @@ -1550,13 +1490,6 @@ values such as `NaN`.
"""
isless

"""
showerror(io, e)

Show a descriptive representation of an exception object.
"""
showerror

"""
error(message::AbstractString)

Expand Down Expand Up @@ -1781,21 +1714,6 @@ end
```
"""
get!(f::Function,collection,key)

"""
@assert cond [text]

Throw an `AssertionError` if `cond` is `false`. Preferred syntax for writing assertions.
Message `text` is optionally displayed upon assertion failure.

# Examples
```jldoctest
julia> @assert iseven(3) "3 is an odd number!"
ERROR: AssertionError: 3 is an odd number!

julia> @assert isodd(3) "What even are numbers?"
```
"""
:@assert

"""
Expand Down
22 changes: 22 additions & 0 deletions base/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,29 @@ systemerror(p, b::Bool; extrainfo=nothing) = b ? throw(Main.Base.SystemError(str

## assertion functions and macros ##


"""
assert(cond)

Throw an [`AssertionError`](@ref) if `cond` is `false`.
Also available as the macro `@assert expr`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are at it, perhaps change to Also available as the macro [`@assert`](@ref).?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm kind of busy rn, if you want to edit the PR to change this (it's a good idea) go wild :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind! Got it, and make docs passes locally.

"""
assert(x) = x ? nothing : throw(Main.Base.AssertionError())

"""
@assert cond [text]

Throw an [`AssertionError`](@ref) if `cond` is `false`. Preferred syntax for writing assertions.
Message `text` is optionally displayed upon assertion failure.

# Examples
```jldoctest
julia> @assert iseven(3) "3 is an odd number!"
ERROR: AssertionError: 3 is an odd number!

julia> @assert isodd(3) "What even are numbers?"
```
"""
macro assert(ex, msgs...)
msg = isempty(msgs) ? ex : msgs[1]
if isa(msg, AbstractString)
Expand Down
6 changes: 6 additions & 0 deletions base/grisu/grisu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ function _print_shortest(io::IO, x::AbstractFloat, dot::Bool, mode, n::Int)
nothing
end

"""
print_shortest(io::IO, x)

Print the shortest possible representation, with the minimum number of consecutive non-zero
digits, of number `x`, ensuring that it would parse to the exact same number.
"""
print_shortest(io::IO, x::AbstractFloat, dot::Bool) = _print_shortest(io, x, dot, SHORTEST, 0)
print_shortest(io::IO, x::Union{AbstractFloat,Integer}) = print_shortest(io, float(x), false)

Expand Down
19 changes: 19 additions & 0 deletions base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,24 @@ processes completed successfully.
"""
exit(n) = ccall(:jl_exit, Void, (Int32,), n)
exit() = exit(0)

"""
quit()

Quit the program indicating that the processes completed successfully. This function calls
`exit(0)` (see [`exit`](@ref)).
"""
quit() = exit()

const roottask = current_task()

is_interactive = false

"""
isinteractive() -> Bool

Determine whether Julia is running an interactive session.
"""
isinteractive() = (is_interactive::Bool)

"""
Expand Down Expand Up @@ -83,6 +96,12 @@ A string containing the full path to the directory containing the `julia` execut

const atexit_hooks = []

"""
atexit(f)

Register a zero-argument function `f()` to be called at process exit. `atexit()` hooks are
called in last in first out (LIFO) order and run before object finalizers.
"""
atexit(f::Function) = (unshift!(atexit_hooks, f); nothing)

function _atexit()
Expand Down
5 changes: 5 additions & 0 deletions base/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ end

# showing exception objects as descriptive error messages

"""
showerror(io, e)

Show a descriptive representation of an exception object.
"""
showerror(io::IO, ex) = show(io, ex)

function showerror(io::IO, ex::BoundsError)
Expand Down
19 changes: 19 additions & 0 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ end

show_supertypes(typ::DataType) = show_supertypes(STDOUT, typ)

"""
@show

Show an expression and result, returning the result.
"""
macro show(exs...)
blk = Expr(:block)
for ex in exs
Expand Down Expand Up @@ -1757,6 +1762,20 @@ function showarray(io::IO, X::AbstractArray, repr::Bool = true; header = true)
end
end

"""
showcompact(x)
showcompact(io::IO, x)

Show a compact representation of a value to `io`. If `io` is not specified, the
default is to print to [`STDOUT`](@ref).

This is used for printing array elements without repeating type information (which would
be redundant with that printed once for the whole array), and without line breaks inside
the representation of an element.

To offer a compact representation different from its standard one, a custom type should
test `get(io, :compact, false)` in its normal [`show`](@ref) method.
"""
showcompact(x) = showcompact(STDOUT, x)
function showcompact(io::IO, x)
if get(io, :compact, false)
Expand Down