narrator

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: AGPL-3.0, AGPL-3.0-only Imports: 3 Imported by: 0

Documentation

Overview

Package narrator composes modules into managed README sections.

Modules are pluggable content producers (badges, shields, text, etc.) that render to inline markdown. The narrator orchestrates them into rows with layout control, then the result gets injected into <!-- sf:<name> --> sections via the section primitives.

Items within a row are space-joined (inline). Rows are blank-line-separated (markdown paragraph breaks). Break modules force a new row.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compose

func Compose(modules []Module) string

Compose takes a flat list of modules. Items are space-joined until a BreakModule forces a new row. Rows are separated by blank lines for proper markdown paragraph breaks. Returns the composed content string.

func ComposeInline

func ComposeInline(modules []Module) string

ComposeInline renders all modules and joins them with spaces on a single line. BreakModules are ignored. Use for inline badge rows.

func ComposeRows

func ComposeRows(rows [][]Module) string

ComposeRows takes rows of modules (pre-grouped). Items within a row are space-joined. Rows are newline-joined. Kept for backward compatibility.

Types

type BadgeModule

type BadgeModule struct {
	Alt    string // image alt text
	ImgURL string // resolved image URL
	Link   string // resolved click target (empty = no link wrapper)
}

BadgeModule renders a markdown badge image, optionally wrapped in a link.

func (BadgeModule) Render

func (b BadgeModule) Render() string

Render produces the inline markdown for this badge.

type BreakModule

type BreakModule struct{}

BreakModule forces a line break in composition. Items before the break are on one line, items after start a new line.

func (BreakModule) Render

func (BreakModule) Render() string

Render returns empty — breaks are handled by Compose, not rendered.

type ComponentModule

type ComponentModule struct {
	Docs string // pre-rendered markdown from component.GenerateDocs
}

ComponentModule renders pre-generated component documentation markdown. The spec file is parsed and docs generated by the caller; this module just carries the rendered output into the narrator composition pipeline.

func (ComponentModule) Render

func (c ComponentModule) Render() string

Render returns the component documentation as-is.

type IncludeModule

type IncludeModule struct {
	Content string // raw file content (read by caller)
}

IncludeModule renders verbatim file content included via kind: include. The file is read by the caller; this module carries the raw content into the narrator composition pipeline without transformation.

func (IncludeModule) Render

func (i IncludeModule) Render() string

Render returns the included content as-is.

type Module

type Module interface {
	Render() string
}

Module produces inline markdown content for a single item.

type PropsModule

type PropsModule struct {
	Resolved props.ResolvedProp
	Variant  props.Variant
}

PropsModule renders a resolved prop through the shared FormatMarkdown path. The prop is resolved before this module is created.

func (PropsModule) Render

func (p PropsModule) Render() string

Render produces the inline markdown for this prop via the shared render path.

type ShieldModule

type ShieldModule struct {
	Path  string // shields.io path (e.g., "docker/pulls/myorg/myrepo")
	Label string // override label (used as alt text; empty = last path segment)
	Link  string // click target URL (empty = no link wrapper)
}

ShieldModule renders a shields.io badge from a path shorthand. The path is appended to https://img.shields.io/ to form the image URL.

func (ShieldModule) Render

func (s ShieldModule) Render() string

Render produces the inline markdown for this shields.io badge.

type TextModule

type TextModule struct {
	Text string // markdown content (templates already resolved by caller)
}

TextModule renders literal markdown text. Template variables ({version}, {env:VAR}, etc.) are resolved before rendering.

func (TextModule) Render

func (t TextModule) Render() string

Render returns the text content as-is.

Jump to

Keyboard shortcuts

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