dvStudioDocumentFromStructure function
The page document a captured structure describes.
tree is a list of nodes, each {role, level, label, href, src, children} -- the shape the build's semantics capture writes and
dvStudioStructureOf reads off a rendered page. Headings become text at
their level's size, links text that navigates, buttons buttons, images
images, and a node with children a column of them. Structure with no
words of its own is flattened away: a column of one column is one column.
Implementation
DVPageDocument dvStudioDocumentFromStructure(
String route,
Object? tree, {
String? title,
}) {
final DVPageNode root = DVPageNode(
type: 'box',
properties: <String, Object?>{'padding': 32, 'spacing': 16},
);
if (tree is List) {
for (final Object? node in tree) {
root.children.addAll(_nodesOf(node));
}
}
return DVPageDocument(
route: route,
title: title ?? _titleOf(tree) ?? route,
root: root,
);
}