Report writers: private API
PortfolioOptimisers.REPORT_CSS — Constant
REPORT_CSSThe style sheet of the HTML file of a Portfolio Report, read at load time from report.css beside this file.
The HTML writer puts it in an inline <style> element, so the file loads no style sheet. The colours are variables, with a dark set for prefers-color-scheme: dark and for data-theme="dark" on the root element.
Related
PortfolioOptimisers.REPORT_JS — Constant
REPORT_JSThe script of the HTML file of a Portfolio Report, read at load time from report.js beside this file.
The HTML writer puts it in an inline <script> element, so the file loads no script. The script shows one entry at a time, keeps the selection in location.hash, moves between the entries with the arrow keys, sorts a table by a click on a header, hides a group, and toggles the theme. With no script, the file shows every entry, one after the other.
Related
PortfolioOptimisers.REPORT_CSP — Constant
REPORT_CSPThe Content Security Policy of the HTML file of a Portfolio Report.
The policy refuses every load from the network. It admits only images from data URIs, and the inline style and script of the file. A string of the caller is escaped, and the policy also holds for it.
Related
PortfolioOptimisers.html_escape — Function
html_escape(s::AbstractString) -> StringEscape a string for HTML text and for the value of a quoted HTML attribute.
Arguments
s: The string.
Returns
t::String:swith&,<,>,"and'written as character references.
Related
PortfolioOptimisers.md_escape — Function
md_escape(s::AbstractString) -> StringEscape a string for Markdown, so that it shows as plain text.
A Markdown renderer reads raw HTML and the markup characters. The function writes &, <, > and " as character references, puts a backslash before each other markup character of the set $\`*_{}[]()#+-.!|~$, and writes a line break as a space, so the string stays in its paragraph or in its table cell.
Arguments
s: The string.
Returns
t::String: The escaped string.
Related
PortfolioOptimisers.ReportCell — Type
struct ReportCell{__T_text, __T_v, __T_num}One cell of a ReportTable: the text to show, the sort value and the kind of the sort value.
This type is an implementation detail and is not intended for direct use. report_cell makes it. report_cell_html and the Markdown writer of a ReportTable read it.
Fields
text:text: The text to show.
v:v: The sort value as a string, ornothingfor an empty cell.
num:num: Whether the sort value is a number.
Related
PortfolioOptimisers.report_cell — Function
report_cell(x::Union{Nothing, Missing}, digits::Integer)
report_cell(x::Integer, digits::Integer)
report_cell(x::Bool, digits::Integer)
report_cell(x::AbstractFloat, digits::Integer)
report_cell(x::Real, digits::Integer)
report_cell(x::Any, digits::Integer)The text, the sort value and the kind of one cell of a ReportTable.
A float shows with digits significant digits, and its sort value is the full number. An integer sorts as a number. nothing, missing and NaN are empty cells, which show as — and have no sort value. Any other value, a Bool included, shows as its string, and sorts as that text.
Arguments
x: The value of the cell.digits: The number of significant digits of a float.
Returns
cell::ReportCell: The text, the sort value and the kind of the cell.
Related
PortfolioOptimisers.report_cell_html — Function
report_cell_html(io::IO, c::ReportCell)Write one cell of a ReportTable as an HTML <td> element, from its report_cell.
A number carries the class po-num, and a cell with a sort value carries it in data-v. The script of the file sorts by data-v, as a number when both cells are numbers, and puts a cell with no data-v last.
Arguments
io: The stream.c: The cell, fromreport_cell.
Returns
nothing.
Related
PortfolioOptimisers.report_level — Function
report_level(io::IO) -> IntThe heading level of the block that a writer writes to io, from the key :report_level of its IOContext, at most 6.
A section writes its blocks one level below its own heading. A block written with no context starts at level 2.
Related
PortfolioOptimisers.figure_mime — Function
figure_mime(fig, preferred::MIME"image/svg+xml")
figure_mime(fig, preferred::MIME"image/png")The image MIME in which a writer embeds a figure: the preferred MIME when the figure shows itself in it, and the other image MIME otherwise.
Arguments
fig: The figure.preferred: The image MIME of the writer, from the key:report_figure_mimeof itsIOContext.
Returns
mime::MIME: The image MIME.
Related
PortfolioOptimisers.figure_data_uri — Function
figure_data_uri(io::IO, fig) -> StringThe data URI of a figure, in the image MIME that figure_mime chooses for the writer of io.
An image tag that reads a data URI isolates its figure. An inline SVG element shares the identifiers and the styles of its page, so two figures of one plotting backend can clip each other. The data URI holds the base64 code of the image, so it adds a third to the size of the image.
Arguments
io: The stream of the writer.fig: The figure.
Returns
uri::String:data:<mime>;base64,<code>.
Related
PortfolioOptimisers.report_paragraphs — Function
report_paragraphs(text::AbstractString) -> Vector{String}The paragraphs of a text: the parts between blank lines, with their edges stripped, and with no empty part.
Related
PortfolioOptimisers.report_meta_markdown — Function
report_meta_markdown(io::IO, meta::AbstractVector{<:Pair})Write the labels of a report or of an entry as a Markdown list. An empty list writes nothing.
Arguments
io: The stream.meta: The labels, fromreport_meta.
Returns
nothing.
Related
PortfolioOptimisers.report_meta_html — Function
report_meta_html(io::IO, meta::AbstractVector{<:Pair})Write the labels of a report or of an entry as an HTML list. An empty list writes nothing.
Arguments
io: The stream.meta: The labels, fromreport_meta.
Returns
nothing.
Related
PortfolioOptimisers.report_controls_html — Function
report_controls_html(io::IO, entries::AbstractVector{<:ReportEntry})Write the controls of the HTML file of a Portfolio Report: the entry selector, the group filter and the toggle of the theme.
The selector shows only when the report holds more than one entry. It lists the entries with no group first, then one <optgroup> for each group, in the order in which the groups first appear. The filter shows only when an entry has a group, with one checkbox for each group. The style sheet hides the controls when the script does not run.
Arguments
io: The stream.entries: The entries of the report.
Returns
nothing.
Related
PortfolioOptimisers.report_select_html — Function
report_select_html(io::IO, entries::AbstractVector{<:ReportEntry},
groups::AbstractVector)Write the entry selector of the HTML file of a Portfolio Report: the entries with no group first, then one <optgroup> for each group, in the order of groups.
Arguments
io: The stream.entries: The entries of the report.groups: The groups of the entries, in the order in which they first appear.
Returns
nothing.
Related
PortfolioOptimisers.report_format — Function
report_format(format::Nothing, path::AbstractString)
report_format(format::MIME"text/markdown", path::AbstractString)
report_format(format::MIME"text/html", path::AbstractString)
report_format(format::MIME, path::AbstractString)The format in which write_report writes a report: the format of the caller, or the format that the extension of path names.
Arguments
format: The MIME of the format, ornothingto read the extension ofpath.path: The path of the file.
Validation
- With no format, the extension of
pathis.md,.htmlor.htm. Otherwise the function raises anArgumentError. - A given format is
text/markdownortext/html. Otherwise the function raises anArgumentError.
Returns
mime::MIME: The format.
Related