Skip to content

Describe

opulse.language.describe

Describe operators: atoms by their rules, defined operators from their parsed definitions.

Every atom is described, built-in or registered (:mod:opulse.core.primitives): built-in atoms have a sentence in each language written with the configured operand names; a registered atom is described by the rule it was registered with. Defined operators are described in two styles. math keeps conditions and bodies in operator notation, so the wording cannot change the arithmetic; natural is the controlled-language view (:mod:opulse.language.views.controlled), which parses back to the same definition. Both use the configured notation (operand names, brackets, NaN spelling, numeral digits). A recursive definition gets the recursion facts of :mod:opulse.language.recursion, read from its structure.

The dependency chain of an operator is the closure of the operators its definition applies, computed from the parsed definitions (not from stored dependency lists), callees first, never cut short unless a limit is given, in which case the text says how many were left out.

Describer

Descriptions of the operators of one registry under one settings object (cached).

closure

closure(operator: Operator) -> list[Operator]

Every operator operator's definition reaches (atoms included), callees first.

describe

describe(
    operator: Operator,
    definition: Definition | None,
    registry: OperatorRegistry,
    lang: str = "zh",
    style: str = "math",
    settings: Settings | None = None,
) -> str

One description of operator (definition is accepted for compatibility; the registry's own definition text is what is described).

annotate

annotate(
    registry: OperatorRegistry,
    settings: Settings | None = None,
    chain_limit: int | None = None,
) -> Iterator[dict]

Yield operator JSON fields with bilingual descriptions and dependency chains.