docrender

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package docrender renders evaluated documents into backend-specific artifacts, consuming only the document IR — never plans, symbols, or ASTs.

Index

Constants

View Source
const DefaultTheme = "default"

DefaultTheme names the default stylesheet on its own.

View Source
const MermaidScriptURL = "https://cdn.jsdelivr.net/npm/mermaid@11.16.1/dist/mermaid.min.js"

MermaidScriptURL is the pinned Mermaid release a page loads from a public CDN when a script is asked for by name rather than URL.

View Source
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

func DocumentFileName(fqn string) string

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

func DocumentHTMLFileName(fqn string) string

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, <dl> definitions and <figure> diagrams carrying their source in the chosen diagram form. 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, direction and palette — and every value is escaped so no content can corrupt the structure.

func Markdown

func Markdown(document *docir.Document, opts MarkdownOptions) (string, error)

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, definitions as one "**term** — description" paragraph per entry, and diagrams as fenced blocks of their source in the chosen diagram form (table-kind views as pipe tables). Metacharacters in content are escaped so no value can corrupt the document structure.

func ThemeStylesheet added in v0.6.0

func ThemeStylesheet(name string) (string, error)

ThemeStylesheet is the default stylesheet followed by the named theme's overrides in the same layer; empty or DefaultTheme is the default alone.

func Themes added in v0.6.0

func Themes() []string

Themes lists the bundled theme names, the default first and the rest sorted.

Types

type Error

type Error struct {
	Kind    ErrorKind
	Content string
	Actual  string
	// DiagramForm is the diagram form asked for, when a failure is about one.
	DiagramForm view.Form
	// Form is the backend that failed, "Markdown" when empty.
	Form string
}

Error is a typed document-rendering failure.

func (*Error) Error

func (e *Error) Error() string

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"
	ErrorUnrenderableForm    ErrorKind = "unrenderable-diagram-form"
	ErrorUnknownForm         ErrorKind = "unknown-diagram-form"
	ErrorEmptyStylesheet     ErrorKind = "empty-stylesheet"
	ErrorAmbiguousStylesheet ErrorKind = "ambiguous-stylesheet"
	ErrorUnsafeStylesheet    ErrorKind = "unsafe-stylesheet"
	ErrorUnknownTheme        ErrorKind = "unknown-theme"
)

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

	// Theme names the bundled theme layered over the default stylesheet;
	// empty is the default alone. Ignored with NoDefaultStylesheet.
	Theme string

	// 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

	// MermaidScript is the URL of a Mermaid script a standalone page loads to
	// draw its diagrams; empty loads none, leaving each as source.
	MermaidScript string

	// DiagramForm is the source every graph-shaped diagram is written as,
	// Mermaid when empty; a table-kind view is a table whichever it is.
	DiagramForm view.Form
}

HTMLOptions are the presentation choices of the HTML backend. They are options of this backend, never document-model attributes.

type MarkdownOptions added in v0.8.0

type MarkdownOptions struct {
	// DiagramForm is the source every graph-shaped diagram is written as,
	// Mermaid when empty; a table-kind view is a pipe table whichever it is.
	DiagramForm view.Form
}

MarkdownOptions are the presentation choices of the Markdown 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL