config

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config loads .doclint.yaml: rule defaults/toggles, per-rule settings, ignore globs, and the declarative custom-rule block.

Index

Constants

View Source
const ConfigName = ".doclint.yaml"

ConfigName is the discovered file name.

Variables

This section is empty.

Functions

func Discover

func Discover(start string) (string, error)

Discover walks up from start looking for ConfigName; returns "" if none.

func Validate added in v0.2.2

func Validate(cfg *Config, knownRules []string) error

Validate checks a loaded config and returns the first problem as a clear, file-prefixed error. knownRules are the registered built-in rule names; custom rule IDs are added to the known set so enable/disable/settings may reference them. It runs at preflight, before the engine builds, so a malformed config fails fast with an actionable message instead of silently doing nothing.

Types

type Config

type Config struct {
	Default  string                 `yaml:"default"`
	Enable   []string               `yaml:"enable"`
	Disable  []string               `yaml:"disable"`
	Settings map[string]RuleSetting `yaml:"settings"`
	Ignore   []string               `yaml:"ignore"`
	Paths    []string               `yaml:"paths"` // default lint/fmt targets when none given on the CLI
	Custom   []CustomRule           `yaml:"custom"`
	Fmt      FmtConfig              `yaml:"fmt"` // `fmt` command formatting-pass options

	Dir string `yaml:"-"` // directory of the config file (relative-path base)
}

Config is the parsed .doclint.yaml plus the directory it was loaded from.

func Default

func Default() *Config

Default returns the built-in config used when no file is found.

func Load

func Load(path string) (*Config, error)

Load reads and parses a config file.

type CustomRule

type CustomRule struct {
	ID         string   `yaml:"id"`
	Type       string   `yaml:"type"`
	Glob       string   `yaml:"glob"`
	Field      string   `yaml:"field"`
	Fields     []string `yaml:"fields"`
	Min        int      `yaml:"min"`
	Max        int      `yaml:"max"`
	Pattern    string   `yaml:"pattern"`
	SkipDrafts bool     `yaml:"skip_drafts"`
	Severity   string   `yaml:"severity"`
}

CustomRule is one declarative rule (mirrors rule.DeclSpec; kept decoupled so config has no dependency on package rule's internals).

type FmtConfig added in v0.7.5

type FmtConfig struct {
	ShortcodeIndent ShortcodeIndentConfig `yaml:"shortcode_indent"`
}

FmtConfig configures the `fmt` command's formatting passes.

type RuleSetting

type RuleSetting struct {
	Severity string `yaml:"severity"`
}

RuleSetting overrides a rule's defaults.

type ShortcodeIndentConfig added in v0.7.5

type ShortcodeIndentConfig struct {
	Enabled     *bool    `yaml:"enabled"`      // run the pass at all (default true)
	IndentWidth *int     `yaml:"indent_width"` // spaces per nesting level (default 2)
	Exclude     []string `yaml:"exclude"`      // shortcode names whose subtree is left verbatim
}

ShortcodeIndentConfig configures the shortcode-indent formatting pass, which re-indents Hugo shortcode tags opened inline in a list item to align with the item's continuation content. Pointer fields distinguish "unset" (use the default) from an explicit value.

func (ShortcodeIndentConfig) ExcludeSet added in v0.7.5

func (c ShortcodeIndentConfig) ExcludeSet() map[string]bool

ExcludeSet returns the excluded shortcode names as a set, or nil if none.

func (ShortcodeIndentConfig) IsEnabled added in v0.7.5

func (c ShortcodeIndentConfig) IsEnabled() bool

IsEnabled reports whether the shortcode-indent pass should run.

func (ShortcodeIndentConfig) Width added in v0.7.5

func (c ShortcodeIndentConfig) Width() int

Width returns the per-nesting-level indent width in spaces, clamped to a sane default when unset or negative.

Jump to

Keyboard shortcuts

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