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 display & MIME stuff out of helpDB, xrefs #22890

Merged
merged 2 commits into from
Jul 22, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Move display & MIME stuff out of helpDB, xrefs
  • Loading branch information
kshyatt committed Jul 21, 2017
commit 956be6fe782f0c67392eef69309b7650510e91dc
56 changes: 1 addition & 55 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,22 +391,6 @@ Like [`randsubseq`](@ref), but the results are stored in `S`
"""
randsubseq!

"""
redisplay(x)
redisplay(d::Display, x)
redisplay(mime, x)
redisplay(d::Display, mime, x)

By default, the `redisplay` functions simply call [`display`](@ref).
However, some display backends may override `redisplay` to modify an existing
display of `x` (if any).
Using `redisplay` is also a hint to the backend that `x` may be redisplayed
several times, and the backend may choose to defer the display until
(for example) the next interactive prompt.
"""
redisplay


"""
/(x, y)

Expand All @@ -422,26 +406,6 @@ Show every part of the representation of a value.
"""
dump

"""
display(x)
display(d::Display, x)
display(mime, x)
display(d::Display, mime, x)

Display `x` using the topmost applicable display in the display stack, typically using the
richest supported multimedia output for `x`, with plain-text [`STDOUT`](@ref) output as a fallback.
The `display(d, x)` variant attempts to display `x` on the given display `d` only, throwing
a `MethodError` if `d` cannot display objects of this type.

There are also two variants with a `mime` argument (a MIME type string, such as
`"image/png"`), which attempt to display `x` using the requested MIME type *only*, throwing
a `MethodError` if this type is not supported by either the display(s) or by `x`. With these
variants, one can also supply the "raw" data in the requested MIME type by passing
`x::AbstractString` (for MIME types with text-based storage, such as text/html or
application/postscript) or `x::Vector{UInt8}` (for binary MIME types).
"""
display

"""
tuple(xs...)

Expand Down Expand Up @@ -867,15 +831,6 @@ Seek a stream to the given position.
"""
seek

"""
popdisplay()
popdisplay(d::Display)

Pop the topmost backend off of the display-backend stack, or the topmost copy of `d` in the
second variant.
"""
popdisplay

"""
cglobal((symbol, library) [, type=Void])

Expand Down Expand Up @@ -1400,15 +1355,6 @@ In this example, `b` is a runnable `Task` that hasn't started yet.
"""
Task

"""
pushdisplay(d::Display)

Pushes a new display `d` on top of the global display-backend stack. Calling `display(x)` or
`display(mime, x)` will display `x` on the topmost compatible backend in the stack (i.e.,
the topmost backend that does not throw a `MethodError`).
"""
pushdisplay

"""
StackOverflowError()

Expand Down Expand Up @@ -1451,7 +1397,7 @@ nfields
"""
show(stream, mime, x)

The `display` functions ultimately call `show` in order to write an object `x` as a
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` (usually a memory buffer), if possible. In order
to provide a rich multimedia representation of a user-defined type `T`, it is only necessary
to define a new `show` method for `T`, via: `show(stream, ::MIME"mime", x::T) = ...`,
Expand Down
47 changes: 47 additions & 0 deletions base/multimedia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,26 @@ close(d::TextDisplay) = close(d.io)
# Display that is capable of displaying x (doesn't throw an error)

const displays = Display[]

"""
pushdisplay(d::Display)

Pushes a new display `d` on top of the global display-backend stack. Calling `display(x)` or
`display(mime, x)` will display `x` on the topmost compatible backend in the stack (i.e.,
the topmost backend that does not throw a [`MethodError`](@ref)).
"""
function pushdisplay(d::Display)
global displays
push!(displays, d)
end

"""
popdisplay()
popdisplay(d::Display)

Pop the topmost backend off of the display-backend stack, or the topmost copy of `d` in the
second variant.
"""
popdisplay() = pop!(displays)
function popdisplay(d::Display)
for i = length(displays):-1:1
Expand All @@ -205,6 +221,24 @@ end

xdisplayable(D::Display, args...) = applicable(display, D, args...)

"""
display(x)
display(d::Display, x)
display(mime, x)
display(d::Display, mime, x)

Display `x` using the topmost applicable display in the display stack, typically using the
richest supported multimedia output for `x`, with plain-text [`STDOUT`](@ref) output as a fallback.
The `display(d, x)` variant attempts to display `x` on the given display `d` only, throwing
a [`MethodError`](@ref) if `d` cannot display objects of this type.

There are also two variants with a `mime` argument (a MIME type string, such as
`"image/png"`), which attempt to display `x` using the requested MIME type *only*, throwing
a `MethodError` if this type is not supported by either the display(s) or by `x`. With these
variants, one can also supply the "raw" data in the requested MIME type by passing
`x::AbstractString` (for MIME types with text-based storage, such as text/html or
application/postscript) or `x::Vector{UInt8}` (for binary MIME types).
"""
function display(x)
for i = length(displays):-1:1
if xdisplayable(displays[i], x)
Expand Down Expand Up @@ -251,6 +285,19 @@ end
# for Matlab/Pylab-like stateful plotting interfaces, where
# a plot is created and then modified many times (xlabel, title, etc.).

"""
redisplay(x)
redisplay(d::Display, x)
redisplay(mime, x)
redisplay(d::Display, mime, x)

By default, the `redisplay` functions simply call [`display`](@ref).
However, some display backends may override `redisplay` to modify an existing
display of `x` (if any).
Using `redisplay` is also a hint to the backend that `x` may be redisplayed
several times, and the backend may choose to defer the display until
(for example) the next interactive prompt.
"""
function redisplay(x)
for i = length(displays):-1:1
if xdisplayable(displays[i], x)
Expand Down