capabilitytext

package
v0.0.31 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: 7 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 capabilitytext reads a recovered capability's single text and its terms into a model of its parts (head, sections, entries with their meta lines and anchors, terms) and renders the model back in the same form, so a capability nothing changed renders byte for byte as it was stored. It never words an entry: it only keeps, moves and renders the lines it read, and adds anchors to a meta line.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAnchors

func AddAnchors(e *Entry, others ...Entry) []string

AddAnchors adds to e's meta line every anchor of others it does not have, PRs and commits as one segment, then each document as its own, after the segments it has, and returns the anchors added. The heading, body and Because: lines are never changed; an entry with no meta line gets none.

func AnchorText

func AnchorText(a mapfile.Anchor) string

AnchorText is an anchor as the meta line writes it: "#12", a commit, or "from <path>".

func Anchors

func Anchors(title string, k mapfolder.Kind, es []Entry) map[string]bool

Anchors is the heading anchors of a kind file holding es under the title title, with its title's and its sections'.

func Clash

func Clash(title string, k mapfolder.Kind, es []Entry) string

Clash is the first heading of es whose anchor a heading before it, or the file's title or sections, already has; empty when none.

func Lines

func Lines(text string) int

Lines counts a file's lines as the map check does, as wc -l counts them.

func Rename

func Rename(e *Entry, s string)

Rename gives e the slug s on its meta line.

func Taken

func Taken(title string, k mapfolder.Kind) map[string]bool

Taken is the anchors a kind file's headings may not share: its title's, "Contents" and "Entries", for a file under the title title.

func Union

Union is footprint a with every file of b it lacks, in order.

Types

type Area

type Area struct {
	Name   string `json:"name"`
	Parent string `json:"parent,omitempty"`
}

Area is an area as recovery's order names it: its name together with the area it was split from, empty when it is not a part.

func (Area) String

func (a Area) String() string

type Capability

type Capability struct {
	Name      string
	Area      Area
	Footprint recovering.Footprint
	Head      []string // front matter, title and overview, with the blank lines after them
	Sections  []Section
	TermsHead []string // lines of the terms before the first term
	Terms     []Term
}

Capability is one recovered capability in parts.

func Parse

func Parse(name string, area Area, file, terms string) (Capability, error)

Parse reads file, a capability's single text as recovering.File writes it, and terms, its glossary terms, into a Capability named name in area. A text mapfolder.Split rejects is an error.

func (*Capability) Add

func (c *Capability) Add(e Entry)

Add puts e last in the section of its kind, opening the section, in the order rules, decisions, questions, when the text has none.

func (*Capability) AddTerm

func (c *Capability) AddTerm(t Term)

AddTerm puts t last among the terms, a blank line before it.

func (Capability) Clone

func (c Capability) Clone() Capability

Clone is a deep copy of c, so changing it never changes c.

func (Capability) Entries

func (c Capability) Entries() []Entry

Entries is every entry, in section order and each section's order.

func (*Capability) Entry

func (c *Capability) Entry(slug string) *Entry

Entry is a pointer to the entry with slug, nil when none has it.

func (Capability) File

func (c Capability) File() string

File renders the capability's single text: its head, then each section with its entries, the blank lines it read kept and none at the end.

func (*Capability) Find

func (c *Capability) Find(slug string) (si, ei int, ok bool)

Find is where the entry with slug sits, false when none has it.

func (Capability) Folder

func (c Capability) Folder() (mapfolder.Folder, error)

Folder is the capability's folder as the map writes it, split from File.

func (Capability) Kinded

func (c Capability) Kinded(k mapfolder.Kind) []Entry

Kinded is the entries of kind k, in order.

func (Capability) Overview

func (c Capability) Overview() string

Overview is the overview's lines, one line end apart, empty without one.

func (Capability) Promise

func (c Capability) Promise() string

Promise is the value of the front matter's promise line.

func (Capability) PromiseLine

func (c Capability) PromiseLine() int

PromiseLine is the index in Head of the front matter's promise line, -1 without one.

func (*Capability) Remove

func (c *Capability) Remove(slug string) (Entry, bool)

Remove takes out the entry with slug and returns it, false when none has it. The gap it leaves is kept.

func (Capability) TermsText

func (c Capability) TermsText() string

TermsText renders the capability's terms, as they were read when no term was taken or added.

func (Capability) Title

func (c Capability) Title() string

Title is the text of the title line, after "# ".

type Entry

type Entry struct {
	Kind    mapfolder.Kind
	Slug    string
	Heading string           // the heading line's text after "### "
	Lines   []string         // the heading line, the meta line, the body lines
	Gap     int              // blank lines after the entry
	Anchors []mapfile.Anchor // the anchors of the meta line, in its order
}

Entry is one rule, decision or question as its capability's text holds it: its exact lines from the heading line to its last line, and the blank lines after it.

func (Entry) Body

func (e Entry) Body() string

Body is the entry's body without its Because: line, one line end apart.

func (Entry) Clone

func (e Entry) Clone() Entry

Clone is a deep copy of e.

func (Entry) Meta

func (e Entry) Meta() string

Meta is the entry's meta line, empty when it has none.

func (Entry) Rest

func (e Entry) Rest() []string

Rest is the meta line's segments after the slug that hold no anchor: the person and the date, which code never changes.

func (Entry) Text

func (e Entry) Text() string

Text is the entry's lines, one line end apart, without a last line end.

func (Entry) Words

func (e Entry) Words() []string

Words is every line of the entry but its meta line: the heading, the body and the Because: lines, which code never changes.

type Section

type Section struct {
	Kind    mapfolder.Kind
	Line    string
	Intro   []string
	Entries []Entry
}

Section is one "## " section of a capability's text: its line, the lines before its first entry, and its entries.

type Term

type Term struct {
	Name  string
	Lines []string
	After []string
}

Term is one glossary term: its "**Name**:" line and the _Avoid_ lines right after it, and the other lines after those, up to the next term.

func (Term) Same

func (t Term) Same(o Term) bool

Same says whether t and o are one term written the same way: names equal apart from case, every other byte equal.

func (Term) Text

func (t Term) Text() string

Text is the term's lines, one line end apart.

Jump to

Keyboard shortcuts

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