Help us shape the future of Go! Take the 2026 Go Developer Survey

render

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BeginMarker = "<!-- BEGIN nasc index -->"
	EndMarker   = "<!-- END nasc index -->"
)

Markers delimit the region of an output file that nasc owns. Everything outside them is written by hand and preserved across runs.

Variables

This section is empty.

Functions

func Findings

func Findings(w io.Writer, fs []validate.Finding, format Format) error

Findings writes findings in the chosen format.

func Index

func Index(w io.Writer, data IndexData, tmpl string) error

Index renders the index. An empty tmpl uses the embedded default.

func Merge added in v0.0.4

func Merge(existing, generated []byte) []byte

Merge splices a freshly generated index into an existing file. When the file already carries a nasc-managed region it is replaced in place, so hand-written prose above or below it survives. When the file has no region the block is appended after the existing content. An empty file yields just the block.

Types

type Format

type Format int

Format selects an output encoding.

const (
	FormatAuto Format = iota
	FormatTable
	FormatJSON
	FormatJSONL
	FormatPaths
)

func Detect

func Detect(w io.Writer, flag, cfgDefault string) Format

Detect resolves the output format from an explicit flag, the config default, and whether w is a TTY.

type Group

type Group struct {
	Type string
	Docs []model.Doc
}

Group is one type bucket of documents.

type IndexData

type IndexData struct {
	Groups   []Group
	Unmarked []model.Doc
}

IndexData is the template input.

func BuildIndex

func BuildIndex(docs []model.Doc, s *schema.Schema) IndexData

BuildIndex groups marked docs by type and collects the unmarked ones.

Jump to

Keyboard shortcuts

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