Documentation
¶
Index ¶
- Constants
- Variables
- func ExcludeWithGitignore(gitignorePath string, paths []string) ([]string, error)
- func IsMetadataType(mdValueStr string) bool
- func ReadMetadata(content []byte, path string) (collections.Set[Metadata], collections.Errors)
- type BasicContentAnalyzer
- type ContentAnalyzer
- type DoublestarCollector
- type Engine
- type Factory
- type Feature
- type FeatureApplyError
- type FeatureApplyMode
- type FeatureFunc
- type FeatureList
- type FileDiff
- type FileDiffs
- type FilepathCollector
- type FormatDiff
- type Formatter
- type LineBreakStyle
- type MatchType
- type Metadata
- type MetadataError
- type MetadataType
- type Operation
- type PathCollector
- type PatternFileCollector
- type Registry
- type UnsupportedLineBreakError
Constants ¶
View Source
const DefaultPatternFile = "yamlfmt.patterns"
View Source
const MetadataIdentifier = "!yamlfmt!"
Variables ¶
View Source
var ( ErrMalformedMetadata = errors.New("metadata: malformed string") ErrUnrecognizedMetadata = errors.New("metadata: unrecognized type") )
Functions ¶
func ExcludeWithGitignore ¶ added in v0.11.0
func IsMetadataType ¶ added in v0.9.0
func ReadMetadata ¶ added in v0.9.0
func ReadMetadata(content []byte, path string) (collections.Set[Metadata], collections.Errors)
Types ¶
type BasicContentAnalyzer ¶ added in v0.9.0
func NewBasicContentAnalyzer ¶ added in v0.9.0
func NewBasicContentAnalyzer(patterns []string) (BasicContentAnalyzer, error)
func (BasicContentAnalyzer) ExcludePathsByContent ¶ added in v0.9.0
func (a BasicContentAnalyzer) ExcludePathsByContent(paths []string) ([]string, []string, error)
type ContentAnalyzer ¶ added in v0.9.0
type DoublestarCollector ¶ added in v0.7.0
func (*DoublestarCollector) CollectPaths ¶ added in v0.7.0
func (c *DoublestarCollector) CollectPaths() ([]string, error)
type Feature ¶ added in v0.4.0
type Feature struct { Name string BeforeAction FeatureFunc AfterAction FeatureFunc }
type FeatureApplyError ¶ added in v0.4.0
type FeatureApplyError struct {
// contains filtered or unexported fields
}
func (*FeatureApplyError) Error ¶ added in v0.4.0
func (e *FeatureApplyError) Error() string
func (*FeatureApplyError) Unwrap ¶ added in v0.4.0
func (e *FeatureApplyError) Unwrap() error
type FeatureApplyMode ¶ added in v0.4.0
type FeatureApplyMode string
var ( FeatureApplyBefore FeatureApplyMode = "Before" FeatureApplyAfter FeatureApplyMode = "After" )
type FeatureFunc ¶ added in v0.4.0
type FeatureList ¶ added in v0.4.0
type FeatureList []Feature
func (FeatureList) ApplyFeatures ¶ added in v0.4.0
func (fl FeatureList) ApplyFeatures(ctx context.Context, input []byte, mode FeatureApplyMode) (context.Context, []byte, error)
type FileDiff ¶ added in v0.8.0
type FileDiff struct { Path string Diff *FormatDiff }
func (*FileDiff) StrOutputQuiet ¶ added in v0.8.0
type FileDiffs ¶ added in v0.8.0
func (FileDiffs) ChangedCount ¶ added in v0.8.0
func (FileDiffs) StrOutputQuiet ¶ added in v0.8.0
type FilepathCollector ¶ added in v0.7.0
func (*FilepathCollector) CollectPaths ¶ added in v0.7.0
func (c *FilepathCollector) CollectPaths() ([]string, error)
type FormatDiff ¶ added in v0.8.0
func (*FormatDiff) Changed ¶ added in v0.8.0
func (d *FormatDiff) Changed() bool
func (*FormatDiff) MultilineDiff ¶ added in v0.8.0
func (d *FormatDiff) MultilineDiff() (string, int)
type LineBreakStyle ¶ added in v0.5.0
type LineBreakStyle string
const ( LineBreakStyleLF LineBreakStyle = "lf" LineBreakStyleCRLF LineBreakStyle = "crlf" )
func (LineBreakStyle) Separator ¶ added in v0.5.0
func (s LineBreakStyle) Separator() (string, error)
type Metadata ¶ added in v0.9.0
type Metadata struct { Type MetadataType LineNum int }
type MetadataError ¶ added in v0.9.0
type MetadataError struct {
// contains filtered or unexported fields
}
func (*MetadataError) Error ¶ added in v0.9.0
func (e *MetadataError) Error() string
func (*MetadataError) Unwrap ¶ added in v0.9.0
func (e *MetadataError) Unwrap() error
type MetadataType ¶ added in v0.9.0
type MetadataType string
const (
MetadataIgnore MetadataType = "ignore"
)
type PathCollector ¶ added in v0.7.0
type PatternFileCollector ¶ added in v0.15.0
type PatternFileCollector struct {
// contains filtered or unexported fields
}
PatternFileCollector determines which files to format and which to ignore based on a pattern file in gitignore(5) syntax.
func NewPatternFileCollector ¶ added in v0.15.0
func NewPatternFileCollector(files ...string) (*PatternFileCollector, error)
NewPatternFileCollector initializes a new PatternFile using the provided file(s). If multiple files are provided, their content is concatenated in order. All patterns are relative to the current working directory.
func NewPatternFileCollectorFS ¶ added in v0.15.0
func NewPatternFileCollectorFS(r io.Reader, fs fs.FS) *PatternFileCollector
NewPatternFileCollectorFS reads a pattern file from r and uses fs for file lookups. It is used by NewPatternFile and primarily public because it is useful for testing.
func (*PatternFileCollector) CollectPaths ¶ added in v0.15.0
func (c *PatternFileCollector) CollectPaths() ([]string, error)
CollectPaths implements the PathCollector interface.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewFormatterRegistry ¶
func (*Registry) GetDefaultFactory ¶
type UnsupportedLineBreakError ¶ added in v0.5.0
type UnsupportedLineBreakError struct {
// contains filtered or unexported fields
}
func (UnsupportedLineBreakError) Error ¶ added in v0.5.0
func (e UnsupportedLineBreakError) Error() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.