API

Modules

Types and constants

Functions and macros

Documentation

LazyReports.LazyTable — Type
struct LazyReports.LazyTable

Represents a lazy table.

Supports convert(::Type{Markdown.Table}, lt::LazyTable).

Don't instantiate directly, use lazytable.

source
LazyReports.OpaqueContent — Type
struct OpaqueContent

Represents opaque content with a specific MIME type.

Constructors:

OpaqueContent(data::AbstractVector{UInt8}, mime::MIME)

OpaqueContent(mime::MIME) do io
    # add something to io::IO
end

Example:

content = OpaqueContent(MIME("text/html")) do io println(io, "<p>Hello, World!</p>") end lazyreport(content)

source
LazyReports.lazyreport — Function
lazyreport()
lazyreport(contents...)
lazyreport(contents...)

Generate a lazy report, e.g. a data processing report.

Use lazyreport!(rpt, contents...) to add more content to a report.

Example:

using LazyReports, StructArrays, IntervalSets, Plots

tbl = StructArray(
    col1 = rand(5), col2 = ClosedInterval.(rand(5), rand(5).+1),
    col3 = [rand(3) for i in 1:5], col4 = rand(Bool, 5),
    col5 = [:a, :b, :c, :d, :e], col6 = ["a", "b", "c", "d", "e"],
    col7 = [:(a[1]), :(a[2]), :(a[3]), :(a[4]), :(a[5])]
)

rpt = lazyreport(
    "# New report",
    "Table 1:", tbl
)
lazyreport!(rpt, "Figure 1:", stephist(randn(10^3)))
lazyreport!(rpt, "Figure 2:", histogram2d(randn(10^4), randn(10^4), format = :png))

show(stdout, MIME"text/plain"(), rpt)
show(stdout, MIME"text/html"(), rpt)
show(stdout, MIME"text/markdown"(), rpt)

write_lazyreport("report.txt", rpt)
write_lazyreport("report.html", rpt)
write_lazyreport("report.md", rpt)

Implementation

Do not specialize lazyreport directly, specialize the lower-level function LazyReports.pushcontent! instead.

source
LazyReports.lazytable — Function
lazytable(tbl; headers = missing)

Wrap/convert a Tables.jl-compatible tbl an return a LazyTable, for use with lazyreport.

If headers is missing, default headers are generated from the column names of tbl. If headers is an AbstractDict, the default column names are overridden according to the keys and values in it. If headers is an AbstractVector, it explicitly defines all headers of the table and must have the same length as the number of columns in tbl.

source
LazyReports.pushcontent! — Function
LazyReports.pushcontent!(rpt::LazyReport, obj)

Lower-level function to add a single object to report rpt.

Users should call lazyreport!(rpt, obj) instead, but should specialize LazyReports.pushcontent!(rpt::LazyReport, obj::MyType) to control how objects of specific types are added to reports (e.g. by converting them to Markdown, tables, or other content types first).

The return value of pushcontent! is undefined and should be ignored.

Implementation

Specialized methods of pushcontent! that convert obj to types already supported by LazyReport should preferably call lazyreport! internally instead of calling pushcontent! again directly.

source
LazyReports.render_element — Function
LazyTable.render_element(io::IO, mime::MIME, obj::Any)

Render obj for the given mime type to io.

Defaults to show(io, mime, obj), with show(io, MIME("text/plain"), obj) as a fallback if showable(mime, obj) == false.

Should be specialized for specific combinations of MIME and object types if specialization of Base.show would be too broad.

source
LazyReports.write_lazyreport — Function
write_lazyreport(filename::AbstractString, rpt::LazyReport)
write_lazyreport(filename::AbstractString, mime::MIME, rpt::LazyReport)

Write lazyreport rpt to file filename.

source