Documentation
¶
Index ¶
- func FormatValue(def Definition, value Value) string
- func JSONValue(def Definition, value Value) any
- func LookupDoc(query string) (string, error)
- func SortRows(rows []Row, by Definition, order Order)
- func SplitList(raw string) []string
- type Definition
- type DocInfo
- type Document
- type Order
- type Row
- type Scope
- type Value
- type ValueKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatValue ¶
func FormatValue(def Definition, value Value) string
FormatValue renders a metric value for text output.
func JSONValue ¶
func JSONValue(def Definition, value Value) any
JSONValue converts a metric value into a JSON-safe scalar. Unavailable values return nil.
func SortRows ¶
func SortRows(rows []Row, by Definition, order Order)
SortRows sorts rows deterministically by a metric and path tiebreaker.
Types ¶
type Definition ¶
type Definition struct {
ID string
Name string
Description string
Scope Scope
Kind ValueKind
Precision int
Default bool
DefaultOrder Order
Compute func(doc *Document) (Value, error)
}
Definition describes a metric and how to compute it.
func Defaults ¶
func Defaults(scope Scope) []Definition
Defaults returns default-selected metrics for a scope.
func ForScope ¶
func ForScope(scope Scope) []Definition
ForScope returns all metrics for a scope, sorted by ID.
func Lookup ¶
func Lookup(query string) (Definition, bool)
Lookup searches by metric ID (case-insensitive) or by name.
func LookupScope ¶
func LookupScope(scope Scope, query string) (Definition, bool)
LookupScope searches by metric ID (case-insensitive) or name within scope.
type Document ¶
Document is the shared metric input for a single Markdown file. Expensive derived values are computed lazily and cached.
func NewDocument ¶
NewDocument constructs a Document wrapper for metric computation.
func (*Document) HeadingCount ¶
HeadingCount returns number of heading nodes.
type Order ¶
type Order string
Order defines metric sort order.
func ParseOrder ¶
ParseOrder parses a user-provided sort order.
type Row ¶
Row holds computed metric values for a single file.
type Scope ¶
type Scope string
Scope defines the entity level a metric applies to.
const ( // ScopeFile indicates a file-level metric. ScopeFile Scope = "file" )
func ParseScope ¶
ParseScope parses a user-provided scope value.
type Value ¶
Value is a computed numeric metric value.
func AvailableValue ¶
AvailableValue constructs an available metric value.
func UnavailableValue ¶
func UnavailableValue() Value
UnavailableValue constructs an unavailable metric value.