document

package
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clip

func Clip(s string, n int) string

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

func CyclePeriod(words string) int

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

func Number(v any) (float64, bool)

Number reads a JSON or YAML value as a number, whichever numeric type its decoder gave it.

func ReadMonth

func ReadMonth(s string) (string, bool)

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

func Slug(s string) string

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

func WorkstreamNames(sections []Section) []string

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

type RegisterRow struct {
	Code  string
	Cells map[string]string
}

RegisterRow is one row: its code and its cells by header.

func ReadList added in v2.11.0

func ReadList(text, header, prefix string) []RegisterRow

ReadList reads a section written as a list rather than a table: each item, its wrapped lines joined, is a row whose one cell is under header, coded by its place (R1, R2, ...), so a register written as bullets ports as one written as columns does.

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.

func Split

func Split(title, text string) []Section

Split splits a document into sections at its headings. A heading with nothing under it (a contents line) is folded into the section before it.

Jump to

Keyboard shortcuts

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