Defined in: packages/megadoc-corpus/lib/Corpus.js
The Corpus public API.
Add a namespace or a document to the corpus. The corpus will be populated with all offspring nodes (if applicable).
Items added to the corpus will gain a UID and will be indexed.
node | T.Namespace|T.Node |
Example
corpus.add(b.namespace({
id: 'JS',
documents: [
b.document({
id: 'jQuery'
})
]
}))Retrieve a document AST node by its UID.
uid | String |
T.Namespace|T.NodeThe document AST node, if found. |
Resolve a link to a document.
Define an alias for a document.
uid | StringThe UID of the node to alias. |
alias | StringThe alias to use (should be fully-qualified.) |
Serialize the Corpus to a flat JSON map with no circular dependencies.
ObjectAn object that can be safely serialized to disk. |
Install a Node visitor that will be called any time a node of the specified type is added to the corpus.
visitor | ObjectA map of node types as keys and functions as values. |
node | T.Namespace|T.Node |
Example
corpus.visit({
Document: function(node) {
if (node.filePath.match(/foo.js/)) {
node.meta.isFoo = true;
}
}
});Unknown tag:
{
"type": "callback",
"string": "",
"typeInfo": {
"name": null,
"description": null,
"isOptional": null,
"defaultValue": null,
"type": null
},
"line": 150
}Made with ♥ using megadoc.