Skip to content

Commit

Permalink
Move docstrings inline from helpdb to base/trig.jl, `base/number.jl…
Browse files Browse the repository at this point in the history
…`, and `base/parse.jl (#22618)
  • Loading branch information
xorJane authored and tkelman committed Jun 30, 2017
1 parent 88e7fbc commit 46ac6d9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 97 deletions.
93 changes: 0 additions & 93 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,6 @@ Also available as the macro `@assert expr`.
"""
assert

"""
sech(x)
Compute the hyperbolic secant of `x`
"""
sech

"""
unsafe_copy!(dest::Ptr{T}, src::Ptr{T}, N)
Expand Down Expand Up @@ -1271,13 +1264,6 @@ Compile the given function `f` for the argument tuple (of types) `args`, but do
"""
precompile

"""
cot(x)
Compute the cotangent of `x`, where `x` is in radians.
"""
cot

"""
get(collection, key, default)
Expand Down Expand Up @@ -1322,13 +1308,6 @@ Forces synchronization between the in-memory version of a memory-mapped `Array`
"""
Mmap.sync!

"""
csc(x)
Compute the cosecant of `x`, where `x` is in radians.
"""
csc

"""
hash(x[, h::UInt])
Expand Down Expand Up @@ -1396,13 +1375,6 @@ or a composite object and field name (as a symbol) or index.
"""
isdefined

"""
cotd(x)
Compute the cotangent of `x`, where `x` is in degrees.
"""
cotd

"""
wait([x])
Expand Down Expand Up @@ -1681,13 +1653,6 @@ used only with extreme caution, as it can cause memory use to grow without bound
"""
gc_enable

"""
secd(x)
Compute the secant of `x`, where `x` is in degrees.
"""
secd

"""
OverflowError()
Expand Down Expand Up @@ -1754,20 +1719,6 @@ unpredictable.
"""
finalizer

"""
csch(x)
Compute the hyperbolic cosecant of `x`.
"""
csch

"""
sec(x)
Compute the secant of `x`, where `x` is in radians.
"""
sec

"""
TypeError(func::Symbol, context::AbstractString, expected::Type, got)
Expand Down Expand Up @@ -1986,13 +1937,6 @@ retrieved by accessing `m.match` and the captured sequences can be retrieved by
"""
match

"""
coth(x)
Compute the hyperbolic cotangent of `x`.
"""
coth

"""
start(iter) -> state
Expand Down Expand Up @@ -2308,43 +2252,6 @@ Unicode string.)
"""
reverseind

"""
signbit(x)
Returns `true` if the value of the sign of `x` is negative, otherwise `false`.
# Examples
```jldoctest
julia> signbit(-4)
true
julia> signbit(5)
false
julia> signbit(5.5)
false
julia> signbit(-4.1)
true
```
"""
signbit

"""
cscd(x)
Compute the cosecant of `x`, where `x` is in degrees.
"""
cscd

"""
tryparse(type, str, [base])
Like [`parse`](@ref), but returns a [`Nullable`](@ref) of the requested type. The result will be null if the
string does not contain a valid number.
"""
tryparse

"""
exit([code])
Expand Down
21 changes: 21 additions & 0 deletions base/number.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ divrem(x,y) = (div(x,y),rem(x,y))
The floored quotient and modulus after division. Equivalent to `(fld(x,y), mod(x,y))`.
"""
fldmod(x,y) = (fld(x,y),mod(x,y))

"""
signbit(x)
Returns `true` if the value of the sign of `x` is negative, otherwise `false`.
# Examples
```jldoctest
julia> signbit(-4)
true
julia> signbit(5)
false
julia> signbit(5.5)
false
julia> signbit(-4.1)
true
```
"""
signbit(x::Real) = x < 0

"""
Expand Down
6 changes: 6 additions & 0 deletions base/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ end
throw(ArgumentError("invalid base: base must be 2 ≤ base ≤ 62, got $base"))
end

"""
tryparse(type, str, [base])
Like [`parse`](@ref), but returns a [`Nullable`](@ref) of the requested type. The result
will be null if the string does not contain a valid number.
"""
tryparse(::Type{T}, s::AbstractString, base::Integer) where {T<:Integer} =
tryparse_internal(T, s, start(s), endof(s), check_valid_base(base), false)
tryparse(::Type{T}, s::AbstractString) where {T<:Integer} =
Expand Down
25 changes: 21 additions & 4 deletions base/special/trig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,28 @@ cosc(x::Complex{<:AbstractFloat}) = x==0 ? zero(x) : oftype(x,(cospi(x)-sinpi(x)
cosc(x::Complex) = cosc(float(x))
cosc(x::Real) = x==0 || isinf(x) ? zero(x) : (cospi(x)-sinpi(x)/(pi*x))/x

for (finv, f) in ((:sec, :cos), (:csc, :sin), (:cot, :tan),
(:sech, :cosh), (:csch, :sinh), (:coth, :tanh),
(:secd, :cosd), (:cscd, :sind), (:cotd, :tand))
for (finv, f, finvh, fh, finvd, fd, fn) in ((:sec, :cos, :sech, :cosh, :secd, :cosd, "secant"),
(:csc, :sin, :csch, :sinh, :cscd, :sind, "cosecant"),
(:cot, :tan, :coth, :tanh, :cotd, :tand, "cotangent"))
name = string(finv)
hname = string(finvh)
dname = string(finvd)
@eval begin
($finv)(z::T) where {T<:Number} = one(T) / (($f)(z))
@doc """
$($name)(x)
Compute the $($fn) of `x`, where `x` is in radians.
""" ($finv)(z::T) where {T<:Number} = one(T) / (($f)(z))
@doc """
$($hname)(x)
Compute the hyperbolic $($fn) of `x`.
""" ($finvh)(z::T) where {T<:Number} = one(T) / (($fh)(z))
@doc """
$($dname)(x)
Compute the $($fn) of `x`, where `x` is in degrees.
""" ($finvd)(z::T) where {T<:Number} = one(T) / (($fd)(z))
end
end

Expand Down

0 comments on commit 46ac6d9

Please sign in to comment.