Documentation
¶
Overview ¶
Package docrender renders evaluated documents into backend-specific artifacts, consuming only the document IR — never plans, symbols, or ASTs.
Index ¶
- Constants
- func DefaultStylesheet() string
- func DocumentFileName(fqn string) string
- func DocumentHTMLFileName(fqn string) string
- func HTML(document *docir.Document, opts HTMLOptions) (string, error)
- func Markdown(document *docir.Document) (string, error)
- type Error
- type ErrorKind
- type HTMLOptions
- type Stylesheet
Constants ¶
const StylesheetFileName = "sysml-document.css"
StylesheetFileName is the file a rendered document set links its shared stylesheet from.
Variables ¶
This section is empty.
Functions ¶
func DefaultStylesheet ¶ added in v0.5.0
func DefaultStylesheet() string
DefaultStylesheet is the default document stylesheet: one cascade layer of declarations, every value taken from a --sysml-* token on .sysml-document.
func DocumentFileName ¶
DocumentFileName derives the deterministic Markdown file name of a rendered document from its fully-qualified name, using the same escaping as anchors so distinct documents never collide.
func DocumentHTMLFileName ¶ added in v0.5.0
DocumentHTMLFileName derives the deterministic HTML file name of a rendered document from its fully-qualified name, escaped as anchors are so distinct documents never collide.
func HTML ¶ added in v0.5.0
func HTML(document *docir.Document, opts HTMLOptions) (string, error)
HTML renders an evaluated document as deterministic, semantic HTML: an <article> holding nested <section> elements, real tables with <caption> and <th scope>, <ul>/<ol> lists and <figure> diagrams carrying Mermaid source. Every node keeps its model facts in sysml- classes and data- attributes — content kind, declared name, query, group column, row element and its kind, projected column, value kind, reference target, diagram kind and direction — and every value is escaped so no content can corrupt the structure.
func Markdown ¶
Markdown renders an evaluated document as deterministic CommonMark: the title as a level-1 ATX heading, each section one level deeper (saturating at 6), paragraphs from space-joined text runs, GitHub-flavored pipe tables with projected column headers, bullet or numbered lists, and diagrams as fenced Mermaid blocks (table-kind views as pipe tables). Metacharacters in content are escaped so no value can corrupt the document structure.
Types ¶
type Error ¶
type Error struct {
Kind ErrorKind
Content string
Actual string
// Form is the backend that failed, "Markdown" when empty.
Form string
}
Error is a typed document-rendering failure.
type ErrorKind ¶
type ErrorKind string
ErrorKind classifies a document-rendering failure.
const ( ErrorNilDocument ErrorKind = "nil-document" ErrorUnknownContent ErrorKind = "unknown-content" ErrorMissingRendering ErrorKind = "missing-rendering" ErrorUnrenderableDiagram ErrorKind = "unrenderable-diagram" ErrorEmptyStylesheet ErrorKind = "empty-stylesheet" ErrorAmbiguousStylesheet ErrorKind = "ambiguous-stylesheet" ErrorUnsafeStylesheet ErrorKind = "unsafe-stylesheet" )
type HTMLOptions ¶ added in v0.5.0
type HTMLOptions struct {
// Fragment writes the document element alone, without the page shell or
// any stylesheet, for embedding in a host page.
Fragment bool
// NoDefaultStylesheet leaves the default stylesheet out.
NoDefaultStylesheet bool
// Stylesheets are attached after the default one, unlayered, so their
// declarations win on cascade origin rather than on specificity.
Stylesheets []Stylesheet
// TitlePage puts the document title in a page of its own.
TitlePage bool
// TOC writes a table of contents ahead of the content.
TOC bool
// NumberSections numbers the section headings hierarchically.
NumberSections bool
// Lang is the page language, "en" when empty.
Lang string
}
HTMLOptions are the presentation choices of the HTML backend. They are options of this backend, never document-model attributes.
type Stylesheet ¶ added in v0.5.0
type Stylesheet struct {
// Content is stylesheet text to inline, keeping the document self-contained.
Content string
// Href is a stylesheet URL to link, for a site-hosted stylesheet.
Href string
// contains filtered or unexported fields
}
Stylesheet is one stylesheet a standalone document carries: Content is inlined, Href is linked. Exactly one of the two is set; InlineStylesheet states a sheet is inlined when its content is empty.
func InlineStylesheet ¶ added in v0.5.0
func InlineStylesheet(content string) Stylesheet
InlineStylesheet is a stylesheet inlined in the document, whose content may be empty: a file the run named is a stylesheet even when it declares nothing.
func LinkedStylesheet ¶ added in v0.5.0
func LinkedStylesheet(href string) Stylesheet
LinkedStylesheet is a stylesheet the document links rather than carries.