UNPKG

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