Tree Class

Summary

Adds metadata to the input documents that describes the position of each one in a tree structure.
Assembly
Wyam.Core.dll
Namespace
Wyam.Core.Modules.Metadata
Interfaces
Base Types
  • Object
graph BT Type-->Base0["Object"] Type-.->Interface0["IModule"] click Interface0 "/api/Wyam.Common.Modules/IModule" Type["Tree"] class Type type-node

Syntax

public class Tree : IModule

Remarks

By default, this module is configured to generate a tree that mimics the directory structure of each document's input path by looking at it's RelativeFilePath metadata value. Any documents with a file name of "index.*" are automatically promoted to the node that represents the parent folder level. For any folder that does not contain an "index.*" file, an empty placeholder tree node is used to represent the folder.

Note that if you clone documents from the tree, the relationships of the cloned document (parent, child, etc.) will not be updated to the new clones. In other words, your new document will still be pointing to the old versions of it's parent, children, etc. To update the tree after cloning documents you will need to recreate it by rerunning this module on all the newly created documents again.

Constructors

Name Summary
Tree() Creates a new tree module.

Methods

Name Value Summary
Execute(IReadOnlyList<IDocument>, IExecutionContext) IEnumerable<IDocument>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
WithMetadataNames(string, string, string, string, string, string, string) Tree
Changes the default metadata keys.
WithNesting(bool, bool) Tree
Indicates that the module should only output root nodes (instead of all nodes which is the default behavior).
WithPlaceholderFactory(Func<Object[], MetadataItems, IExecutionContext, IDocument>) Tree
Allows you to specify a factory function for the creation of placeholder documents which get created to represent nodes in the tree for which there was no input document. The factory gets passed the current tree path, the set of tree metadata that should be set in the document, and the execution context which can be used to create a new document. If the factory function returns null, a new document with the tree metadata is created.
WithRoots(DocumentConfig) Tree
Specifies for each document if it is a root of a tree. This results in splitting the generated tree into multiple smaller ones, removing the root node from the set of children of it's parent and setting it's parent to null.
WithSort(Comparison<IDocument>) Tree
This specifies how the children of a given tree node should be sorted. The default behavior is to sort based on the string value of the last component of the child node's tree path (I.e., the folder or file name). The output document for each tree node is used as the input to the sort delegate.
WithTreePath(DocumentConfig) Tree
Defines the structure of the tree. If the delegate returns null the document is excluded from the tree.
GitHub