Skip to content

Commit 298fb19

Browse files
stevengjStefanKarpinski
authored andcommitted
rename mimewritable to showable
1 parent 8143edf commit 298fb19

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

base/deprecated.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,6 +1367,7 @@ end
13671367
@deprecate IOBuffer(maxsize::Integer) IOBuffer(read=true, write=true, maxsize=maxsize)
13681368

13691369
@deprecate reprmime(mime, x) repr(mime, x)
1370+
@deprecate mimewritable(mime, x) showable(mime, x)
13701371

13711372
# PR #23332
13721373
@deprecate ^(x, p::Integer) Base.power_by_squaring(x,p)

base/exports.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,10 +875,10 @@ export
875875
istextmime,
876876
MIME,
877877
@MIME_str,
878-
mimewritable,
879878
popdisplay,
880879
pushdisplay,
881880
redisplay,
881+
showable,
882882
HTML,
883883
Text,
884884

base/multimedia.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Multimedia
44

55
export AbstractDisplay, display, pushdisplay, popdisplay, displayable, redisplay,
66
MIME, @MIME_str, istextmime,
7-
mimewritable, TextDisplay
7+
showable, TextDisplay
88

99
###########################################################################
1010
# We define a singleton type MIME{mime symbol} for each MIME type, so
@@ -25,23 +25,26 @@ print(io::IO, ::MIME{mime}) where {mime} = print(io, mime)
2525
# in order to provide a way to export T as a given mime type.
2626

2727
"""
28-
mimewritable(mime, x)
28+
showable(mime, x)
2929
30-
Returns a boolean value indicating whether or not the object `x` can be written as the given
31-
`mime` type. (By default, this is determined automatically by the existence of the
32-
corresponding [`show`](@ref) method for `typeof(x)`.)
30+
Returns a boolean value indicating whether or not the object `x` can be written
31+
as the given `mime` type.
32+
33+
(By default, this is determined automatically by the existence of the
34+
corresponding [`show`](@ref) method for `typeof(x)`. Some types provide custom `showable`
35+
methods; for example, if the available MIME formats depend on the *value* of `x`.)
3336
3437
# Examples
3538
```jldoctest
36-
julia> mimewritable(MIME("text/plain"), rand(5))
39+
julia> showable(MIME("text/plain"), rand(5))
3740
true
3841
39-
julia> mimewritable(MIME("img/png"), rand(5))
42+
julia> showable("img/png", rand(5))
4043
false
4144
```
4245
"""
43-
mimewritable(::MIME{mime}, x) where {mime} =
44-
hasmethod(show, Tuple{IO, MIME{mime}, typeof(x)})
46+
showable(::MIME{mime}, x) where {mime} = hasmethod(show, Tuple{IO, MIME{mime}, typeof(x)})
47+
showable(m::AbstractString, x) = showable(MIME(m), x)
4548

4649
"""
4750
show(io, mime, x)
@@ -73,10 +76,7 @@ The first argument to `show` can be an [`IOContext`](@ref) specifying output for
7376
See [`IOContext`](@ref) for details.
7477
"""
7578
show(stream, mime, x)
76-
77-
# it is convenient to accept strings instead of ::MIME
7879
show(io::IO, m::AbstractString, x) = show(io, MIME(m), x)
79-
mimewritable(m::AbstractString, x) = mimewritable(MIME(m), x)
8080

8181
"""
8282
repr(mime, x; context=nothing)

doc/src/base/io-network.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Base.Multimedia.display
9393
Base.Multimedia.redisplay
9494
Base.Multimedia.displayable
9595
Base.show(::Any, ::Any, ::Any)
96-
Base.Multimedia.mimewritable
96+
Base.Multimedia.showable
9797
Base.repr(::Any, ::Any)
9898
```
9999

@@ -107,7 +107,7 @@ define a function `display(d::D, ::MIME"mime", x) = ...` that displays `x` as th
107107
usually by calling [`show(io, mime, x)`](@ref) or [`repr(io, mime, x)`](@ref).
108108
A `MethodError` should be thrown if `x` cannot be displayed
109109
as that MIME type; this is automatic if one calls `show` or `repr`. Finally, one should define a function
110-
`display(d::D, x)` that queries [`mimewritable(mime, x)`](@ref) for the `mime` types supported by `D`
110+
`display(d::D, x)` that queries [`showable(mime, x)`](@ref) for the `mime` types supported by `D`
111111
and displays the "best" one; a `MethodError` should be thrown if no supported MIME types are found
112112
for `x`. Similarly, some subtypes may wish to override [`redisplay(d::D, ...)`](@ref Base.Multimedia.redisplay). (Again, one should
113113
`import Base.display` to add new methods to `display`.) The return values of these functions are

stdlib/Markdown/src/render/rich.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222

2323
function bestmime(val)
2424
for mime in ("text/html", "image/svg+xml", "image/png", "text/plain")
25-
mimewritable(mime, val) && return MIME(Symbol(mime))
25+
showable(mime, val) && return MIME(Symbol(mime))
2626
end
2727
error("Cannot render $val to Markdown.")
2828
end

0 commit comments

Comments
 (0)