Skip to content

Document Authoring

A document definition is a part def specializing DocumentQueries::Document. Its nested parts are its content, rendered in declaration order. This chapter covers each block; the snippets are excerpts of models that render with the current binary (most are drawn from the worked example).

Document and sections

part def MassReport :> Document {
    attribute redefines title = "Telescope Mass Report";

    part breakdown : Section {
        attribute redefines title = "Subsystem Masses";

        part heavy : Section {
            attribute redefines title = "Heavy Subsystems";
            // ...
        }
    }
}
  • The document's title is required and renders as the level-1 heading.
  • A Section requires a title too and renders as a heading one level deeper than its parent, saturating at Markdown's level 6.
  • Sections nest arbitrarily; anything a document can contain, a section can.
  • A section is also what a heading in a Markdown or AsciiDoc body opens (see Markdown prose), so one body can carry a whole document's outline.
  • A document nested inside a document is a planning error.

Paragraphs

A Paragraph carries exactly one of four things:

Static text — a literal text attribute:

part intro : Paragraph {
    attribute redefines text = "Mass rollup for the telescope assembly.";
}

:>> text = "..." is the short spelling of the same redefinition; the two forms are equivalent, and the rest of this manual uses the short one.

A query — each projected value becomes one plain text run, joined by spaces (nested column runs restyle this — see Styled query text):

part summary : Paragraph {
    calc names : HeavySubsystemNames {
        in root = telescope;
        in threshold = "10";
    }
}

renders as mount segmentControl.

Inline runs — nested Span, Link and Ref parts, composed in declaration order and joined by single spaces (next section).

A Markdown body — a rep language "markdown" whose comment is the paragraph's prose, inline markup included — see Markdown prose.

Giving a paragraph both text and a query, runs alongside either, or a Markdown body alongside any of them, is a typed planning error rather than a guess about your intent.

part guide : Paragraph {
    part lead : Span {
        :>> text = "This report is";
    }
    part generated : Span {
        :>> text = "generated";
        attribute redefines style = "emphasis";
    }
    part tool : Span {
        :>> text = "sysml -render-document";
        attribute redefines style = "code";
    }
    part docsLink : Link {
        :>> text = "(OpenSysML)";
        attribute redefines target = "https://opensysml.org/";
    }
    part massesRef : Ref {
        ref redefines target = breakdown;
    }
}

renders as:

