okfschema

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 2 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 okfschema is the field-type registry an editor consults to know how a frontmatter key may be edited: which keys are closed enumerations, which hold tag lists, and which the indexer owns and a human must not retype. It is pure data with no store or UI dependency, so other surfaces (a future validate check) can reuse the same definitions.

Index

Constants

View Source
const SupersededByKey = "superseded_by"

SupersededByKey is the frontmatter key naming the document that replaces this one. It is a uri relative to the kb root, the same address space as a link target, and is free text rather than an enum: the set of valid values is every document in the tree (ADR-0010).

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldKind

type FieldKind int

FieldKind is how an editor presents a frontmatter field.

const (
	// KindText is a free-form single-line scalar.
	KindText FieldKind = iota
	// KindEnum is a scalar restricted to FieldSchema.Enum.
	KindEnum
	// KindTags is a list of strings, retyped as a whole.
	KindTags
	// KindReadOnly is a field the index or the pipeline owns; it is displayed
	// but never edited.
	KindReadOnly
)

type FieldSchema

type FieldSchema struct {
	Key  string
	Kind FieldKind
	Enum []string
}

FieldSchema describes one frontmatter key. Enum is populated only for KindEnum.

func FieldSchemaFor

func FieldSchemaFor(docType, key string) FieldSchema

FieldSchemaFor returns how key should be edited on a document of docType. An unknown type or an unlisted key falls back on the key alone: tag lists for "tags", read-only for the system keys, free text otherwise — so an editor always has a usable answer and never rejects an unknown OKF type.

func (FieldSchema) Cycle

func (f FieldSchema) Cycle(current string, delta int) string

Cycle returns the enum value delta steps from current, wrapping around. A current value outside the enum (or a non-enum field) resolves to the first value, so an editor can always offer a valid choice.

type TypeSchema

type TypeSchema struct {
	Fields []FieldSchema
}

TypeSchema is the set of known fields for one OKF document type.

Jump to

Keyboard shortcuts

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