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

Backports for Julia 1.5-RC1 (or beta2) #36098

Merged
merged 29 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a7c4fd3
fix #36031: Printf bug for BigInt (#36033)
simeonschaub May 28, 2020
91216bf
Update armv7l `-d16` -> `+d32` feature change for LLVM 9+
staticfloat May 28, 2020
53f0393
LibGit2: add resolve_url to RemoteCallbacksStruct for LibGit2 0.99.0 …
diabonas May 29, 2020
5e85387
update NEWS entry for popat!
rfourquet Jun 4, 2020
d01886d
Fix a bug with break/continue/return in at-testset begin end (#36046)
tkf Jun 1, 2020
c7476af
clarify `show` doc strings (#36076)
JeffBezanson Jun 1, 2020
99adb51
Revert "Use norm instead of abs in generic lu factorization (#34575)"…
andreasnoack Jun 2, 2020
3ccc916
rename pop!(vector, idx, [default]) to popat! (#36070)
rfourquet Jun 2, 2020
88b689b
fix #36116, diff(::AbstractRange) returns an Array (#36117)
mbauman Jun 3, 2020
539eab5
fix #36108, printing invalid numeric juxtapositions (#36122)
JeffBezanson Jun 3, 2020
633046e
Fix mkpath error handling (#36126)
simonbyrne Jun 3, 2020
360f5cc
fix #36104, assign global name during type definitions (#36121)
JeffBezanson Jun 4, 2020
fdd4547
Fix zero(::Type{<:TwicePrecision}) for dimensionful quantities (#36113)
sostock Jun 4, 2020
5c236b4
Fix equality for one-element ranges
sostock May 29, 2020
60bab00
fix ImmutableDict(pairs...) constructor (#36143)
rfourquet Jun 4, 2020
2f8eb20
inference: ignore badly behaving generated functions (#36115)
vtjnash Jun 3, 2020
62ea26d
Error when compiling invalid AddrSpacePtrs.
maleadt May 28, 2020
cf26388
Rename AddrSpacePtr to LLVMPtr.
maleadt May 28, 2020
bf34e0a
Mark Tuples with Bottom among their parameters as cacheable (#36152)
martinholters Jun 4, 2020
e4b83af
bump Pkg version
KristofferC Jun 5, 2020
3854131
bump Statistics version
KristofferC Jun 5, 2020
ea15599
Allow non-Function callables to be used in count(f, itr) (#36187)
tkf Jun 8, 2020
6c65ec8
fix #36272: Error with optional argument in anonymous function define…
simeonschaub Jun 15, 2020
8dec8f1
Fix Broadcasting of Bidiagonal (#35281)
ssikdar1 Jun 8, 2020
ee41310
Promote on Rational binary operations (#36279)
Liozou Jun 16, 2020
1cf4720
Remove `init` from `count!` docstring (#36305)
tkf Jun 16, 2020
e2cfc6f
deleteat! : check bounds for the first passed index (#36231)
rfourquet Jun 16, 2020
d3bc87f
Switch `httpbin` tests over to JuliaLang-hosted `httpbin` mock server…
staticfloat Jun 18, 2020
3e5174f
more precise inference of `splatnew` (#35976)
JeffBezanson May 26, 2020
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
Prev Previous commit
Next Next commit
clarify show doc strings (#36076)
fixes #36072

(cherry picked from commit 147d5b1)
  • Loading branch information
JeffBezanson authored and KristofferC committed Jun 4, 2020
commit c7476afb9c816e8bdb76f506e7b5cafc9eea0c52
18 changes: 10 additions & 8 deletions base/multimedia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ showable(::MIME{mime}, @nospecialize x) where {mime} = hasmethod(show, Tuple{IO,
showable(m::AbstractString, @nospecialize x) = showable(MIME(m), x)

"""
show(io, mime, x)
show(io::IO, mime, x)

The [`display`](@ref) functions ultimately call `show` in order to write an object `x` as a
given `mime` type to a given I/O stream `io` (usually a memory buffer), if possible. In order
Expand All @@ -94,18 +94,20 @@ your images to be displayed on any PNG-capable `AbstractDisplay` (such as IJulia
to `import Base.show` in order to add new methods to the built-in Julia function
`show`.

The default MIME type is `MIME"text/plain"`. There is a fallback definition for `text/plain`
output that calls `show` with 2 arguments. Therefore, this case should be handled by
defining a 2-argument `show(io::IO, x::MyType)` method.

Technically, the `MIME"mime"` macro defines a singleton type for the given `mime` string,
which allows us to exploit Julia's dispatch mechanisms in determining how to display objects
of any given type.

The first argument to `show` can be an [`IOContext`](@ref) specifying output format properties.
See [`IOContext`](@ref) for details.
The default MIME type is `MIME"text/plain"`. There is a fallback definition for `text/plain`
output that calls `show` with 2 arguments, so it is not always necessary to add a method
for that case. If a type benefits from custom human-readable output though,
`show(::IO, ::MIME"text/plain", ::T)` should be defined. For example, the `Day` type uses
`1 day` as the output for the `text/plain` MIME type, and `Day(1)` as the output of 2-argument `show`.

Container types generally implement 3-argument `show` by calling `show(io, MIME"text/plain"(), x)`
for elements `x`, with `:compact => true` set in an [`IOContext`](@ref) passed as the first argument.
"""
show(stream, mime, x)
show(stream::IO, mime, x)
show(io::IO, m::AbstractString, x) = show(io, MIME(m), x)

"""
Expand Down
23 changes: 15 additions & 8 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ the properties of that stream (note that `io` can itself be an `IOContext`).

The following properties are in common use:

- `:compact`: Boolean specifying that small values should be printed more compactly, e.g.
- `:compact`: Boolean specifying that values should be printed more compactly, e.g.
that numbers should be printed with fewer digits. This is set when printing array
elements.
elements. `:compact` output should not contain line breaks.
- `:limit`: Boolean specifying that containers should be truncated, e.g. showing `…` in
place of most elements.
- `:displaysize`: A `Tuple{Int,Int}` giving the size in rows and columns to use for text
Expand Down Expand Up @@ -356,14 +356,21 @@ function show_circular(io::IOContext, @nospecialize(x))
end

"""
show(x)
show([io::IO = stdout], x)

Write an informative text representation of a value to the current output stream. New types
should overload `show(io::IO, x)` where the first argument is a stream. The representation used
by `show` generally includes Julia-specific formatting and type information.
Write a text representation of a value `x` to the output stream `io`. New types `T`
should overload `show(io::IO, x::T)`. The representation used by `show` generally
includes Julia-specific formatting and type information, and should be parseable
Julia code when possible.

[`repr`](@ref) returns the output of `show` as a string.

To customize human-readable text output for objects of type `T`, define
`show(io::IO, ::MIME"text/plain", ::T)` instead. Checking the `:compact`
[`IOContext`](@ref) property of `io` in such methods is recommended,
since some containers show their elements by calling this method with
`:compact => true`.

See also [`print`](@ref), which writes un-decorated representations.

# Examples
Expand All @@ -374,10 +381,10 @@ julia> print("Hello World!")
Hello World!
```
"""
show(x) = show(stdout::IO, x)

show(io::IO, @nospecialize(x)) = show_default(io, x)

show(x) = show(stdout::IO, x)

# avoid inferring show_default on the type of `x`
show_default(io::IO, @nospecialize(x)) = _show_default(io, inferencebarrier(x))

Expand Down
4 changes: 2 additions & 2 deletions doc/src/base/io-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Base.IOContext(::IO, ::IOContext)
## Text I/O

```@docs
Base.show(::Any)
Base.show(::IO, ::Any)
Base.summary
Base.print
Base.println
Expand Down Expand Up @@ -93,7 +93,7 @@ Base.AbstractDisplay
Base.Multimedia.display
Base.Multimedia.redisplay
Base.Multimedia.displayable
Base.show(::Any, ::Any, ::Any)
Base.show(::IO, ::Any, ::Any)
Base.Multimedia.showable
Base.repr(::MIME, ::Any)
Base.MIME
Expand Down