This report is *generated* `sysml -render-document` [(OpenSysML)](<https://opensysml.org/>) [Subsystem Masses](#breakdown)

Span carries required text and an optional style: "plain" (the default), "emphasis" (*text*), "strong" (**text**), "code" (`text`) or "math" ($text$, the text being LaTeX — see Mathematics). Content is still escaped inside the styling — a * in an emphasis span cannot break out of it, and a code span grows its backtick fence past any backticks in the text.

Link carries required text and a required target URL, rendering as an inline Markdown link with the destination in pointy brackets (so parentheses and spaces in URLs survive).

Ref cross-references a named content block of this document — or of another document — by name: ref redefines target = <block>. The renderer gives the referenced block a stable HTML anchor derived from its named path — <a id="breakdown"></a> before the section above — and the Ref renders as a link to it. text is optional; it defaults to the target's title (for a section), caption (for a table or diagram) or name. A Ref may also name a model element outside every document — a usage by name (telescope.mount), any element through its metadata (Mount.metadata, the KerML way to refer to a definition or package as a value): it renders as the element's name, in HTML marked with the element's qualified name (data-element) and no link, since a rendered document has no page for it. A content block that is not a named member of a document, or a target without a stable name, is a typed planning error.

Cross-document references

To reference another document, declare a usage typed by the target document definition, then name it (for the document's root) or reach into it with dot notation (for one of its content blocks):

ref appendix : 'Mass Appendix';

part def SystemReport :> Document {
    attribute redefines title = "System Report";
    part intro : Paragraph {
        part see : Ref {
            ref redefines target = appendix.tables.masses;
        }
        part whole : Ref {
            ref redefines target = appendix;
        }
    }
}

Targets resolve at planning time against the loaded workspace. A content target renders as a relative link into the target document's generated file with the block's stable anchor — a destination like Observatory-Mass.20Appendix.md#tables-masses behind the link text; a root target links to the file alone. The file name is deterministic: the target document's fully qualified name with :: replaced by - and any byte outside ASCII letters, digits and _ escaped as .XX (uppercase hex), plus .md; where two names would meet in one file (see Multi-document sets) the link carries the tagged name the set writes. Render the whole set with -render-documents <dir> so the links resolve on disk. Rendering a single document that references another still succeeds — the link points at the file name the set gives the unrendered target, and it dangles until that document is rendered into the same directory. An unknown target is a typed planning error, and a target usage typed by more than one document definition is an ambiguous-target error; both carry the reference's source location.

Markdown prose

Writing every sentence as Span, Link and Ref parts is exact but verbose. A KerML textual representation lets you write the prose of a document, a section or a paragraph as one Markdown body instead:

part def MassReport :> Document {
    :>> title = "Telescope Mass Report";

    rep language "markdown" /* This report is *generated* by `sysml -render-document`
     * ([OpenSysML](https://opensysml.org/)); see [](sysml:breakdown) for the
     * masses, and the mount at [](sysml:telescope.mount). Mass scales as
     * $m \propto D^{2.5}$.
     *
     * - Masses are rolled up from the parts.
     * - Margins are computed against the allocation.
     */

    part breakdown : Section {
        :>> title = "Subsystem Masses";
        part reading : Paragraph {
            rep language "markdown" /* A **named** paragraph keeps its name as a `Ref` target. */
        }
    }
}

renders as:

This report is *generated* by `sysml -render-document` ([OpenSysML](<https://opensysml.org/>)); see [Subsystem Masses](#breakdown) for the masses, and the mount at mount. Mass scales as $m \propto D^{2.5}$.

- Masses are rolled up from the parts.
- Margins are computed against the allocation.

<a id="breakdown"></a>

## Subsystem Masses

A **named** paragraph keeps its name as a `Ref` target.

The rep is the KerML element for "this element, represented in another language" (KerML 1.0 §8.3.2.3.6); its language is matched case-insensitively, and the body is the comment's text with the /*, */ and the * margin removed, as for any KerML comment. Two placements are supported:

  • In a Document or Section, a body expands in place — in declaration order among the sibling parts — into unnamed paragraphs and lists, and its headings open sections (below). Several bodies in one section are several runs of blocks, and part : Paragraph and part : Table members may sit between them.
  • In a part : Paragraph, the body must yield exactly one paragraph, which is that paragraph's content; the part keeps its name, so it stays a Ref target and HTML anchor. A body beside text, inline runs or a query is the usual conflicting-content error, and a heading in it is the markup-body-not-paragraph error.

The body is CommonMark with no extensions, mapped onto the content blocks the rest of this chapter describes — the Markdown, HTML and PDF outputs are the same ones a Span/Link/Ref paragraph produces:

Markdown Content
paragraph Paragraph with runs
*text*, **text**, `text` emphasis, strong and code runs
[label](https://…), <https://…> Link run
[label](sysml:<target>) Ref run — see below
[label](sysml:value:<target>) value run — the feature's value, see below
$…$ math run (LaTeX; the pandoc rule: the opening $ is followed by a non-space, the closing one preceded by one and not followed by a digit)
- item / 1. item lists of single paragraphs List with bullet or number style
# Title … ###### Title, setext Title over ===/--- Section with that title — see below
line break one space, as between any two runs

A sysml: link destination is a Ref target written in the same notation as ref redefines target = …: a named content block of this or another document (sysml:breakdown, sysml:appendix.budget), a usage by name or feature chain (sysml:telescope.mount) or any element through its metadata (sysml:Telescope.metadata). It is resolved in the scope the body is written in. An empty label — [](sysml:breakdown) — takes the target's title, caption or name as a Ref without text does.

A sysml:value: destination reads a feature's value into the prose instead of referencing the element: [](sysml:value:telescope.mass) renders 2290000 [kg], exactly as a SpanColumn cell projecting mass from telescope would — numbers with their unit, strings, booleans, enumeration literals, and a multi-valued feature joined with , as a list cell is. The target is a data-valued feature — an attribute, calculation or enumeration usage, or a ref typed by data types only — named by qualified name or feature chain, resolved as a sysml: reference is; a feature chain reads from its root, a name from the feature's owner (a member written a::b reads a, then b). Without a session the declared value is read; over a session (-run, or a document rendered while the REPL holds objects) a target whose root the session holds reads the object's current value, as Objects rows do. A label precedes the value with one space — [Mass:](sysml:value:telescope.mass) renders Mass: 2290000 [kg]; an empty label renders the value alone. A target that is a part, port, content block, definition or a ref to one of those is refused when the document is planned (invalid-value-target): sysml: without value: references those. A feature with no value fails the document's evaluation (empty-value) naming the feature, never a blank; give the feature a value or a redefinition.

Headings open sections

A heading in a body owned by a Document or Section opens a Section with the heading's text as its title; the blocks after it are that section's content until the next heading of the same or a shallower level, and a deeper heading nests. Levels are relative to the body's owner: the first heading met in the body, whatever its mark, is one level below the owner — a body directly in the document starts the level-1 sections, a body in a Section its subsections — and each later heading is at most one level deeper than the open one. A heading that skips a level (# then ###) or rises above the first heading's level (## first, # later) is the markup-heading-level planning error, naming the heading and its body line. Styled text in a heading is flattened to its plain title; a link, reference or formula in one is refused as a construct with no title form.

part def MassReport :> Document {
    :>> title = "Telescope Mass Report";

    rep language "markdown" /* Lead paragraph; see [](sysml:mass_budget).
     *
     * # Overview
     *
     * ## Mass budget
     *
     * - mirror: 12 kg
     *
     * # Design
     */

    part appendix : Section {
        :>> title = "Appendix";
        rep language "markdown" /* ## Derivation
         * Back to [](sysml:overview). */
    }
}

renders the outline Overview (1) › Mass budget (1.1), Design (2), Appendix (3) › Derivation (3.1): the body expands where it is declared, so the part-born appendix follows the body's sections in declaration order, and a body inside a section nests below that section. Numbering, tables of contents and title pages (-doc-number-sections, -doc-toc, -doc-title-page) treat markup-born and part-born sections alike.

Each such section is named, so it is a Ref target and an HTML anchor like a part : Section. The name is the explicit id when the markup gives one (AsciiDoc [[id]] or [#id] on the title; Markdown has no CommonMark spelling for one), kept as written when it is a basic name ([[MassBudget]] → MassBudget) and otherwise slugged like a title; else a slug of the title: lower-cased, every run of characters other than letters and digits replaced by one underscore, leading and trailing underscores dropped, an underscore prefixed to a leading digit (Mass budget → mass_budget, 3rd level, deep! → _3rd_level_deep, [[mass-budget]] → mass_budget). Names are unique within the document: a derived or explicit name already taken by a content part or an earlier heading gets the first free suffix _2, _3, … in body order — the second Mass budget above would be mass_budget_2. The name is not a model element: a sysml: destination is resolved against the model first, and only a name no element answers to is looked up among the document's headings — by name, or by an explicit id exactly as written (sysml:mass-budget finds [[mass-budget]]) — so a model element of the same name in scope wins; give the heading an explicit id or refer to the element by a longer name. From another document, qualify the name by the document definition or a usage of it (sysml:MassReport::mass_budget) as for a named part; a usage typed by more than one document is the ambiguous-ref-target error, as for a part. The anchor is the section's path, overview-mass_budget. A nested heading is also a target by its named path — sysml:overview.mass_budget, or sysml:appendix.derivation for a heading in a body inside a part : Section — qualified the same way from another document (sysml:MassReport::appendix.derivation).

Constructs that no content block renders are refused with a typed planning error naming the construct and its line within the body, rather than dropped or rendered as literal text: block quotes, indented and fenced code blocks, HTML blocks and inline HTML, images, thematic breaks, nested lists and list items of more than one paragraph, ordered lists not starting at 1, link titles, nested emphasis and styled link text. Images and tables have content kinds (Image, Table) and may gain a Markdown spelling later; today they stay parts. GFM tables, footnotes, strikethrough and task lists are not enabled and read as the paragraphs CommonMark makes of them.

Every run and block planned from a body keeps its position inside the body, so a planning error, a hover or an edit points at the prose that caused it, not at the rep as a whole. A rep in a language no parser serves (rep language "asciidoc") is refused too (unsupported-markup-language), so no body is ever silently dropped.

AsciiDoc prose

The same two placements take an AsciiDoc body — rep language "asciidoc" — for authors who prefer its one-markup-string-per-paragraph style, its tables and its macros:

part def MassReport :> Document {
    :>> title = "Telescope Mass Report";

    rep language "asciidoc" /* This report is _generated_ by `sysml -render-document`
     * (link:https://opensysml.org/[OpenSysML]); see <<breakdown>> for the
     * masses, and the mount at sysml:ref[telescope.mount]. Mass scales as
     * stem:[m \propto D^{2.5}].
     *
     * NOTE: Margins are computed against the allocation.
     *
     * .Allocations
     * [cols="3,1"]
     * |===
     * |Subsystem |Allocation
     *
     * |Optics |120 kg
     * |Structure |80 kg
     * |===
     */

    part breakdown : Section {
        :>> title = "Subsystem Masses";
        part reading : Paragraph {
            rep language "asciidoc" /* A *named* paragraph keeps its name as a `Ref` target. */
        }
    }
}

The body is parsed by Asciidoctor.js, run as an external converter the way the PDF toolchain's tools are: the scripts/asciidoc/asciidoctor-json.js script reads the body on stdin and writes its block and inline tree as JSON, and the planner maps that tree onto the content blocks of this chapter. ./scripts/download-doc-pdf-toolchain.sh installs the pinned Asciidoctor.js beside the script under build/doc-pdf/asciidoctor/; point OPENSYSML_ASCIIDOCTOR at the installed asciidoctor-json.js (an asciidoctor-json on PATH is found without it). Validation (sysml -validate, the editors, the SARIF report) does not need the converter installed: a document with an AsciiDoc body and no converter gets one document-plan-markup-tool-missing warning at its first body, naming the converter looked for, where (OPENSYSML_ASCIIDOCTOR or PATH) and the remedy, and its AsciiDoc bodies go unchecked while the rest of the document is still validated; -warnings-as-errors makes that a failure. A rendering needs the body parsed, so -render-document fails with the same message until the converter is installed, and a converter that is found but fails is an error reported with its message — the body is never rendered as literal text.

AsciiDoc Content
paragraph Paragraph with runs
_text_, *text*, `text` emphasis, strong and code runs
link:https://…[label], https://…, https://…[label] Link run
sysml:ref[<target>], sysml:ref[<target>, label] Ref run — the target as [label](sysml:<target>) takes it
sysml:value[<target>], sysml:value[<target>, label] value run — the feature's value as [label](sysml:value:<target>) renders it
<<name>>, <<name,label>> Ref run to the content block, usage or element name resolves to, else to the markup-born section of that name
== Title … ====== Title, with [[id]] or [#id] ahead of it Section with that title, named id — see below
stem:[…] math run (LaTeX)
NOTE: text and the other admonitions, or a delimited [NOTE] block holding one paragraph Paragraph led by a strong Note: (Tip:, Important:, Warning:, Caution:) run
* item / . item lists of single paragraphs, numbered from 1 List with bullet or number style
|=== table of plain-text cells under a header row, .Title, [cols="…"] static Table: the header row heads the columns, cols sizes them as columnWidths does, the title is the caption
[stem] block with .Title Formula with the title as caption
image::file[alt] with .Title Image with the title as caption
typographic replacements ((C), --, ...) and entities the characters they stand for

A table cell is one plain-text value, as a projected cell is: styled text, a link, a reference, a macro or math inside a cell is refused.

Section titles open sections exactly as Markdown headings do — the first title met is one level below the body's owner, a title that skips a level or rises above it is the markup-heading-level error, and a title in a part : Paragraph body is refused — with one addition: an anchor on the title, [[mass_budget]] or [#mass_budget], is the section's name, and <<mass_budget>> or sysml:ref[mass_budget] resolves to it. An id spelt with characters a name cannot carry ([[mass-budget]]) is normalised by the slug rule to mass_budget, and an xref written as the id, <<mass-budget>> or sysml:ref['mass-budget'], still finds it. An id already taken as an earlier heading's name gets the _2 suffix and does not take that name over, and a repeated id keeps naming its first heading. Without an anchor the name is the slug of the title; Asciidoctor's automatic _title ids are not used.

Constructs no content block renders are refused with a typed planning error naming the construct and its body line, as for Markdown: a document header (= Title), listing, literal, example, sidebar, quote, verse, open and passthrough blocks, description and callout lists, nested lists and blocks attached to a list item, ordered lists not starting at 1 ([start=3], and a start that is not a number, which Asciidoctor reads as 0), a delimited admonition holding anything but one paragraph, thematic and page breaks, tables without a header row or with a footer, AsciiMath, inline images, footnotes, keyboard, button and menu macros, index terms, superscript, subscript and highlighted text, nested quoted text, styled link text, styled block titles, and a block title on a block that has no caption. The sysml:value[<target>] macro reads a feature's value as the Markdown sysml:value: destination does, its second positional attribute the label: sysml:value[telescope.mass, Mass:] renders Mass: 2290000 [kg].

Styled query text (column runs)

A query-backed paragraph or list may nest column runs — SpanColumn and LinkColumn parts — that map projected columns to styled runs. Each result row renders one run per column run, in declaration order:

part styledSummary : Paragraph {
    calc names : StyledHeavyNames {
        in root = telescope;
        in threshold = "10";
    }
    part styledName : SpanColumn {
        attribute redefines column = "name";
        attribute redefines styleColumn = "style";
    }
    part linkedName : LinkColumn {
        attribute redefines column = "name";
        attribute redefines targetColumn = "url";
    }
}
**mount** [mount](<https://example.com/parts#mount>) **segmentControl** [segmentControl](<https://example.com/parts#segmentControl>)

SpanColumn carries a required column naming the projected column its text comes from, plus at most one of:

  • style — a fixed "plain" (the default), "emphasis", "strong", "code" or "math" applied to every row;
  • styleColumn — a projected column supplying each row's style. Each row must supply exactly one string value among the five styles; anything else is a typed evaluation error naming the query, column and row.

A "math" column run reads each row's value as LaTeX, so a query can typeset formulas stored on the model — a latex attribute of each relation, say. A row whose math value is blank or absent is a typed evaluation error naming the query, column and row, since an empty formula has nothing to typeset.

LinkColumn carries a required column for the link text and a required targetColumn naming a projected column that supplies each row's one non-empty link destination.

Computed columns (Column with expression, cell, or path) feed column runs like any projected property, so a query can compute both the text and the style or target it renders with — the styleColumn/targetColumn example above uses computed style and url columns. A RelatedColumn(...) cell is multi-valued — a table renders its elements comma-separated, each an element value with its data-element link in HTML, as any multi-valued projection is rendered — and its count or any form is a scalar a table can group by (Traceability matrix).

Column names are checked against the query's statically-known projection at planning time; a projection only known at evaluation (e.g. a parameter-driven properties) is checked when the query runs. Column runs alongside static text or inline runs, on a paragraph without a query, or anywhere other than a query-backed paragraph or list, are typed planning errors.

Tables

A Table requires a query and may carry a caption (rendered in emphasis above the table):

part masses : Table {
    attribute redefines caption = "All subsystems by mass";
    calc rows : SubsystemTable {
        in root = telescope;
    }
}
*All subsystems by mass*

| name | mass |
| --- | --- |
| mount | 15 |
| optics | 8.5 |
| segmentControl | 20 |

The header row is the query's projected column names; a query that projects no columns gets a single element column holding each element's qualified name. An empty result still renders the header and delimiter rows, so the document shows that the table is empty rather than omitting it. Cell values render faithfully: strings unquoted, integers in base 10, reals in shortest notation, booleans as true/false, unbounded multiplicity as *, elements — a general, an enumeration literal — by effective name, the one the name property reads (HTML links each and carries its qualified name in data-element), and quantities as the magnitude followed by the unit the model spelt in brackets — 2290000 [kg], escaped in Markdown as 2290000 \[kg\] so the brackets read as text. An attribute whose value is not a constant (mass = dryMass + propellantMass) is a typed error naming the query, the property and the row, not an empty cell; see the query cookbook.

Grouped tables

A groupBy attribute names one projected column; rows partition into one subtable per distinct value of that column, in order of first appearance, with the group key above each in strong emphasis:

part zones : Table {
    attribute redefines caption = "Subsystems grouped by zone";
    attribute redefines groupBy = "zone";
    calc rows : ZonedSubsystems {
        in root = telescope;
    }
}
*Subsystems grouped by zone*

**zone: support**

| zone | name | mass |
| --- | --- | --- |
| support | mount | 15 |

**zone: payload**

| zone | name | mass |
| --- | --- | --- |
| payload | optics | 8.5 |
| payload | segmentControl | 20 |

The group column must be one the query statically projects — an unknown name is a typed error at planning time, not an empty rendering. Row order within each group is the query's order.

Column widths

A columnWidths attribute states the relative widths of the projected columns, in order, in whatever units the source used — a migrated Cameo table keeps its pixel widths — with 0 for a column sized automatically; an entry for every column is not required, the rest are automatic. Renderers honour them proportionally: HTML writes one <col> per column with its share of the table width, PDF sizes the columns by them, and Markdown, which has no column widths, ignores them (Wide tables).

part masses : Table {
    attribute redefines caption = "Masses";
    attribute redefines columnWidths = (200, 0, 80);
    calc rows : MassTable {
        in root = telescope;
    }
}

Column labels

A columnLabels attribute states the headings of the projected columns, in order, where they differ from the column names: a column's name is the unique key the query, groupBy and the HTML data-column attribute know it by, while its label is what the reader sees over it, so two columns may be headed alike (Key and Key) though named apart (Key and Key 2). "" heads a column by its name, and an entry for every column is not required. A migrated Cameo table is headed as the tool headed it — Id, Text, classifier, the tag's name over a stereotype-tag column — over the query properties it reads (shortName, documentation, general). Every backend prints the label; HTML keeps the name on the cell and heading as data-column.

part key : Table {
    attribute redefines caption = "Key Requirements";
    attribute redefines columnLabels = ("Id", "", "Text");
    calc rows : KeyRequirements;
}

Lists

A List requires a query and renders each result value as one item. style is "bullet" (the default) or "number"; anything else is a typed planning error. Nested column runs restyle each item's runs — see Styled query text.

part heavyItems : List {
    attribute redefines style = "number";
    calc items : HeavySubsystemNames {
        in root = telescope;
        in threshold = "10";
    }
}
1. mount
2. segmentControl

An empty result renders as nothing — unlike a table, an empty list leaves no trace.

Definitions — query rows as prose

A Definitions block renders each query row as one prose entry: a term followed by its description, both taken from projected columns the block names. It is how model-authored text — a requirement's short name and its doc body, a part's identifier and its description — reads as sentences rather than as cells. term and description are required and name projected columns of the bound query; either may be a property (shortName, name, documentation, …) or a computed Column:

calc def Reqs :> Query {
    in root : Element;
    Project(
        source = RelatedElements(
            source = WhereType(source = Descendants(source = root, maxDepth = 1), type = "RequirementUsage"),
            relationshipKind = "typing", direction = "outgoing", maxDepth = 1
        ),
        properties = ("shortName", "name", "documentation")
    )
}

part requirementText : Definitions {
    attribute redefines term = "shortName";
    attribute redefines description = "documentation";
    calc rows : Reqs {
        in root = spec;
    }
}
**HLR-R001** — The mission shall safely return all three crew members to Earth.

**HLR-R002** — The mission shall achieve a soft landing on the lunar surface.

Markdown writes one paragraph per row: the term in strong emphasis, an em dash, then the description. HTML writes a description list — <dl> with one <dt>/<dd> group per row, each group carrying the row's element — so a theme can style terms and descriptions apart; PDF follows the Markdown form. A cell with several values (an element with two doc comments) joins them with spaces, as a list item does. A row whose term is absent renders its description alone and vice versa; a row with neither writes nothing in Markdown and an empty group in HTML. An empty result follows a list's: it leaves no trace in Markdown, while HTML keeps the empty <dl> — as it keeps an empty <ul> — so the block stays addressable by name and query.

Both column names are checked against the query's statically-known projection at planning time; a name the query does not project is a typed error there, or at evaluation when the projection is only known then. A Definitions block without a query, or one nesting other content, is a typed planning error.

The complete model is examples/requirements.sysml and its rendered output examples/requirements.md:

$ sysml docs/manual/examples/requirements.sysml -run-query "Requirements::Reqs root=Requirements::spec"
$ sysml docs/manual/examples/requirements.sysml -render-document Requirements::RequirementsReport
$ sysml docs/manual/examples/requirements.sysml -render-document Requirements::RequirementsReport -doc-form html

Mathematics

Formulas are written in LaTeX, inline or displayed. An inline formula is a Span (or SpanColumn) with style = "math"; a displayed one is a Formula block with the LaTeX in source and an optional caption:

part intro : Paragraph {
    part lead : Span {
        :>> text = "The mirror's mass scales as";
    }
    part scaling : Span {
        :>> text = "m \\propto D^{2.5}_{\\text{eff}}";
        attribute redefines style = "math";
    }
    part cost : Span {
        :>> text = "and each $ of budget buys about 1 cm^2 of aperture.";
    }
}
part mirrorArea : Formula {
    attribute redefines caption = "Collecting area of a circular mirror";
    attribute redefines source = "A = \\pi \\left(\\frac{D}{2}\\right)^2 = \\frac{\\pi D^2}{4}";
}

renders as:

The mirror's mass scales as $m \propto D^{2.5}_{\text{eff}}$ and each \$ of budget buys about 1 cm^2 of aperture.

*Collecting area of a circular mirror*

$$
A = \pi \left(\frac{D}{2}\right)^2 = \frac{\pi D^2}{4}
$$

The LaTeX passes through untouched: math is the one run whose text is not escaped as prose, so \frac, _{eff} and ^2 reach the typesetter as written (SysML string literals still need their own backslashes doubled). In return, ordinary prose is kept out of the math: a $ in a plain span renders as \$, so "each $ of budget" can never open a formula, and a $ inside a formula — \text{cost} = 10^6\,\$ — is escaped so it cannot close one. Markdown carries the formulas as $…$ and $$…$$ blocks, which GitHub, pandoc and most Markdown viewers typeset; HTML and PDF have their own typesetters — see Outputs.

Formula.source is required and cannot be blank, and so is the text of a math span: an empty formula is a typed planning error rather than an empty box. A Formula is a content block like a Table or Diagram, not a paragraph: it takes no query and nests no runs, its caption renders above it, and a named one is a Ref target — ref redefines target = mirrorArea links to it, and the link text defaults to its caption. Line breaks in source survive into the display block (alignment environments keep their rows), while an inline formula's are folded to spaces.

Diagrams

A Diagram embeds a rendering of a model element, drawn by the same view engine that serves the editor's diagram panel. Its source names either a declared view or a plain element:

view interconnectView {
    expose imagingChain;
    render asInterconnectionDiagram;
}

part imaging : Diagram {
    attribute redefines caption = "Imaging chain interconnection";
    ref redefines source = interconnectView;
}

part structure : Diagram {
    attribute redefines caption = "Telescope part tree, left to right";
    attribute redefines kind = "tree";
    attribute redefines direction = "LR";
    attribute redefines palette = "okabe-ito";
    ref redefines source = telescope;
}
  • A view source carries its own rendering kind from its render clause; stating a kind on the diagram too is a conflict error.
  • A plain element source requires a kind: "tree", "interconnection", "state", "action", "case", "mixed", "table" or "sequence".
  • caption is optional and renders in emphasis above the diagram.
  • direction — "TB", "LR", "RL" or "BT" — is accepted only by kinds drawn as directed graphs; it becomes the Mermaid flowchart direction or a stateDiagram-v2 direction statement, the Graphviz rankdir when the document is rendered with DOT diagrams, PlantUML's top to bottom direction/left to right direction with PlantUML ones, or D2's direction: statement with D2 ones. Stating one on a sequence diagram is a typed error.
  • palette — "okabe-ito", "tol-bright", "tol-muted", "tol-light", "brewer-set2", "brewer-dark2", "viridis" or "cividis" — is accepted for graph-shaped kinds (tree, interconnection, state, action, case, mixed, sequence). Mermaid, DOT, PlantUML and D2 fill applicable nodes by keyword family from that colourblind-safe palette, a part def and its part usages sharing a hue, with black text kept legible on every fill (the palettes). Mermaid sequence diagrams note that individual participants cannot be filled; HTML figures carry the palette as data-palette. Any other name, or a palette on a table diagram, is a typed error. D2 fills nodes for tree, interconnection, state, action and sequence renderings; it does not yet write case or mixed renderings and refuses them with a typed WrongFormError. ports — "minimal" or "full" — is accepted by an interconnection or mixed diagram. "minimal", the default, draws on each part the ports an interconnection edge ends at and no other, each a small square on the part's border named beside it; "full" draws every port a part has, labelled name : Type. Any other name, or ports on another kind, is a typed error. show — a comma-separated list of the optional notation elements ("parameter-symbols", "port-symbols", "compartments", "edge-labels", "keywords", "multiplicities", "typings", "qualifiers", "annotations") or "all" — draws those elements besides the ones the view's rendering shows, as -render-show does for the whole document; the two add up. An unknown name is a typed error. overlay — "verdicts" — is accepted by a requirement diagram alone: it runs the verification cases verifying each requirement drawn and labels and colours the requirement by their verdicts. Any other name, or overlay on another kind, is a typed error.

A diagram block states what is drawn, not the notation it is written in: that is a choice made when the document is rendered. By default most kinds render as a fenced ```mermaid block:

*Imaging chain interconnection*

```mermaid
---
config:
  themeCSS: ".cluster-label .nodeLabel { text-align: center; }"
---
%% Observatory::interconnectView — interconnection rendering (render asInterconnectionDiagram)
flowchart LR
  subgraph n0 ["`*«part»* **imagingChain**`"]
    direction LR
    subgraph n1 ["`*«part»* **camera : Camera**`"]
      direction LR
      n1.0["«port»<br>output : DataPort"]
    end
    subgraph n2 ["`*«part»* **recorder : Recorder**`"]
      direction LR
      n2.0["«port»<br>input : DataPort"]
    end
  end
  n1.0 ---|"link"| n2.0
Rendered with `-diagram-form dot` (`%render-document <name> dot` in the REPL,
`diagramForm: "dot"` over the LSP), every graph-shaped diagram of the
document — a `tree`, `interconnection`, `state`, `action`, `case` or `mixed`
rendering — is a
fenced ` ```dot ` block of Graphviz DOT instead, for a toolchain that lays
diagrams out with Graphviz. No Graphviz installation is needed to write it:

```markdown
*Imaging chain interconnection*

```dot
// view: Observatory::interconnectView
// kind: interconnection
// stated: render asInterconnectionDiagram
// layout: dot
digraph "Observatory::interconnectView" {
  graph [rankdir=LR];
  node [shape=box];
  subgraph "cluster_n0" {
    label=<<font point-size="10">«part»</font><br/><b>imagingChain</b>>;
    "n0" [shape=point, style=invis, width=0, height=0, label=""];
    "n1" [shape=plain, style=solid, label=<<table border="0" cellborder="0" cellspacing="0" cellpadding="0"><tr><td colspan="4"><table border="1" cellborder="0" cellspacing="0" cellpadding="6" bgcolor="white" style="rounded"><tr><td><font point-size="10"><i>«part»</i></font><br/><b>camera : Camera</b></td></tr></table></td></tr><tr><td width="6"></td><td port="n1.0" border="1" fixedsize="true" width="10" height="10" bgcolor="white"></td><td align="left"><font point-size="8">output : DataPort</font></td><td width="6"></td></tr></table>>];
    "n2" [shape=plain, style=solid, label=<<table border="0" cellborder="0" cellspacing="0" cellpadding="0"><tr><td width="6"></td><td port="n2.0" border="1" fixedsize="true" width="10" height="10" bgcolor="white"></td><td align="left"><font point-size="8">input : DataPort</font></td><td width="6"></td></tr><tr><td colspan="4"><table border="1" cellborder="0" cellspacing="0" cellpadding="6" bgcolor="white" style="rounded"><tr><td><font point-size="10"><i>«part»</i></font><br/><b>recorder : Recorder</b></td></tr></table></td></tr></table>>];
  }
  "n1":"n1.0" -> "n2":"n2.0" [label="link", arrowhead=none, penwidth=3];
}
A view that states where its elements go (`DiagramLayout` annotations, see the
[CLI reference](../reference/cli.md#rendering-a-view)) is written with those
positions pinned and its header naming `neato`, so Graphviz draws it as laid
out. The HTML backend embeds the source in `<pre class="dot">`, and the PDF
backend keeps it as source under a notice rather than drawing it. A `sequence` kind
has no DOT form, so a document holding one cannot be rendered with DOT
diagrams; the failure is a typed error naming the block.

Rendered with `-diagram-form plantuml` (`%render-document <name> plantuml`,
`diagramForm: "plantuml"`), every diagram — the `sequence` kind included, which
PlantUML has a grammar for — is a fenced ` ```plantuml ` block in the OMG Pilot
visualizer's B&W style, its style inline so the file stands alone. No Java or
PlantUML jar is needed to write it:

```markdown
*Imaging chain interconnection*

```plantuml
@startuml
' Observatory::interconnectView — interconnection rendering (render asInterconnectionDiagram)
<style>
…
</style>
skinparam wrapWidth 300
hide stereotype
rectangle "<size:10>//«part»//</size>\n**imagingChain**" as n0 <<part>> <<usage>> {
  rectangle "<size:10>//«part»//</size>\n**camera : Camera**" as n1 <<part>> <<usage>> {
    port "output : DataPort" as n1.0
  }
  rectangle "<size:10>//«part»//</size>\n**recorder : Recorder**" as n2 <<part>> <<usage>> {
    port "input : DataPort" as n2.0
  }
}
n1.0 -[thickness=3]- n2.0 : link
@enduml
The HTML backend embeds it in `<pre class="plantuml">` and the PDF backend keeps
it as source under a notice. PlantUML pins no positions, so a view's
`DiagramLayout` geometry rides along as `'` comments; DOT is the form that
honours it ([the PlantUML form](../project/view-rendering-forms.md#plantuml)).

Rendered with `-diagram-form d2` (`%render-document <name> d2`, `diagramForm: "d2"`),
each `tree`, `interconnection`, `state`, `action` or `sequence` diagram is a fenced
` ```d2 ` block for a [D2](https://d2lang.com) toolchain, in the same B&W look as a
`classes` block the nodes and edges name; a part's parts and drawn ports are containers
nested in it. Case and mixed diagrams are refused with a typed unrenderable-form error.
No `d2` is needed to write it:

```markdown
*Imaging chain interconnection*

```d2
# Observatory::interconnectView — interconnection rendering (render asInterconnectionDiagram)
classes: {
  …
}
n0: "«part»\nimagingChain" {
  class: usage
  n1: "«part»\ncamera : Camera" {
    class: usage
    "n1.0": "output" { class: pin }
  }
  n2: "«part»\nrecorder : Recorder" {
    class: usage
    "n2.0": "input" { class: pin }
  }
}
n0.n1."n1.0" -- n0.n2."n2.0": "link" { class: connection }
The HTML backend embeds it in `<pre class="d2">`; the PDF backend draws it with
the `d2` executable `OPENSYSML_D2` names (or `d2` on `PATH`) and keeps it as
source under a notice without one. D2 lays the diagram out itself, so a view's
`DiagramLayout` geometry rides along as `#` comments
([the D2 form](../project/view-rendering-forms.md#d2)).

The `table` kind is the exception — it renders as a pipe table of the
element's structure (Element / Kind / Type / Declared in) rather than a
Mermaid, DOT, PlantUML or D2 block, whichever diagram form the document is rendered
with.

## Images

An `Image` shows an image file under an optional caption:

```sysml
part plate : Image {
    attribute redefines location = "images/mark.png";
    attribute redefines caption = "Plate 1: the survey mark";
    attribute redefines alt = "a brass survey mark";
}

location is required and cannot be blank: it is a path relative to the document's source file — resolved the same way a relative link or stylesheet is, against the output file's directory — or an http(s) or file URL. The block above renders as:

*Plate 1: the survey mark*

![a brass survey mark](images/mark.png)

Markdown writes the CommonMark image of the location under its caption; HTML a <figure class="sysml-image"> whose <img> carries the location verbatim, with alt the declared text alternative (the caption when none is declared) and the caption its <figcaption>; a PDF draws the file — a missing local location is a typed missing-image error naming the block, while an http(s) location is left for the engine to fetch. An Image is a content block like a Table or Formula: it takes no query, nests nothing, and a named one is a Ref target.

Binding queries to blocks

Every query-carrying block uses the same form:

calc rows : SubsystemTable {
    in root = telescope;
    in threshold = "10";
}

Bindings are validated against the query's compiled signature at planning time: an unknown parameter, a duplicate, a missing one without a usable default, or a type or multiplicity mismatch is a typed error before anything runs. A binding's value is an element name (telescope, or telescope.optics.mirror for a nested usage, in dot notation) or a literal; the engine does not evaluate arbitrary default expressions.

Escaping — write content freely

Model text cannot corrupt document structure. The renderer backslash-escapes Markdown metacharacters (|, *, _, #, backticks, backslashes, brackets, HTML-sensitive characters), folds newlines to spaces in prose and <br> in table cells, and escapes a leading quote, bullet or list marker. A part named baffle|shroud *tricky* renders as exactly that text in a table cell, not as a broken row.