maxsectionlength

package
v0.23.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HeadingPattern

type HeadingPattern struct {
	Pattern string
	Regex   *regexp.Regexp
	Max     int
}

HeadingPattern is a regex pattern matched against heading text with an associated maximum section length.

type Rule

type Rule struct {
	// Max is the default per-section line limit. Zero means no global limit.
	Max int
	// PerLevel overrides Max for a specific heading level (1-6).
	PerLevel map[int]int
	// PerHeading overrides Max and PerLevel when the heading text matches.
	// The first pattern that matches wins.
	PerHeading []HeadingPattern
	// MaxWords caps the word count of a section's prose. Zero disables.
	MaxWords int
	// MinWords sets a lower bound on a section's word count. Zero disables.
	MinWords int
	// MaxParagraphs caps the number of paragraphs in a section. Zero disables.
	MaxParagraphs int
}

Rule enforces per-section line, word, and paragraph counts.

Section span is the lines from the heading line up to (but not including) the next heading line of any level, or the end of file. Nested subsections are measured separately from their parent. Word counts come from the plain text of paragraph nodes inside the section; paragraph counts include only paragraphs in that range (sub-section paragraphs belong to the sub-section).

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. All keys are returned so re-applying defaults (e.g., test cleanup) fully clears PerLevel and PerHeading, not just Max.

func (*Rule) EnabledByDefault

func (r *Rule) EnabledByDefault() bool

EnabledByDefault implements rule.Defaultable.

func (*Rule) ID

func (r *Rule) ID() string

ID implements rule.Rule.

func (*Rule) Name

func (r *Rule) Name() string

Name implements rule.Rule.

Jump to

Keyboard shortcuts

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