Docstring dictionaries: private API
src/01_Base/ implements the most basal symbols used in PortfolioOptimisers.jl. One file per concept: the docstring dictionaries, the type roots, the pretty-show macro, the ScopedConfig holders, the load-time preferences, the message builders, the error hierarchy, the type aliases, the observation weights, the assert_* family, VecScalar, the NormError family, the Kaniadakis logarithm, the partial-fit state seam and the sample buffer the online step folds into.
In order to standardise the documentation we use an arg_dict of terms.
PortfolioOptimisers.arg_dict — Constant
arg_dictMaps a parameter key to the docstring description of the corresponding argument or field, so that a single description is written once here and interpolated into every docstring that mentions that parameter (via $(arg_dict[key]) for # Arguments entries, or through the derived field_dict for # Fields entries).
Each value has the form $"`name`: description."$, where name is the display name the caller sees and everything after the first : is the prose; field_dict strips the $"`name`: "$ prefix. A few illustrative entries:
:ce => "`ce`: Covariance estimator.":oow => "`w`: Optional observation weights vector `observations × 1`, ...":per => "`pr`: Prior estimator or result.":pler => "`pl`: Network estimator, phylogeny result, clustering estimator, or clustering result.":plsrc => "`pl`: Network estimator or clustering estimator -- a source that refits, never a precomputed result."The const definition below is the single source of truth; consult it for the full table of keys and descriptions. A key must appear once: unique_key_dict builds the table and refuses a repeat, because a Dict literal drops the earlier entry in silence.
Related
PortfolioOptimisers.val_dict — Constant
const val_dict = Dict(:oow => "If `w` is not `nothing`, `!isempty(w)`.")Validation rules for certain arg_dict terms used in the documentation of PortfolioOptimisers.jl.
:relax is the exception: it is the fixed opening sentence of a ## Relaxation subsection under # JuMP formulation, held here so that the wording cannot drift between docstrings.
Related
PortfolioOptimisers.ret_dict — Constant
ret_dictDictionary containing return value descriptions for common parameters used in PortfolioOptimisers.jl.
Related
PortfolioOptimisers.field_dict — Constant
field_dictDerived dictionary mapping argument keys to field description strings, used for $(FIELDS)-style docstring interpolation.
Each entry is derived from arg_dict by stripping the leading parameter name prefix (everything up to and including the first :).
Related
PortfolioOptimisers.math_dict — Constant
math_dictDictionary of mathematical notation descriptions used for docstring interpolation throughout PortfolioOptimisers.jl.
Keys are symbols that identify mathematical variables or subscripts; values are LaTeX-formatted strings suitable for embedding in docstrings.
A key owns a definition, not a glyph: one glyph carries different quantities in different families, so a second quantity on the same glyph takes its own key under its own symbol.
Related
PortfolioOptimisers.err_name_dict — Constant
err_name_dictMaps high-order-moment argument keys to the domain noun used in error messages, so a message names what the caller supplied (e.g. cokurtosis) rather than the bare field symbol. The symbol itself is appended at the call site, giving messages like $cokurtosis (`kt`) cannot be empty$.
Related
PortfolioOptimisers.ref_dict — Constant
ref_dictMaps a key of docs/src/References.bib to the formatted # References bullet for that work, so the reference text is written once here and interpolated wherever a docstring cites it.
Each value is a complete bullet body: the citation marker for the key, followed by the reference in the style DocumenterCitations renders in the bibliography. A citing docstring writes the whole bullet as one interpolation of this table and never pastes the reference prose inline. A pasted copy drifts from the entry in References.bib and from the other copies of itself: before this table existed, gerber2025squeezing was pasted 31 times and mlp1 13 times.
The const definition below is the single source of truth. A key must appear once: unique_key_dict builds the table and refuses a repeat.
Related
PortfolioOptimisers.unique_key_dict — Function
unique_key_dict(
name::Symbol,
pairs::Pair{Symbol, <:AbstractString}...
) -> Dict{Symbol, String}
Build a documentation dictionary from pairs, and throw if a key appears more than once.
A Dict literal is last-wins, so a repeated key drops the earlier entry with no warning and makes its prose unreachable. This constructor is the guard against that: it fails at load time and names both descriptions, so the duplicate is visible instead of silent.
Algorithm
- Start
dictempty. - For each pair, in the order the caller wrote it, raise an
ArgumentErrorwhendictalready holds the key. The message namesname, the key, and both descriptions. - Otherwise store the pair in
dict.
Arguments
name::Symbol: Name of the dictionary under construction, used in the error message.pairs: The key-description pairs, in the order they are written.
Validation
- Each key appears exactly once. A repeat raises an
ArgumentErrornamingname, the key, and both descriptions.
Returns
dict::Dict{Symbol, String}: The built table.
Related