tree

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 6 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 tree decides which elements of a model get pages, what each page shows, and where it is written (requirements PG-1..7, PT-1..6). It finds them by querying the model for its textual representations, then grows the tree from their owners: the elements that inherit them, and the owners of both up to the top of the model (DS-4).

Index

Constants

View Source
const UnnamedName = "Unnamed"

UnnamedName stands in for the name of an element without one, wherever its name is shown, page title included (PG-5).

Variables

This section is empty.

Functions

func Href

func Href(from, to *Node) string

Href is a relative link from the page at from to the page of to, each folder name escaped, so the site works from file:// as from a server.

Types

type Node

type Node struct {
	ID string // element id; empty for the root
	// Name is the element's name, UnnamedName, or empty for the root. It is
	// not the page title, which is decided when the page is rendered (PG-8).
	Name string
	// Unnamed is set when the element has no name (PG-5, PT-6).
	Unnamed bool
	// QualifiedName identifies the element in messages and to the
	// evaluator: its qualified name, or its positional name (M::@2) when it
	// has none.
	QualifiedName string
	// Dir is the page's folder relative to the site, slash-separated; empty
	// for the root. The page itself is Dir + "/index.html".
	Dir string
	// Own are the representations the element owns, in declaration order;
	// Inherited are those it inherits, nearest specialization first (PG-7).
	Own       []Rep
	Inherited []Rep
	Parent    *Node
	Children  []*Node
}

Node is one page of the site, or the site root.

func (*Node) Documented

func (n *Node) Documented() bool

Documented reports whether the element has representations of its own or inherited ones; other nodes are empty ancestor pages (PG-6).

type Rep

type Rep struct {
	ID    string
	Owner string // id of the element that owns it
	Body  string
}

Rep is an AsciiDoc textual representation.

type Tree

type Tree struct {
	// Model is the model the tree was built from, for macros that read
	// elements without pages.
	Model *model.Model
	Root  *Node
	// Pages are every node but the root, in pre-order.
	Pages []*Node
	// ByID finds a page by element id.
	ByID map[string]*Node
	// Warnings are skipped representations (PG-4) and unnamed pages (PG-5).
	Warnings []string
}

Tree is the page tree of a model.

func Build

func Build(ctx context.Context, m *model.Model) (*Tree, error)

Build computes the page tree of m:

  1. query the textual representations; the owners of the AsciiDoc ones are documented (others are skipped with a warning, PG-4);
  2. query the usages and definitions, and keep those that inherit an AsciiDoc representation (PG-7);
  3. keep every owner of a documented element up to the top of the model (PG-6), and nothing else (PT-4);
  4. lay the kept elements out as the model's containment tree, in declaration order, and give each a folder (PT-1, PT-6).

func (*Tree) Href

func (t *Tree) Href(from, to string) (href string, ok bool)

Href is the link, relative to the page of element from, to the page of element to, both by id; ok is false when either has no page. It makes the tree the macros' Pages (macros.Pages).

Jump to

Keyboard shortcuts

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