1
function printsequence(io::IO, source::Enumerable)
2 47
    T = eltype(source)
3 39
    rows = Base.IteratorSize(source) == Base.HasLength() ? length(source) : "?"
4

5 39
    print(io, "$(rows)-element query result")
6

7
    max_element_to_show = 10
8

9
    i = 1
10 39
    foo = iterate(source)
11 47
    while foo!==nothing
12
        v, s = foo
13 39
        println(io)
14 47
        if i==max_element_to_show+1
15 0
            print(io, "... with ")
16
            if Base.IteratorSize(source)!=Base.HasLength()
17
                print(io, " more elements")
18
            else
19 0
                extra_rows = length(source) - max_element_to_show
20 0
                print(io, "$extra_rows more $(extra_rows==1 ? "element" : "elements")")
21
            end
22 0
            break
23
        else
24 39
            print(io, " ")
25 39
            show(IOContext(io, :compact => true), v)
26
        end
27 39
        i += 1
28

29 47
        foo = iterate(source, s)
30
    end
31
end
32

33
function Base.show(io::IO, source::Enumerable)
34 47
    if eltype(source) <: NamedTuple
35 47
        TableShowUtils.printtable(io, source, "query result")
36
    else
37 47
        printsequence(io, source)
38
    end
39
end
40

41
function Base.show(io::IO, ::MIME"text/html", source::Enumerable)
42 47
    if eltype(source) <: NamedTuple
43 47
        TableShowUtils.printHTMLtable(io, source)
44
    else
45
        error("Cannot write this Enumerable as text/html.")
46
    end
47
end
48

49
function Base.Multimedia.showable(::MIME"text/html", source::Enumerable)
50 0
    return eltype(source) <: NamedTuple
51
end
52

53
function Base.show(io::IO, ::MIME"application/vnd.dataresource+json", source::Enumerable)
54 47
    if eltype(source) <: NamedTuple
55 47
        TableShowUtils.printdataresource(io, source)
56
    else
57
        error("Cannot write this Enumerable as 'application/vnd.dataresource+json'.")
58
    end
59
end
60

61
function Base.Multimedia.showable(::MIME"application/vnd.dataresource+json", source::Enumerable)
62 0
    return eltype(source) <: NamedTuple
63
end

Read our documentation on viewing source code .

Loading