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

Update MIME docstring #56942

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Changes from 6 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
40 changes: 35 additions & 5 deletions base/multimedia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,48 @@ export AbstractDisplay, display, pushdisplay, popdisplay, displayable, redisplay
"""
MIME

A type representing a standard internet data format. "MIME" stands for
"Multipurpose Internet Mail Extensions", since the standard was originally
used to describe multimedia attachments to email messages.
A parametric type representing a standard internet data format.
nathanrboyer marked this conversation as resolved.
Show resolved Hide resolved

A `MIME` object can be passed as the second argument to [`show`](@ref) to
request output in that format.
"MIME" stands for "Multipurpose Internet Mail Extensions", since the standard was originally
used to describe multimedia attachments to email messages.
The [current standard](https://www.iana.org/assignments/media-types/media-types.xhtml),
maintained by the Internet Assigned Numbers Authority,
now refers to "MIME types" as "media types".
Each media type is defined as a string in the form `"<type>/<subtype>"`.
There are over one thousand official media types,
but in practice only a few are usually supported.
nathanrboyer marked this conversation as resolved.
Show resolved Hide resolved
Some common MIMEs are `"text/plain"``, `"text/html"``, `"image/jpeg"``, `"video/mpeg"``.
nathanrboyer marked this conversation as resolved.
Show resolved Hide resolved
Unofficial custom MIMEs are also supported.
nathanrboyer marked this conversation as resolved.
Show resolved Hide resolved

A specific singleton MIME **type** is constructed by passing the MIME string as a symbol,
e.g. `MIME{Symbol("text/plain")}`.
[`@MIME_str`](@ref) is defined to simplify creation of singleton types in this way,
e.g. `MIME"text/plain"`.
stevengj marked this conversation as resolved.
Show resolved Hide resolved
Singleton MIME types can be used to add new methods to the [`show`](@ref) function.

A `MIME` **object** is created by calling the MIME constructor, either directly,
nathanrboyer marked this conversation as resolved.
Show resolved Hide resolved
e.g. `MIME("text/plain")`, or after the string macro, e.g. `MIME"text/plain"()`.
A `MIME` object can be passed as the second argument to [`show`](@ref)
to request output in that format.
stevengj marked this conversation as resolved.
Show resolved Hide resolved

# Examples
```jldoctest
julia> show(stdout, MIME("text/plain"), "hi")
"hi"
```

```jldoctest
julia> struct MyType
val
end

julia> import Base.show

julia> show(io::IO, ::MIME"text/plain", x::MyType) = print(io, "My Value is ", x.val);
nathanrboyer marked this conversation as resolved.
Show resolved Hide resolved

julia> show(stdout, MIME"text/plain"(), MyType(5))
My Value is 5
```
"""
struct MIME{mime} end

Expand Down
Loading