print

package
v0.4.3-final-apache Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrReplacerSkipChildren could be returned from the ReplaceNodes replacer func
	// to skip children. Will never be returned by ReplaceNodes itself.
	ErrReplacerSkipChildren = errors.New("skip children")
	// ErrReplacerStuck means that replacer failed to make progress
	ErrReplacerStuck = errors.New("replacer stuck")
)

Functions

func ReplaceNodes

func ReplaceNodes(n ast.Node, replacer func(n ast.Node) (repl ast.Node, err error)) (ast.Node, error)

ReplaceNodes walks the AST starting from the given node and replaces nodes in it. If replacer returns nil - the node is deleted

func ReplaceNodesInContent

func ReplaceNodesInContent(el plugin.Content, replacer func(src *astsrc.ASTSource, n ast.Node) (repl ast.Node, err error)) error

ReplaceNodesInContent runs ReplaceNodes on plugin.ContentAST nodes Replacer is not expected to replace the top-level plugin node (ContentNode)

Types

type Printer

type Printer interface {
	Print(ctx context.Context, w io.Writer, el plugin.Content) error
}

Printer is the interface for printing content.

func WithLogging

func WithLogging(next Printer, logger *slog.Logger, attrs ...slog.Attr) Printer

WithLogging wraps the printer with logging instrumentation.

func WithTracing

func WithTracing(next Printer, tracer trace.Tracer, attrs ...attribute.KeyValue) Printer

WithTracing wraps a printer with tracing instrumentation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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