UNPKG

3.41 kBJavaScriptView Raw
1/**
2 * Indicates the type of {@link DocNode}.
3 *
4 * @remarks
5 * When creating custom subclasses of `DocNode`, it's recommended to create your own const enum to identify them.
6 * To avoid naming conflicts between projects, the enum value should be a string comprised of your full
7 * NPM package name, followed by a "#" symbol, followed by the class name (without the "Doc" prefix).
8 */
9export var DocNodeKind;
10(function (DocNodeKind) {
11 DocNodeKind["Block"] = "Block";
12 DocNodeKind["BlockTag"] = "BlockTag";
13 DocNodeKind["Excerpt"] = "Excerpt";
14 DocNodeKind["FencedCode"] = "FencedCode";
15 DocNodeKind["CodeSpan"] = "CodeSpan";
16 DocNodeKind["Comment"] = "Comment";
17 DocNodeKind["DeclarationReference"] = "DeclarationReference";
18 DocNodeKind["ErrorText"] = "ErrorText";
19 DocNodeKind["EscapedText"] = "EscapedText";
20 DocNodeKind["HtmlAttribute"] = "HtmlAttribute";
21 DocNodeKind["HtmlEndTag"] = "HtmlEndTag";
22 DocNodeKind["HtmlStartTag"] = "HtmlStartTag";
23 DocNodeKind["InheritDocTag"] = "InheritDocTag";
24 DocNodeKind["InlineTag"] = "InlineTag";
25 DocNodeKind["LinkTag"] = "LinkTag";
26 DocNodeKind["MemberIdentifier"] = "MemberIdentifier";
27 DocNodeKind["MemberReference"] = "MemberReference";
28 DocNodeKind["MemberSelector"] = "MemberSelector";
29 DocNodeKind["MemberSymbol"] = "MemberSymbol";
30 DocNodeKind["Paragraph"] = "Paragraph";
31 DocNodeKind["ParamBlock"] = "ParamBlock";
32 DocNodeKind["ParamCollection"] = "ParamCollection";
33 DocNodeKind["PlainText"] = "PlainText";
34 DocNodeKind["Section"] = "Section";
35 DocNodeKind["SoftBreak"] = "SoftBreak";
36})(DocNodeKind || (DocNodeKind = {}));
37/**
38 * The base class for the parser's Abstract Syntax Tree nodes.
39 */
40var DocNode = /** @class */ (function () {
41 function DocNode(parameters) {
42 this.configuration = parameters.configuration;
43 }
44 /**
45 * Returns the list of child nodes for this node. This is useful for visitors that want
46 * to scan the tree looking for nodes of a specific type, without having to process
47 * intermediary nodes.
48 */
49 DocNode.prototype.getChildNodes = function () {
50 // Do this sanity check here, since the constructor cannot access abstract members
51 this.configuration.docNodeManager.throwIfNotRegisteredKind(this.kind);
52 return this.onGetChildNodes().filter(function (x) { return x !== undefined; });
53 };
54 /**
55 * Overridden by child classes to implement {@link DocNode.getChildNodes}.
56 * @virtual
57 */
58 DocNode.prototype.onGetChildNodes = function () {
59 return [];
60 };
61 /**
62 * A type guard that returns true if the input uses the `IDocNodeParsedParameters` (parser scenario).
63 *
64 * @remarks
65 * There are two scenarios for constructing `DocNode` objects. The "builder scenario" constructs the object based on
66 * literal strings, does NOT create DocExcerpt child nodes, and generally uses the {@link IDocNodeParameters}
67 * hierarchy for its constructor parameters. The "parser scenario" constructs the object by parsing a TypeScript
68 * source file, does create DocExcerpt child nodes, and generally uses the {@link IDocNodeParsedParameters} hierarchy.
69 */
70 DocNode.isParsedParameters = function (parameters) {
71 return parameters.parsed === true;
72 };
73 return DocNode;
74}());
75export { DocNode };
76//# sourceMappingURL=DocNode.js.map
\No newline at end of file