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 ¶
- func AddAnchors(e *Entry, others ...Entry) []string
- func AnchorText(a mapfile.Anchor) string
- func Anchors(title string, k mapfolder.Kind, es []Entry) map[string]bool
- func Clash(title string, k mapfolder.Kind, es []Entry) string
- func Lines(text string) int
- func Rename(e *Entry, s string)
- func Taken(title string, k mapfolder.Kind) map[string]bool
- func Union(a, b recovering.Footprint) recovering.Footprint
- type Area
- type Capability
- func (c *Capability) Add(e Entry)
- func (c *Capability) AddTerm(t Term)
- func (c Capability) Clone() Capability
- func (c Capability) Entries() []Entry
- func (c *Capability) Entry(slug string) *Entry
- func (c Capability) File() string
- func (c *Capability) Find(slug string) (si, ei int, ok bool)
- func (c Capability) Folder() (mapfolder.Folder, error)
- func (c Capability) Kinded(k mapfolder.Kind) []Entry
- func (c Capability) Overview() string
- func (c Capability) Promise() string
- func (c Capability) PromiseLine() int
- func (c *Capability) Remove(slug string) (Entry, bool)
- func (c Capability) TermsText() string
- func (c Capability) Title() string
- type Entry
- type Section
- type Term
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAnchors ¶
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 ¶
AnchorText is an anchor as the meta line writes it: "#12", a commit, or "from <path>".
func Anchors ¶
Anchors is the heading anchors of a kind file holding es under the title title, with its title's and its sections'.
func Clash ¶
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 Taken ¶
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 ¶
func Union(a, b recovering.Footprint) recovering.Footprint
Union is footprint a with every file of b it lacks, in order.
Types ¶
type Area ¶
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.
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) Rest ¶
Rest is the meta line's segments after the slug that hold no anchor: the person and the date, which code never changes.
type Section ¶
Section is one "## " section of a capability's text: its line, the lines before its first entry, and its entries.