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 ¶
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 ¶
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 ¶
Documented reports whether the element has representations of its own or inherited ones; other nodes are empty ancestor pages (PG-6).
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 ¶
Build computes the page tree of m:
- query the textual representations; the owners of the AsciiDoc ones are documented (others are skipped with a warning, PG-4);
- query the usages and definitions, and keep those that inherit an AsciiDoc representation (PG-7);
- keep every owner of a documented element up to the top of the model (PG-6), and nothing else (PT-4);
- lay the kept elements out as the model's containment tree, in declaration order, and give each a folder (PT-1, PT-6).