mapcheck

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mapcheck checks a product's map against its format and size limits: the rules `physa check map` enforces. It builds on the reader's problems and adds what each kind of entry must carry, that every folder keeps the folder format (index.md's grammar and links, each kind file's title, sections, headings, and contents that match its entries), that slugs and terms are unique, that document anchors name files in the repo, that commit anchors name changes in the repo's history, read through version control, and that each file stays within its limit.

Index

Constants

View Source
const (
	MaxIndexLines = 30
	MaxRulesLines = 150
)

The size limits of a folder's files (09 §6), the same for the product and every capability. Going over one fails the check; decisions.md and questions.md have none.

View Source
const (
	PRAnchorsGitHub   = "github"
	PRAnchorsFormOnly = "form-only"
)

The values of Result.PRAnchors.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// PRExists tells whether a PR with this number exists. Nil checks #N
	// anchors for form only. An error stops resolving for the rest of the
	// run: PR anchors are then checked for form only.
	PRExists func(n int) (bool, error)
	// OpenRepo opens the version control holding root. It is called once,
	// when the first commit anchor is met. Nil leaves commit anchors
	// unresolved: each is a problem.
	OpenRepo func(root string) (vcs.Repo, error)
	// DocRoot is where `from <path>` anchors resolve; empty means root. A
	// scratch copy of the map uses it to check against the real repo.
	DocRoot string
	// FormOnly checks every anchor for its form alone: a commit anchor is
	// not resolved, so it is no problem, and a #N anchor is not resolved
	// whatever PRExists says. History and the forge are never read. Every
	// other check runs as it does without the option: format, contents,
	// slugs, terms, size limits, and `from <path>` anchors naming a file.
	FormOnly bool
}

Options carries what the check cannot learn from the repo's files.

type Result

type Result struct {
	Problems     []mapfile.Problem // sorted by path, then line, then message
	Capabilities int
	Entries      int // entries in the product and in every capability

	// PRAnchors says how #N anchors were checked: PRAnchorsGitHub when every
	// one was resolved, PRAnchorsFormOnly when only their form was.
	PRAnchors string
	// PRNote is why PR anchors were checked for form only after the resolver
	// failed; empty otherwise (the caller explains a missing resolver).
	PRNote string
}

Result is what a check found.

func Check

func Check(root string) (Result, error)

Check reads the map under root (the repo root) and checks it, with no resolver for #N anchors and no version control for commit anchors. The error is only for a map that cannot be read at all.

func CheckRead

func CheckRead(root string, o Options) (*mapfile.Map, Result, error)

CheckRead is CheckWith that also returns the map it read, so a caller that needs the map reads it once. The map is nil only with an error.

func CheckWith

func CheckWith(root string, o Options) (Result, error)

CheckWith is Check with options: it resolves #N anchors through o.PRExists and commit anchors through o.OpenRepo, when each is set.

Jump to

Keyboard shortcuts

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