Documentation ¶
Overview ¶
Package renderer renders the given AST to certain formats.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Options map[OptionName]interface{} NodeRenderers util.PrioritizedSlice }
A Config struct is a data structure that holds configuration of the Renderer.
type NodeRenderer ¶
type NodeRenderer interface { // RendererFuncs registers NodeRendererFuncs to given NodeRendererFuncRegisterer. RegisterFuncs(NodeRendererFuncRegisterer) }
A NodeRenderer interface offers NodeRendererFuncs.
type NodeRendererFunc ¶
type NodeRendererFunc func(writer util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error)
NodeRendererFunc is a function that renders a given node.
type NodeRendererFuncRegisterer ¶
type NodeRendererFuncRegisterer interface { // Register registers given NodeRendererFunc to this object. Register(ast.NodeKind, NodeRendererFunc) }
A NodeRendererFuncRegisterer registers
type Option ¶
type Option interface {
SetConfig(*Config)
}
An Option interface is a functional option type for the Renderer.
func WithNodeRenderers ¶
func WithNodeRenderers(ps ...util.PrioritizedValue) Option
WithNodeRenderers is a functional option that allow you to add NodeRenderers to the renderer.
func WithOption ¶
func WithOption(name OptionName, value interface{}) Option
WithOption is a functional option that allow you to set an arbitrary option to the parser.
type Renderer ¶
type Renderer interface { Render(w io.Writer, source []byte, n ast.Node) error // AddOptions adds given option to this renderer. AddOptions(...Option) }
A Renderer interface renders given AST node to given writer with given Renderer.
func NewRenderer ¶
NewRenderer returns a new Renderer with given options.
type SetOptioner ¶
type SetOptioner interface { // SetOption sets given option to the object. // Unacceptable options may be passed. // Thus implementations must ignore unacceptable options. SetOption(name OptionName, value interface{}) }
A SetOptioner interface sets given option to the object.