requiredstructure

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PathPattern added in v0.14.0

type PathPattern struct {
	Kind    string
	Pattern string
}

PathPattern records a kind's `path-pattern:` constraint: the kind that declared it and the glob the workspace-relative path of every file in the kind must match. Populated by the config merge layer from KindBody.PathPattern.

type Rule

type Rule struct {
	Schema       string         // path to schema file
	InlineSchema *schema.Schema // parsed inline schema (when set)
	Placeholders []string       // placeholder tokens to treat as opaque
	PathPatterns []PathPattern  // kind-level path-pattern entries
}

Rule checks that a document's heading structure matches a schema.

A rule instance holds at most one schema source: a path to a proto.md file (Schema) or an already-parsed inline schema (InlineSchema). The kind-level loader rejects configurations that set both on the same kind; the merge logic in internal/config clears the other source whenever a later layer installs a new one, so the rule never has to disambiguate at runtime.

func (*Rule) ApplySettings

func (r *Rule) ApplySettings(settings map[string]any) error

ApplySettings implements rule.Configurable.

func (*Rule) Category

func (r *Rule) Category() string

Category implements rule.Rule.

func (*Rule) Check

func (r *Rule) Check(f *lint.File) []lint.Diagnostic

Check implements rule.Rule.

func (*Rule) DefaultSettings

func (r *Rule) DefaultSettings() map[string]any

DefaultSettings implements rule.Configurable.

func (*Rule) Fix added in v0.14.0

func (r *Rule) Fix(f *lint.File) []byte

Fix implements rule.FixableRule. The rule does not modify the document body — it returns f.Source unchanged — but when the inline schema declares an `index:` block, Fix emits the JSON side-output next to the source file. `mdsmith check` skips the write, preserving check's read-only contract (plan 143).

Fix swallows the WriteIndex error because Fix returns bytes, not diagnostics. WriteIndex itself records any failure in the package-level cache keyed by f.Path; the next Check reads that cache and surfaces the underlying I/O error in place of the generic "missing / out of date" message, so users are not trapped in a fix loop without signal.

func (*Rule) ID

func (r *Rule) ID() string

ID implements rule.Rule.

func (*Rule) Name

func (r *Rule) Name() string

Name implements rule.Rule.

func (*Rule) SettingMergeMode added in v0.7.0

func (r *Rule) SettingMergeMode(key string) rule.MergeMode

SettingMergeMode implements rule.ListMerger.

Jump to

Keyboard shortcuts

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