API
Modules
Types and constants
Functions and macros
LazyReports.lazyreport
LazyReports.lazyreport!
LazyReports.lazytable
LazyReports.pushcontent!
LazyReports.render_element
LazyReports.render_inline
LazyReports.render_intable
LazyReports.write_lazyreport
Documentation
LazyReports.LazyReports
— ModuleLazyReports
Lazy reports in Julia.
LazyReports.LazyReport
— TypeLazyReports.LazyTable
— Typestruct LazyReports.LazyTable
Represents a lazy table.
Supports convert(::Type{Markdown.Table}, lt::LazyTable)
.
Don't instantiate directly, use lazytable
.
LazyReports.OpaqueContent
— Typestruct 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)
LazyReports.lazyreport
— Functionlazyreport()
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.
LazyReports.lazyreport!
— Methodlazyreport!(rpt::LazyReport, contents...)
Add more content to report rpt
. See lazyreport
for an example.
Implementation
Do not specialize lazyreport!(rpt::LazyReport, obj::MyType)
directly, specialize the lower-level function LazyReports.pushcontent!
instead.
LazyReports.lazytable
— Functionlazytable(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
.
LazyReports.pushcontent!
— FunctionLazyReports.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.
LazyReports.render_element
— FunctionLazyTable.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.
LazyReports.render_inline
— FunctionLazyTable.render_inline(io::IO, mime::MIME, obj::Any)
Render obj
as inline content for the given mime
type to io
.
Defaults to render_element(io, mime, obj)
and may be specialized for specific combinations of MIME and object types.
LazyReports.render_intable
— FunctionLazyTable.render_intable(io::IO, mime::MIME, obj::Any)
Render obj
as table cell content for the given mime
type to io
.
Defaults to render_inline(io, mime, obj)
and may be specialized for specific combinations of MIME and object types.
LazyReports.write_lazyreport
— Functionwrite_lazyreport(filename::AbstractString, rpt::LazyReport)
write_lazyreport(filename::AbstractString, mime::MIME, rpt::LazyReport)
Write lazyreport rpt
to file filename
.