Documentation
¶
Overview ¶
Package document reads a document's text: its sections, by their headings, and the registers its tables hold. It is pure: it knows no store, no port and no kind, only text.
Index ¶
- func Clip(s string, n int) string
- func CyclePeriod(words string) int
- func Number(v any) (float64, bool)
- func ReadMonth(s string) (string, bool)
- func RegisterItems(field string, rows []RegisterRow) []map[string]any
- func Slug(s string) string
- func WorkstreamNames(sections []Section) []string
- type RegisterRow
- type Section
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clip ¶
Clip shortens text to n characters at the latest boundary that keeps at least half of it: the end of a sentence, else of a clause, else of a word; never mid-phrase where a boundary will do. A clause's trailing joining word ("and", "of") goes with it.
func CyclePeriod ¶
CyclePeriod is the length in months of a cycle a register names in words, or 0 when the words name no equal period (termly, once).
func Number ¶
Number reads a JSON or YAML value as a number, whichever numeric type its decoder gave it.
func ReadMonth ¶
ReadMonth reads a date as its month, YYYY-MM: from YYYY-MM, YYYY-MM-DD, or DD/MM/YYYY.
func RegisterItems ¶
func RegisterItems(field string, rows []RegisterRow) []map[string]any
RegisterItems maps a register's rows onto a list field of a project, in the field's own shape: milestones, deliverables, risks or the KPIs it names. What a row does not give is left out, for the checks to ask.
The server's porting map is applied to the rows as they are read, so a port comes out the same whoever runs it: a milestone already completed is not ported unless one still to come waits on it, and a measure taken once is not an indicator. Such a row is returned with _skip, its reason.
func Slug ¶
Slug reduces free text to the Slug pattern: lowercase, every run of anything else a single hyphen, trimmed, and short enough to read. It matches the interface's own slug helper so an id generated on either side of the wire comes out the same.
func WorkstreamNames ¶
WorkstreamNames are the names a document's workstream plan gives its workstreams: in a section headed as workstreams, the text that follows a workstream's code on its line (WS5 Monitoring, Data and ...).
Types ¶
type RegisterRow ¶
RegisterRow is one row: its code and its cells by header.
func ReadRegister ¶
func ReadRegister(text string) []RegisterRow
ReadRegister reads the rows of the tables in a section's text.
type Section ¶
type Section struct {
ID string `json:"id"`
Heading string `json:"heading"`
Words int `json:"words"`
// Feeds are the fields it most likely answers, as JSON pointers on a
// project, or "pieces" for the parts that name pieces of work.
Feeds []string `json:"feeds,omitempty"`
// Text is the section's words, kept apart from what it is listed
// with.
Text string `json:"-"`
}
Section is one section of a brought document.