UNPKG

4.48 kBTypeScriptView Raw
1import { TSDocConfiguration } from '../configuration/TSDocConfiguration';
2/**
3 * Indicates the type of {@link DocNode}.
4 *
5 * @remarks
6 * When creating custom subclasses of `DocNode`, it's recommended to create your own const enum to identify them.
7 * To avoid naming conflicts between projects, the enum value should be a string comprised of your full
8 * NPM package name, followed by a "#" symbol, followed by the class name (without the "Doc" prefix).
9 */
10export declare enum DocNodeKind {
11 Block = "Block",
12 BlockTag = "BlockTag",
13 Excerpt = "Excerpt",
14 FencedCode = "FencedCode",
15 CodeSpan = "CodeSpan",
16 Comment = "Comment",
17 DeclarationReference = "DeclarationReference",
18 ErrorText = "ErrorText",
19 EscapedText = "EscapedText",
20 HtmlAttribute = "HtmlAttribute",
21 HtmlEndTag = "HtmlEndTag",
22 HtmlStartTag = "HtmlStartTag",
23 InheritDocTag = "InheritDocTag",
24 InlineTag = "InlineTag",
25 LinkTag = "LinkTag",
26 MemberIdentifier = "MemberIdentifier",
27 MemberReference = "MemberReference",
28 MemberSelector = "MemberSelector",
29 MemberSymbol = "MemberSymbol",
30 Paragraph = "Paragraph",
31 ParamBlock = "ParamBlock",
32 ParamCollection = "ParamCollection",
33 PlainText = "PlainText",
34 Section = "Section",
35 SoftBreak = "SoftBreak"
36}
37/**
38 * Constructor parameters for {@link DocNode}.
39 *
40 * @remarks
41 * There are two scenarios for constructing `DocNode` objects. The "builder scenario" constructs the object based on
42 * literal strings, does NOT create DocExcerpt child nodes, and generally uses the `IDocNodeParameters`
43 * hierarchy for its constructor parameters. The "parser scenario" constructs the object by parsing a TypeScript
44 * source file, does create DocExcerpt child nodes, and generally uses the {@link IDocNodeParsedParameters} hierarchy.
45 */
46export interface IDocNodeParameters {
47 configuration: TSDocConfiguration;
48}
49/**
50 * Constructor parameters for {@link DocNode}.
51 *
52 * @remarks
53 * There are two scenarios for constructing `DocNode` objects. The "builder scenario" constructs the object based on
54 * literal strings, does NOT create DocExcerpt child nodes, and generally uses the {@link IDocNodeParameters}
55 * hierarchy for its constructor parameters. The "parser scenario" constructs the object by parsing a TypeScript
56 * source file, does create DocExcerpt child nodes, and generally uses the `IDocNodeParsedParameters` hierarchy.
57 */
58export interface IDocNodeParsedParameters {
59 configuration: TSDocConfiguration;
60 /**
61 * This is a marker used by {@link DocNode.isParsedParameters} to determine whether the constructor was
62 * invoked using `IDocNodeParameters` (builder scenario) or `IDocNodeParsedParameters` (parser scenario).
63 */
64 parsed: true;
65}
66/**
67 * The base class for the parser's Abstract Syntax Tree nodes.
68 */
69export declare abstract class DocNode {
70 readonly configuration: TSDocConfiguration;
71 constructor(parameters: IDocNodeParameters | IDocNodeParsedParameters);
72 /**
73 * Returns a text string that uniquely identifies the child class type. This is used for example by
74 * switch statements to efficiently determine the kind of node.
75 */
76 abstract get kind(): DocNodeKind | string;
77 /**
78 * Returns the list of child nodes for this node. This is useful for visitors that want
79 * to scan the tree looking for nodes of a specific type, without having to process
80 * intermediary nodes.
81 */
82 getChildNodes(): ReadonlyArray<DocNode>;
83 /**
84 * Overridden by child classes to implement {@link DocNode.getChildNodes}.
85 * @virtual
86 */
87 protected onGetChildNodes(): ReadonlyArray<DocNode | undefined>;
88 /**
89 * A type guard that returns true if the input uses the `IDocNodeParsedParameters` (parser scenario).
90 *
91 * @remarks
92 * There are two scenarios for constructing `DocNode` objects. The "builder scenario" constructs the object based on
93 * literal strings, does NOT create DocExcerpt child nodes, and generally uses the {@link IDocNodeParameters}
94 * hierarchy for its constructor parameters. The "parser scenario" constructs the object by parsing a TypeScript
95 * source file, does create DocExcerpt child nodes, and generally uses the {@link IDocNodeParsedParameters} hierarchy.
96 */
97 static isParsedParameters(parameters: IDocNodeParameters | IDocNodeParsedParameters): parameters is IDocNodeParsedParameters;
98}
99//# sourceMappingURL=DocNode.d.ts.map
\No newline at end of file