Documentation
¶
Index ¶
- Variables
- type Metrics
- type Node
- func (n *Node) AddSub(p Provider, name string) (*Node, error)
- func (n *Node) ChildNodes(p Provider) ([]*Node, error)
- func (n *Node) FillID() (uuid.UUID, error)
- func (n *Node) GetLeafs(r Reader) ([]*Node, error)
- func (n *Node) GetTemplate(p Provider) (*NodeTemplate, error)
- func (n *Node) Metrics(p Provider) (*Metrics, error)
- func (n *Node) Name() string
- func (n *Node) Parent(p Provider) (*Node, error)
- func (n *Node) Template(p Provider, rawName string) (*NodeTemplate, *TemplateData, error)
- func (n *Node) Walk(r Reader, ...) error
- type NodeHeader
- type NodeTemplate
- type Provider
- type RawTemplateData
- type Reader
- type RootsProvider
- type TemplateData
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNodeNotFound is returned when a node is not found. ErrNodeNotFound = errors.New("node not found") // ErrPartialTemplate is returned when root node template is missing or // partial. ErrPartialTemplate = errors.New("partial or missing template") )
var ( // RootNodeID is empty UUDI, filled with zeros, id of the root node. RootNodeID = uuid.Nil //nolint:gochecknoglobals // constant. // RootNodePath is empty path, root node path. RootNodePath = pathutil.NodePath("") //nolint:gochecknoglobals // constant. )
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
type Metrics struct {
Nodes int `json:"nodes"`
FinalNodes int `json:"finalNodes"`
Depth metric `json:"depth"`
Leafs metric `json:"leafs"`
}
Metrics groups all nodes metrics.
type Node ¶
type Node struct {
Path pathutil.NodePath `json:"path"`
Header NodeHeader `json:"header"`
Content string `json:"content"`
}
Node describes a single node.
func (*Node) ChildNodes ¶
ChildNodes returns all child nodes of node.
func (*Node) GetTemplate ¶
func (n *Node) GetTemplate(p Provider) (*NodeTemplate, error)
GetTemplate returns the first template encountered when walking up the tree.
func (*Node) Name ¶
Name returns the name of a node. That being either the defined name in node header or first element of nodes path.
func (*Node) Template ¶
func (n *Node) Template( p Provider, rawName string, ) (*NodeTemplate, *TemplateData, error)
Template prepares n nodes template. Walking up the graph tree to find a base template and setting template data to be used to fill template fields.
type NodeHeader ¶
type NodeHeader struct {
ID uuid.UUID `yaml:"id"`
DisplayName string `yaml:"displayName,omitempty"`
Weight int `yaml:"weight,omitempty"`
Template *NodeTemplate `yaml:"template,omitempty"`
Any map[string]any `yaml:",inline"`
}
NodeHeader describes info stored in nodes header.
type NodeTemplate ¶
type NodeTemplate struct {
DisplayName string `yaml:"displayName,omitempty"`
PathName string `yaml:"pathName,omitempty"`
Weight string `yaml:"weight,omitempty"`
Content string `yaml:"content,omitempty"`
Template *NodeTemplate `yaml:"template,omitempty"`
}
NodeTemplate describes a template data of a node.
func (*NodeTemplate) FillContent ¶
func (nt *NodeTemplate) FillContent(td *TemplateData) (string, error)
FillContent fills templated node content.
func (*NodeTemplate) FillNames ¶
func (nt *NodeTemplate) FillNames(td *RawTemplateData) (string, string, error)
FillNames returns templated nodes display name and path name.
func (*NodeTemplate) FillWeight ¶
func (nt *NodeTemplate) FillWeight(td *TemplateData) (int, error)
FillWeight fills templated node weight.
type RawTemplateData ¶
type RawTemplateData struct {
RawName string // name that user provided.
Day int // day of the month 1,2,..31
Month int // month of the year 1,2,3...12
MonthName string // month name in English
Year int
Week int // week number of the year
Weekday int // number of the weekday 1,2...7
WeekdayName string // monday (1), tuesday(2)...sunday
YearDay int // day of the year 1,2,...365
// next ++ increment of weight of largest sibling node
WeightAutoincrement int
Smile string // random gyph smile
}
RawTemplateData describes the template fields available to unprocessed template fillers, like FillName.
type Reader ¶
type Reader interface {
GetByID(id uuid.UUID) (*Node, error)
GetByPath(path pathutil.NodePath) (*Node, error)
GetLeafs(path pathutil.NodePath) ([]*Node, error)
}
Reader describes graph read operations.
type RootsProvider ¶
RootsProvider describes a provider implementation with an additional Roots method that can retrieve root nodes separately.
type TemplateData ¶
type TemplateData struct {
RawTemplateData
// fields populated when template is executed.
DisplayName string
PathName string
}
TemplateData describes data that can be used in node templates.