Documentation ¶
Overview ¶
Package format implements formatting of Rego source files.
Index ¶
- func ArityFormatMismatchError(operands []*ast.Term, operator string, loc *ast.Location, f *types.Function) *ast.Error
- func Ast(x interface{}) ([]byte, error)
- func AstWithOpts(x interface{}, opts Opts) ([]byte, error)
- func MustAst(x interface{}) []byte
- func Source(filename string, src []byte) ([]byte, error)
- func SourceWithOpts(filename string, src []byte, opts Opts) ([]byte, error)
- type ArityFormatErrDetail
- type Opts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArityFormatMismatchError ¶ added in v0.51.0
func ArityFormatMismatchError(operands []*ast.Term, operator string, loc *ast.Location, f *types.Function) *ast.Error
arityMismatchError but for `fmt` checks since the compiler has not run yet.
func Ast ¶
Ast formats a Rego AST element. If the passed value is not a valid AST element, Ast returns nil and an error. If AST nodes are missing locations an arbitrary location will be used.
func AstWithOpts ¶ added in v0.40.0
func MustAst ¶ added in v0.9.2
func MustAst(x interface{}) []byte
MustAst is a helper function to format a Rego AST element. If any errors occurs this function will panic. This is mostly used for test
Types ¶
type ArityFormatErrDetail ¶ added in v0.51.0
ArgErrDetail but for `fmt` checks since compiler has not run yet.
func (*ArityFormatErrDetail) Lines ¶ added in v0.51.0
func (d *ArityFormatErrDetail) Lines() []string
Lines returns the string representation of the detail.
type Opts ¶ added in v0.40.0
type Opts struct { // IgnoreLocations instructs the formatter not to use the AST nodes' locations // into account when laying out the code: notably, when the input is the result // of partial evaluation, arguments maybe have been shuffled around, but still // carry along their original source locations. IgnoreLocations bool // RegoVersion is the version of Rego to format code for. RegoVersion ast.RegoVersion // ParserOptions is the parser options used when parsing the module to be formatted. ParserOptions *ast.ParserOptions }
Opts lets you control the code formatting via `AstWithOpts()`.
Click to show internal directories.
Click to hide internal directories.