• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37527

pending completion
#37527

push

local

web-flow
make `IRShow.method_name` inferrable (#49607)

18 of 18 new or added lines in 3 files covered. (100.0%)

68710 of 81829 relevant lines covered (83.97%)

33068903.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/base/docs/utils.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
# Text / HTML objects
4

5
import .Base: print, show, ==, hash
6

7
export HTML, @html_str
8

9
export HTML, Text
10

11
"""
12
`HTML(s)`: Create an object that renders `s` as html.
13

14
    HTML("<div>foo</div>")
15

16
You can also use a stream for large amounts of data:
17

18
    HTML() do io
19
      println(io, "<div>foo</div>")
20
    end
21

22
!!! warning
23
    `HTML` is currently exported to maintain
24
    backwards compatibility, but this export
25
    is deprecated. It is recommended to use
26
    this type as `Docs.HTML` or to explicitly
27
    import it from `Docs`.
28
"""
29
mutable struct HTML{T}
30
    content::T
31
end
32

33
function HTML(xs...)
×
34
    HTML() do io
×
35
        for x in xs
×
36
            print(io, x)
×
37
        end
×
38
    end
39
end
40

41
show(io::IO, ::MIME"text/html", h::HTML) = print(io, h.content)
×
42
show(io::IO, ::MIME"text/html", h::HTML{<:Function}) = h.content(io)
×
43

44
"""
45
    @html_str -> Docs.HTML
46

47
Create an `HTML` object from a literal string.
48

49
# Examples
50
```jldoctest
51
julia> html"Julia"
52
HTML{String}("Julia")
53
```
54
"""
55
macro html_str(s)
56
    :(HTML($s))
57
end
58

59
function catdoc(xs::HTML...)
×
60
    HTML() do io
×
61
        for x in xs
×
62
            show(io, MIME"text/html"(), x)
×
63
        end
×
64
    end
65
end
66

67
export Text, @text_str
68

69
"""
70
`Text(s)`: Create an object that renders `s` as plain text.
71

72
    Text("foo")
73

74
You can also use a stream for large amounts of data:
75

76
    Text() do io
77
      println(io, "foo")
78
    end
79

80
!!! warning
81
    `Text` is currently exported to maintain
82
    backwards compatibility, but this export
83
    is deprecated. It is recommended to use
84
    this type as `Docs.Text` or to explicitly
85
    import it from `Docs`.
86
"""
87
mutable struct Text{T}
88
    content::T
×
89
end
90

91
print(io::IO, t::Text) = print(io, t.content)
×
92
print(io::IO, t::Text{<:Function}) = t.content(io)
×
93
show(io::IO, t::Text) = print(io, t)
×
94

95
==(t1::T, t2::T) where {T<:Union{HTML,Text}} = t1.content == t2.content
×
96
hash(t::T, h::UInt) where {T<:Union{HTML,Text}} = hash(T, hash(t.content, h))
×
97

98
"""
99
    @text_str -> Docs.Text
100

101
Create a `Text` object from a literal string.
102

103
# Examples
104
```jldoctest
105
julia> text"Julia"
106
Julia
107
```
108
"""
109
macro text_str(s)
110
    :(Text($s))
111
end
112

113
function catdoc(xs::Text...)
×
114
    Text() do io
×
115
        for x in xs
×
116
            show(io, MIME"text/plain"(), x)
×
117
        end
×
118
    end
119
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc