document

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 5 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 document reads a file as a document (GLOSSARY.md): its type, title, tags and date, and the document rules it breaks. read and write both see documents through it, so they agree on what a document says.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Doc

type Doc struct {
	Frontmatter *vault.Frontmatter
	Type        string // "" for a plain file, which no rule applies to
	Title       string // the title field
	Tags        []string
	DateField   string    // the type's date field, or date for a type not configured
	Date        time.Time // zero when DateField has no value or holds no date
	Findings    []Finding // in rule order: type, required, date, tag
}

Doc is a file with frontmatter, read as a document.

func Parse

func Parse(src []byte, cfg *config.Config, voc *vault.Vocabulary) (*Doc, error)

Parse reads src as a document. It returns nil, nil for a file without frontmatter, and the *vault.FrontmatterError for frontmatter that does not parse. A nil vocabulary skips the tag rule.

func Read

func Read(fm *vault.Frontmatter, cfg *config.Config, voc *vault.Vocabulary) *Doc

Read reads parsed frontmatter as a document. A nil vocabulary skips the tag rule.

type Finding

type Finding struct {
	Rule   Rule
	Key    Key
	Reason string
}

Finding is a document rule a document breaks. Reason says what is wrong; the caller adds what to do next.

func (Finding) Same

func (f Finding) Same(o Finding) bool

Same reports whether f and o are the same finding: the same rule, broken about the same key, whatever the reason says.

type Key

type Key struct{ Type, Field, Value string }

Key is what a Finding is about, as far as its rule tells findings apart: the type for RuleType; the type and field for RuleRequired; the type, field and value for RuleDate; and the tag, as Value, for RuleTag. So a changed type makes its required and date findings new, and an old bad tag stays the same finding.

type Rule

type Rule string

Rule is a document rule a Finding is about. "The frontmatter parses" is not one: Parse fails instead.

const (
	RuleType     Rule = "type"     // the type is configured
	RuleRequired Rule = "required" // the type's required fields have values
	RuleDate     Rule = "date"     // the date field holds a date
	RuleTag      Rule = "tag"      // the tags are in the vocabulary
)

Jump to

Keyboard shortcuts

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