Report writers: private API

PortfolioOptimisers.REPORT_CSS — Constant
REPORT_CSS

The 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

source
PortfolioOptimisers.REPORT_JS — Constant
REPORT_JS

The 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

source
PortfolioOptimisers.REPORT_CSP — Constant
REPORT_CSP

The 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

source
PortfolioOptimisers.html_escape — Function
html_escape(s::AbstractString) -> String

Escape a string for HTML text and for the value of a quoted HTML attribute.

Arguments

  • s: The string.

Returns

  • t::String: s with &, <, >, " and ' written as character references.

Related

source
PortfolioOptimisers.md_escape — Function
md_escape(s::AbstractString) -> String

Escape 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

source
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, or nothing for an empty cell.
  • num: num: Whether the sort value is a number.

Related

source
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

source
PortfolioOptimisers.report_level — Function
report_level(io::IO) -> Int

The 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

source
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_mime of its IOContext.

Returns

  • mime::MIME: The image MIME.

Related

source
PortfolioOptimisers.figure_data_uri — Function
figure_data_uri(io::IO, fig) -> String

The 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

source
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

source
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

source
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, or nothing to read the extension of path.
  • path: The path of the file.

Validation

  • With no format, the extension of path is .md, .html or .htm. Otherwise the function raises an ArgumentError.
  • A given format is text/markdown or text/html. Otherwise the function raises an ArgumentError.

Returns

  • mime::MIME: The format.

Related

source