Documentation ¶
Overview ¶
Package ast declares the types used to represent syntax trees for the .env file.
Index ¶
- Constants
- func ContextualError(stmt Statement, err error) error
- func ExcludeActiveAssignments(input Statement) selectorResult
- func ExcludeComments(input Statement) selectorResult
- func ExcludeDisabledAssignments(input Statement) selectorResult
- func ExcludeHiddenViaAnnotation(input Statement) selectorResult
- type Assignment
- func (a *Assignment) Annotation(name string) []string
- func (a *Assignment) BelongsToGroup(name string) bool
- func (a *Assignment) CommentsSlice() []string
- func (a *Assignment) Disable()
- func (a *Assignment) Documentation(withoutPrefix bool) string
- func (a *Assignment) DocumentationSummary() string
- func (a *Assignment) Enable()
- func (a *Assignment) GetSafeLiteral() string
- func (a *Assignment) HasComments() bool
- func (a *Assignment) Initialize(ctx context.Context)
- func (a *Assignment) Is(other Statement) bool
- func (a *Assignment) IsHidden() bool
- func (a *Assignment) SetLiteral(ctx context.Context, in string)
- func (a *Assignment) Type() string
- func (a *Assignment) Unquote(ctx context.Context) (string, error)
- func (a *Assignment) ValidationRules() string
- type Comment
- type Document
- func (doc *Document) AccessibleVariables(target *Assignment) func() map[string]string
- func (d *Document) AllAssignments(selectors ...Selector) []*Assignment
- func (d *Document) Assignments() []*Assignment
- func (d *Document) BelongsToGroup(name string) bool
- func (doc *Document) EnsureGroup(name string) *Group
- func (d *Document) Get(name string) *Assignment
- func (d *Document) GetAssignmentIndex(name string) (int, *Assignment)
- func (d *Document) GetConfig(name string) (string, error)
- func (d *Document) GetGroup(name string) *Group
- func (d *Document) Has(name string) bool
- func (d *Document) HasGroup(name string) bool
- func (document *Document) Initialize(ctx context.Context)
- func (doc *Document) InterpolateAll(ctx context.Context) error
- func (doc *Document) InterpolateStatement(ctx context.Context, target *Assignment) error
- func (doc *Document) InterpolationMapper(target *Assignment) func(input string) (string, bool)
- func (d *Document) Is(other Statement) bool
- func (d *Document) ReindexStatements()
- func (document *Document) Replace(assignment *Assignment) error
- func (d *Document) Type() string
- func (document *Document) Validate(ctx context.Context, selectors []Selector, ignoreErrors []string) ([]*ValidationError, error)
- func (document *Document) ValidateSingleAssignment(ctx context.Context, assignment *Assignment, selectors []Selector, ...) (ValidationErrors, error)
- type Group
- type Newline
- type Position
- type Selector
- type Statement
- type StatementCollection
- type ValidationError
- type ValidationErrors
Constants ¶
const ( Exclude selectorResult = iota Keep )
Variables ¶
This section is empty.
Functions ¶
func ContextualError ¶ added in v0.8.0
func ExcludeActiveAssignments ¶ added in v0.6.2
func ExcludeActiveAssignments(input Statement) selectorResult
ExcludeActiveAssignments will exclude *ACTIVE* Assignments
func ExcludeComments ¶ added in v0.6.2
func ExcludeComments(input Statement) selectorResult
ExcludeComments will *EXCLUDE* all comments
func ExcludeDisabledAssignments ¶ added in v0.6.2
func ExcludeDisabledAssignments(input Statement) selectorResult
ExcludeDisabledAssignments will exclude *DISABLED* Assignments
func ExcludeHiddenViaAnnotation ¶ added in v0.6.2
func ExcludeHiddenViaAnnotation(input Statement) selectorResult
ExcludeHiddenViaAnnotation will exclude *HIDDEN* Assignments via the [@dottie/hidden] annotation
Types ¶
type Assignment ¶
type Assignment struct { Complete bool `json:"complete"` // The key/value had no value/content after the "=" sign Enabled bool `json:"enabled"` // The assignment was enabled out (#KEY=VALUE) Interpolated string `json:"interpolated"` // Value of the key (after interpolation) Literal string `json:"literal"` // Value of the key (right hand side of the "=" sign) Name string `json:"key"` // Name of the key (left hand side of the "=" sign) Quote token.Quote `json:"quote"` // The style of quotes used for the assignment Position Position `json:"position"` // Information about position of the assignment in the file Comments []*Comment `json:"comments"` // Comments attached to the assignment (e.g. doc block before it) Dependencies map[string]template.Variable `json:"dependencies"` // Assignments that this assignment depends on Dependents map[string]*Assignment `json:"dependents"` // Assignments dependents on this assignment Group *Group `json:"-"` // The (optional) group this assignment belongs to }
func (*Assignment) Annotation ¶ added in v0.10.0
func (a *Assignment) Annotation(name string) []string
func (*Assignment) BelongsToGroup ¶
func (a *Assignment) BelongsToGroup(name string) bool
func (*Assignment) CommentsSlice ¶ added in v0.7.0
func (a *Assignment) CommentsSlice() []string
func (*Assignment) Disable ¶ added in v0.6.0
func (a *Assignment) Disable()
func (*Assignment) Documentation ¶ added in v0.2.0
func (a *Assignment) Documentation(withoutPrefix bool) string
func (*Assignment) DocumentationSummary ¶ added in v0.6.2
func (a *Assignment) DocumentationSummary() string
func (*Assignment) Enable ¶ added in v0.6.0
func (a *Assignment) Enable()
func (*Assignment) GetSafeLiteral ¶ added in v0.11.0
func (a *Assignment) GetSafeLiteral() string
func (*Assignment) HasComments ¶
func (a *Assignment) HasComments() bool
func (*Assignment) Initialize ¶ added in v0.8.0
func (a *Assignment) Initialize(ctx context.Context)
func (*Assignment) Is ¶
func (a *Assignment) Is(other Statement) bool
func (*Assignment) IsHidden ¶ added in v0.6.2
func (a *Assignment) IsHidden() bool
func (*Assignment) SetLiteral ¶ added in v0.9.4
func (a *Assignment) SetLiteral(ctx context.Context, in string)
func (*Assignment) Type ¶ added in v0.3.0
func (a *Assignment) Type() string
func (*Assignment) Unquote ¶ added in v0.9.4
func (a *Assignment) Unquote(ctx context.Context) (string, error)
func (*Assignment) ValidationRules ¶
func (a *Assignment) ValidationRules() string
type Comment ¶
type Comment struct { Value string `json:"value"` // The actual comment value Annotation *token.Annotation `json:"annotation"` // If the comment was detected to be an annotation Group *Group `json:"-"` // The (optional) group the comment belongs to Position Position `json:"position"` // Information about position of the assignment in the file }
Comment node represents a comment statement.
func NewComment ¶
func NewCommentsFromSlice ¶ added in v0.8.0
func (*Comment) BelongsToGroup ¶
func (Comment) CleanString ¶ added in v0.7.0
type Document ¶
type Document struct { Statements []Statement `json:"statements"` // Statements belonging to the root of the document Groups []*Group `json:"groups"` // Groups within the document Annotations []*Comment `json:"-"` // Global annotations for configuration of dottie // contains filtered or unexported fields }
Document node represents .env file statement, that contains assignments and comments.
func NewDocument ¶ added in v0.8.0
func NewDocument() *Document
func (*Document) AccessibleVariables ¶ added in v0.10.0
func (doc *Document) AccessibleVariables(target *Assignment) func() map[string]string
func (*Document) AllAssignments ¶ added in v0.7.0
func (d *Document) AllAssignments(selectors ...Selector) []*Assignment
func (*Document) Assignments ¶
func (d *Document) Assignments() []*Assignment
func (*Document) BelongsToGroup ¶
func (*Document) EnsureGroup ¶ added in v0.1.0
func (*Document) Get ¶
func (d *Document) Get(name string) *Assignment
func (*Document) GetAssignmentIndex ¶ added in v0.7.0
func (d *Document) GetAssignmentIndex(name string) (int, *Assignment)
func (*Document) Initialize ¶ added in v0.8.0
func (*Document) InterpolateAll ¶ added in v0.8.0
func (*Document) InterpolateStatement ¶ added in v0.8.0
func (doc *Document) InterpolateStatement(ctx context.Context, target *Assignment) error
func (*Document) InterpolationMapper ¶ added in v0.10.0
func (doc *Document) InterpolationMapper(target *Assignment) func(input string) (string, bool)
func (*Document) ReindexStatements ¶ added in v0.8.0
func (d *Document) ReindexStatements()
func (*Document) Replace ¶ added in v0.8.0
func (document *Document) Replace(assignment *Assignment) error
func (*Document) ValidateSingleAssignment ¶ added in v0.9.0
func (document *Document) ValidateSingleAssignment(ctx context.Context, assignment *Assignment, selectors []Selector, ignoreErrors []string) (ValidationErrors, error)
type Group ¶
type Group struct { Name string `json:"name"` // Name of the group (within the header) Statements []Statement `json:"statements"` // Statements within the group Position Position `json:"position"` // Positional information about the group }
func (*Group) Assignments ¶ added in v0.7.0
func (g *Group) Assignments() []*Assignment
func (*Group) BelongsToGroup ¶
func (*Group) GetAssignmentIndex ¶ added in v0.7.0
func (g *Group) GetAssignmentIndex(name string) (int, *Assignment)
type Newline ¶
type Position ¶
type Selector ¶ added in v0.6.2
type Selector func(input Statement) selectorResult
func ExcludeKeyPrefix ¶ added in v0.6.2
ExcludeKeyPrefix will *EXCLUDE* Assignments with the provided prefix
func RetainExactKey ¶ added in v0.6.9
RetainExactKey will *RETAIN* Assignments with the exact name
func RetainGroup ¶ added in v0.6.2
RetainGroup will exclude Assignment, Group, and Comment statements that do not belong to the provided group name
func RetainKeyPrefix ¶ added in v0.6.2
RetainKeyPrefix will *RETAIN* Assignments with the provided prefix
type Statement ¶
type Statement interface { Is(statement Statement) bool Type() string // contains filtered or unexported methods }
Statement represents syntax tree node of .env file statement (like: assignment or comment).
type StatementCollection ¶ added in v0.7.0
type StatementCollection interface { Assignments() []*Assignment GetAssignmentIndex(name string) (int, *Assignment) }
type ValidationError ¶ added in v0.9.0
type ValidationError struct { WrappedError any Assignment *Assignment }
func NewError ¶ added in v0.9.0
func NewError(assignment *Assignment, err error) *ValidationError
func (ValidationError) Error ¶ added in v0.9.0
func (e ValidationError) Error() string
type ValidationErrors ¶ added in v0.9.0
type ValidationErrors []*ValidationError
func (ValidationErrors) Error ¶ added in v0.9.0
func (x ValidationErrors) Error() string
func (ValidationErrors) Errors ¶ added in v0.9.0
func (x ValidationErrors) Errors() []*ValidationError