mapfile

package
v0.0.30 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: 9 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 mapfile reads a product's map from its .physa directory: the product's folder, each capability's folder and the glossary. A folder is read whole: index.md for the promise, stewards, title and overview, then rules.md, decisions.md and questions.md for its entries. It turns them into entries (rules, decisions and questions), anchors and terms, describes each file it read so the checks can judge the folder's format, and reports every spot where the map is malformed, with its file and line. It judges form only: what an entry of each kind must carry, whether anchors point anywhere, and whether a folder's contents match its entries are questions for the checks built on top of it.

Index

Constants

View Source
const (
	Rule     = mapfolder.Rule
	Decision = mapfolder.Decision
	Question = mapfolder.Question
)

The entry kinds, one per kind file of a folder.

View Source
const OldLayout = "the map is in the old single-file format; convert it to folders (docs/architecture/09-capability-folders.md)"

OldLayout is the message for each file of a map still in the single-file layout.

Variables

This section is empty.

Functions

func Read

func Read(root string) (*Map, []Problem, error)

Read reads the map in root/.physa. The error is for I/O failure, such as a missing .physa directory; every fault in the format is a Problem, and reading goes on past each one. A missing capabilities directory means the map has no capabilities yet and is not a Problem; a capabilities path that is not a directory is one. A map in the old single-file layout gives one Problem per old file, saying to convert it.

func ValidSlug

func ValidSlug(s string) bool

ValidSlug says whether s is a slug: lowercase words of letters and digits joined by single hyphens, as a capability folder's name or an entry's slug must be.

Types

type Anchor

type Anchor struct {
	Kind  AnchorKind
	Value string // "1102", "a1b2c3d" or "docs/vision.md"
}

Anchor links an entry to the change or document that made it real.

type AnchorKind

type AnchorKind int

AnchorKind says what an anchor points at.

const (
	PR AnchorKind = iota + 1
	Commit
	Doc
)

The anchor kinds: a pull request, a commit, or a document in the repo.

type Entry

type Entry struct {
	Kind     Kind
	Heading  string
	Path     string // the kind file it sits in, e.g. ".physa/capabilities/init/rules.md"
	Line     int    // line of the heading in that file
	Slug     string
	Role     string // "decided" or "raised", empty without a person
	Person   string
	How      string // text after the person's comma, e.g. "accepting a proposal"
	Date     string
	Anchors  []Anchor
	Body     string // prose between the meta line and Because:/Rejected:, blank lines dropped
	Because  string
	Rejected []string
	MetaHas  Meta
	// contains filtered or unexported fields
}

Entry is one rule, decision or question.

type File

type File struct {
	Path         string // the folder, slash-separated, relative to the root
	Name         string // the folder's name, the capability's slug; "product" for the product
	Lines        int    // lines of index.md, as wc -l counts them
	Promise      string
	Stewards     []string
	Title        string
	Overview     string  // index.md's overview paragraph, its lines joined by "\n"
	OverviewLine int     // line of the overview's first line in index.md; 0 without one
	Entries      []Entry // rules, then decisions, then questions, each in file order
	Parts        []Part  // index.md first, then each kind file the folder has
}

File is the product or one capability: its folder, read whole.

type Kind

type Kind = mapfolder.Kind

Kind says which kind an entry is; the file it sits in decides it.

type Line

type Line struct {
	No   int
	Text string
}

Line is one line of a file and its line number.

type Map

type Map struct {
	Product      *File   // nil when the product's folder is missing
	Capabilities []*File // sorted by Name
	Glossary     []Term
	HasReadme    bool
}

Map is everything read from a product's .physa directory.

type Meta

type Meta struct {
	Slug, Person, Date, Anchors bool
}

Meta says which parts of an entry's meta line were present.

type Part

type Part struct {
	Path      string // slash-separated, relative to the root
	Kind      Kind   // 0 for index.md
	Lines     int    // as wc -l counts them
	Title     string // the text after "# ", empty without a title
	TitleLine int
	// Contents are the "- " lines under ## Contents in a kind file, or the
	// link lines of index.md, as written.
	Contents []Line
	// Headings are every heading outside a fenced block, "#" marks included.
	Headings []Line
	// OutsideEntries are the lines of "###" headings outside ## Entries; in
	// index.md, every "###" heading.
	OutsideEntries []int
	// Text is index.md's text as read, for the checks to judge its grammar;
	// empty in a kind file.
	Text string
}

Part is one file of a folder as it was read, for the checks to judge its format without reading it again.

type Problem

type Problem struct {
	Path    string // slash-separated, relative to the root
	Line    int    // 0 when the whole file is at fault
	Message string
}

Problem is one malformed spot in the map.

func (Problem) String

func (p Problem) String() string

type Term

type Term struct {
	Name       string
	Definition string // text after "**Name**: "
	Avoid      []string
	Line       int
}

Term is one glossary term.

Jump to

Keyboard shortcuts

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