Initial commit

This commit is contained in:
yuding
2025-12-03 12:00:46 +08:00
commit 5763b764a3
5365 changed files with 1483113 additions and 0 deletions

View File

@@ -0,0 +1,200 @@
/**
* Represents a reference to a declaration.
* @beta
*/
export declare class DeclarationReference {
private _source;
private _navigation;
private _symbol;
constructor(source?: ModuleSource | GlobalSource, navigation?: Navigation.Locals | Navigation.Exports, symbol?: SymbolReference);
get source(): ModuleSource | GlobalSource | undefined;
get navigation(): Navigation.Locals | Navigation.Exports | undefined;
get symbol(): SymbolReference | undefined;
get isEmpty(): boolean;
static parse(text: string): DeclarationReference;
static parseComponent(text: string): Component;
/**
* Determines whether the provided string is a well-formed symbol navigation component string.
*/
static isWellFormedComponentString(text: string): boolean;
/**
* Escapes a string for use as a symbol navigation component. If the string contains any of `!.#~:,"{}()@` or starts
* with `[`, it is enclosed in quotes.
*/
static escapeComponentString(text: string): string;
/**
* Unescapes a string used as a symbol navigation component.
*/
static unescapeComponentString(text: string): string;
/**
* Determines whether the provided string is a well-formed module source string. The string may not
* have a trailing `!` character.
*/
static isWellFormedModuleSourceString(text: string): boolean;
/**
* Escapes a string for use as a module source. If the string contains any of `!"` it is enclosed in quotes.
*/
static escapeModuleSourceString(text: string): string;
/**
* Unescapes a string used as a module source. The string may not have a trailing `!` character.
*/
static unescapeModuleSourceString(text: string): string;
static empty(): DeclarationReference;
static package(packageName: string, importPath?: string): DeclarationReference;
static module(path: string, userEscaped?: boolean): DeclarationReference;
static global(): DeclarationReference;
static from(base: DeclarationReference | undefined): DeclarationReference;
withSource(source: ModuleSource | GlobalSource | undefined): DeclarationReference;
withNavigation(navigation: Navigation.Locals | Navigation.Exports | undefined): DeclarationReference;
withSymbol(symbol: SymbolReference | undefined): DeclarationReference;
withComponentPath(componentPath: ComponentPath): DeclarationReference;
withMeaning(meaning: Meaning | undefined): DeclarationReference;
withOverloadIndex(overloadIndex: number | undefined): DeclarationReference;
addNavigationStep(navigation: Navigation, component: ComponentLike): DeclarationReference;
toString(): string;
}
/**
* Indicates the symbol table from which to resolve the next symbol component.
* @beta
*/
export declare enum Navigation {
Exports = ".",
Members = "#",
Locals = "~"
}
/**
* Represents a module.
* @beta
*/
export declare class ModuleSource {
readonly escapedPath: string;
private _path;
private _pathComponents;
constructor(path: string, userEscaped?: boolean);
get path(): string;
get packageName(): string;
get scopeName(): string;
get unscopedPackageName(): string;
get importPath(): string;
static fromScopedPackage(scopeName: string | undefined, unscopedPackageName: string, importPath?: string): ModuleSource;
static fromPackage(packageName: string, importPath?: string): ModuleSource;
private static _fromPackageName;
toString(): string;
private _getOrParsePathComponents;
}
/**
* Represents the global scope.
* @beta
*/
export declare class GlobalSource {
static readonly instance: GlobalSource;
private constructor();
toString(): string;
}
/**
* @beta
*/
export type Component = ComponentString | ComponentReference;
/**
* @beta
*/
export declare namespace Component {
function from(value: ComponentLike): Component;
}
/**
* @beta
*/
export type ComponentLike = Component | DeclarationReference | string;
/**
* @beta
*/
export declare class ComponentString {
readonly text: string;
constructor(text: string, userEscaped?: boolean);
toString(): string;
}
/**
* @beta
*/
export declare class ComponentReference {
readonly reference: DeclarationReference;
constructor(reference: DeclarationReference);
static parse(text: string): ComponentReference;
withReference(reference: DeclarationReference): ComponentReference;
toString(): string;
}
/**
* @beta
*/
export type ComponentPath = ComponentRoot | ComponentNavigation;
/**
* @beta
*/
export declare abstract class ComponentPathBase {
readonly component: Component;
constructor(component: Component);
addNavigationStep(this: ComponentPath, navigation: Navigation, component: ComponentLike): ComponentPath;
abstract toString(): string;
}
/**
* @beta
*/
export declare class ComponentRoot extends ComponentPathBase {
withComponent(component: ComponentLike): ComponentRoot;
toString(): string;
}
/**
* @beta
*/
export declare class ComponentNavigation extends ComponentPathBase {
readonly parent: ComponentPath;
readonly navigation: Navigation;
constructor(parent: ComponentPath, navigation: Navigation, component: Component);
withParent(parent: ComponentPath): ComponentNavigation;
withNavigation(navigation: Navigation): ComponentNavigation;
withComponent(component: ComponentLike): ComponentNavigation;
toString(): string;
}
/**
* @beta
*/
export declare enum Meaning {
Class = "class",// SymbolFlags.Class
Interface = "interface",// SymbolFlags.Interface
TypeAlias = "type",// SymbolFlags.TypeAlias
Enum = "enum",// SymbolFlags.Enum
Namespace = "namespace",// SymbolFlags.Module
Function = "function",// SymbolFlags.Function
Variable = "var",// SymbolFlags.Variable
Constructor = "constructor",// SymbolFlags.Constructor
Member = "member",// SymbolFlags.ClassMember | SymbolFlags.EnumMember
Event = "event",//
CallSignature = "call",// SymbolFlags.Signature (for __call)
ConstructSignature = "new",// SymbolFlags.Signature (for __new)
IndexSignature = "index",// SymbolFlags.Signature (for __index)
ComplexType = "complex"
}
/**
* @beta
*/
export interface ISymbolReferenceOptions {
meaning?: Meaning;
overloadIndex?: number;
}
/**
* Represents a reference to a TypeScript symbol.
* @beta
*/
export declare class SymbolReference {
readonly componentPath: ComponentPath | undefined;
readonly meaning: Meaning | undefined;
readonly overloadIndex: number | undefined;
constructor(component: ComponentPath | undefined, { meaning, overloadIndex }?: ISymbolReferenceOptions);
static empty(): SymbolReference;
withComponentPath(componentPath: ComponentPath | undefined): SymbolReference;
withMeaning(meaning: Meaning | undefined): SymbolReference;
withOverloadIndex(overloadIndex: number | undefined): SymbolReference;
addNavigationStep(navigation: Navigation, component: ComponentLike): SymbolReference;
toString(): string;
}
//# sourceMappingURL=DeclarationReference.d.ts.map

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,98 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocNodeManager = void 0;
const StringChecks_1 = require("../parser/StringChecks");
/**
* Part of the {@link TSDocConfiguration} object.
*
* @remarks
* If you define your own custom subclasses of `DocNode`, they must be registered with the `DocNodeManager`.
* Use {@link DocNodeManager.registerAllowableChildren} to specify which {@link DocNodeContainer} subclasses
* are allowed to contain your nodes.
*/
class DocNodeManager {
constructor() {
this._docNodeDefinitionsByKind = new Map();
this._docNodeDefinitionsByConstructor = new Map();
}
/**
* Registers a list of {@link IDocNodeDefinition} objects to be used with the associated
* {@link TSDocConfiguration} object.
*/
registerDocNodes(packageName, definitions) {
const packageNameError = StringChecks_1.StringChecks.explainIfInvalidPackageName(packageName);
if (packageNameError) {
throw new Error('Invalid NPM package name: ' + packageNameError);
}
for (const definition of definitions) {
if (!DocNodeManager._nodeKindRegExp.test(definition.docNodeKind)) {
throw new Error(`The DocNode kind ${JSON.stringify(definition.docNodeKind)} is not a valid identifier.` +
` It must start with an underscore or letter, and be comprised of letters, numbers, and underscores`);
}
let existingDefinition = this._docNodeDefinitionsByKind.get(definition.docNodeKind);
if (existingDefinition !== undefined) {
throw new Error(`The DocNode kind "${definition.docNodeKind}" was already registered` +
` by ${existingDefinition.packageName}`);
}
existingDefinition = this._docNodeDefinitionsByConstructor.get(definition.constructor);
if (existingDefinition !== undefined) {
throw new Error(`This DocNode constructor was already registered by ${existingDefinition.packageName}` +
` as ${existingDefinition.docNodeKind}`);
}
const newDefinition = {
docNodeKind: definition.docNodeKind,
constructor: definition.constructor,
packageName,
allowedChildKinds: new Set()
};
this._docNodeDefinitionsByKind.set(definition.docNodeKind, newDefinition);
this._docNodeDefinitionsByConstructor.set(definition.constructor, newDefinition);
}
}
/**
* Reports an error if the specified DocNode kind has not been registered.
*/
throwIfNotRegisteredKind(docNodeKind) {
if (!this._docNodeDefinitionsByKind.has(docNodeKind)) {
throw new Error(`The DocNode kind "${docNodeKind}" was not registered with this TSDocConfiguration`);
}
}
/**
* For the given parent DocNode kind, registers the specified DocNode kinds as being allowable children of
* the parent.
*
* @remarks
* To prevent mistakes, `DocNodeContainer` will report an error if you try to add node that was not registered
* as an allowable child of the container.
*/
registerAllowableChildren(parentKind, childKinds) {
const parentDefinition = this._getDefinition(parentKind);
for (const childKind of childKinds) {
this._getDefinition(childKind);
parentDefinition.allowedChildKinds.add(childKind);
}
}
/**
* Returns true if the specified DocNode kind has been registered as an allowable child of the specified
* parent DocNode kind.
*/
isAllowedChild(parentKind, childKind) {
const parentDefinition = this._getDefinition(parentKind);
return parentDefinition.allowedChildKinds.has(childKind);
}
_getDefinition(docNodeKind) {
const definition = this._docNodeDefinitionsByKind.get(docNodeKind);
if (definition === undefined) {
throw new Error(`The DocNode kind "${docNodeKind}" was not registered with this TSDocConfiguration`);
}
return definition;
}
}
exports.DocNodeManager = DocNodeManager;
// Matches an ASCII TypeScript-style identifier.
//
// Example: "_myIdentifier99"
DocNodeManager._nodeKindRegExp = /^[_a-z][_a-z0-9]*$/i;
//# sourceMappingURL=DocNodeManager.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,223 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TSDocConfiguration = void 0;
const StandardTags_1 = require("../details/StandardTags");
const TSDocValidationConfiguration_1 = require("./TSDocValidationConfiguration");
const DocNodeManager_1 = require("./DocNodeManager");
const BuiltInDocNodes_1 = require("../nodes/BuiltInDocNodes");
const TSDocMessageId_1 = require("../parser/TSDocMessageId");
/**
* Configuration for the TSDocParser.
*/
class TSDocConfiguration {
constructor() {
this._tagDefinitions = [];
this._tagDefinitionsByName = new Map();
this._supportedTagDefinitions = new Set();
this._validation = new TSDocValidationConfiguration_1.TSDocValidationConfiguration();
this._docNodeManager = new DocNodeManager_1.DocNodeManager();
this._supportedHtmlElements = new Set();
this.clear(false);
// Register the built-in node kinds
BuiltInDocNodes_1.BuiltInDocNodes.register(this);
}
/**
* Resets the `TSDocConfiguration` object to its initial empty state.
* @param noStandardTags - The `TSDocConfiguration` constructor normally adds definitions for the
* standard TSDoc tags. Set `noStandardTags` to true for a completely empty `tagDefinitions` collection.
*/
clear(noStandardTags = false) {
this._tagDefinitions.length = 0;
this._tagDefinitionsByName.clear();
this._supportedTagDefinitions.clear();
this._validation.ignoreUndefinedTags = false;
this._validation.reportUnsupportedTags = false;
this._validation.reportUnsupportedHtmlElements = false;
this._supportedHtmlElements.clear();
if (!noStandardTags) {
// Define all the standard tags
this.addTagDefinitions(StandardTags_1.StandardTags.allDefinitions);
}
}
/**
* The TSDoc tags that are defined in this configuration.
*
* @remarks
* The subset of "supported" tags is tracked by {@link TSDocConfiguration.supportedTagDefinitions}.
*/
get tagDefinitions() {
return this._tagDefinitions;
}
/**
* Returns the subset of {@link TSDocConfiguration.tagDefinitions}
* that are supported in this configuration.
*
* @remarks
* This property is only used when
* {@link TSDocValidationConfiguration.reportUnsupportedTags} is enabled.
*/
get supportedTagDefinitions() {
return this.tagDefinitions.filter((x) => this.isTagSupported(x));
}
/**
* Enable/disable validation checks performed by the parser.
*/
get validation() {
return this._validation;
}
/**
* The HTML element names that are supported in this configuration. Used in conjunction with the `reportUnsupportedHtmlElements` setting.
*/
get supportedHtmlElements() {
return Array.from(this._supportedHtmlElements.values());
}
/**
* Register custom DocNode subclasses.
*/
get docNodeManager() {
return this._docNodeManager;
}
/**
* Return the tag that was defined with the specified name, or undefined
* if not found.
*/
tryGetTagDefinition(tagName) {
return this._tagDefinitionsByName.get(tagName.toUpperCase());
}
/**
* Return the tag that was defined with the specified name, or undefined
* if not found.
*/
tryGetTagDefinitionWithUpperCase(alreadyUpperCaseTagName) {
return this._tagDefinitionsByName.get(alreadyUpperCaseTagName);
}
/**
* Define a new TSDoc tag to be recognized by the TSDocParser, and mark it as unsupported.
* Use {@link TSDocConfiguration.setSupportForTag} to mark it as supported.
*
* @remarks
* If a tag is "defined" this means that the parser recognizes it and understands its syntax.
* Whereas if a tag is "supported", this means it is defined AND the application implements the tag.
*/
addTagDefinition(tagDefinition) {
const existingDefinition = this._tagDefinitionsByName.get(tagDefinition.tagNameWithUpperCase);
if (existingDefinition === tagDefinition) {
return;
}
if (existingDefinition) {
throw new Error(`A tag is already defined using the name ${existingDefinition.tagName}`);
}
this._tagDefinitions.push(tagDefinition);
this._tagDefinitionsByName.set(tagDefinition.tagNameWithUpperCase, tagDefinition);
}
/**
* Calls {@link TSDocConfiguration.addTagDefinition} for a list of definitions,
* and optionally marks them as supported.
* @param tagDefinitions - the definitions to be added
* @param supported - if specified, calls the {@link TSDocConfiguration.setSupportForTag}
* method to mark the definitions as supported or unsupported
*/
addTagDefinitions(tagDefinitions, supported) {
for (const tagDefinition of tagDefinitions) {
this.addTagDefinition(tagDefinition);
if (supported !== undefined) {
this.setSupportForTag(tagDefinition, supported);
}
}
}
/**
* Returns true if the tag is supported in this configuration.
*/
isTagSupported(tagDefinition) {
this._requireTagToBeDefined(tagDefinition);
return this._supportedTagDefinitions.has(tagDefinition);
}
/**
* Specifies whether the tag definition is supported in this configuration.
* The parser may issue warnings for unsupported tags.
*
* @remarks
* If a tag is "defined" this means that the parser recognizes it and understands its syntax.
* Whereas if a tag is "supported", this means it is defined AND the application implements the tag.
*
* This function automatically sets {@link TSDocValidationConfiguration.reportUnsupportedTags}
* to true.
*/
setSupportForTag(tagDefinition, supported) {
this._requireTagToBeDefined(tagDefinition);
if (supported) {
this._supportedTagDefinitions.add(tagDefinition);
}
else {
this._supportedTagDefinitions.delete(tagDefinition);
}
this.validation.reportUnsupportedTags = true;
}
/**
* Specifies whether the tag definition is supported in this configuration.
* This operation sets {@link TSDocValidationConfiguration.reportUnsupportedTags} to `true`.
*
* @remarks
* The parser may issue warnings for unsupported tags.
* If a tag is "defined" this means that the parser recognizes it and understands its syntax.
* Whereas if a tag is "supported", this means it is defined AND the application implements the tag.
*/
setSupportForTags(tagDefinitions, supported) {
for (const tagDefinition of tagDefinitions) {
this.setSupportForTag(tagDefinition, supported);
}
}
/**
* Assigns the `supportedHtmlElements` property, replacing any previous elements.
* This operation sets {@link TSDocValidationConfiguration.reportUnsupportedHtmlElements} to `true`.
*/
setSupportedHtmlElements(htmlTags) {
this._supportedHtmlElements.clear();
this._validation.reportUnsupportedHtmlElements = true;
for (const htmlTag of htmlTags) {
this._supportedHtmlElements.add(htmlTag);
}
}
/**
* Returns true if the html element is supported in this configuration.
*/
isHtmlElementSupported(htmlTag) {
return this._supportedHtmlElements.has(htmlTag);
}
/**
* Returns true if the specified {@link TSDocMessageId} string is implemented by this release of the TSDoc parser.
* This can be used to detect misspelled identifiers.
*
* @privateRemarks
*
* Why this API is associated with TSDocConfiguration: In the future, if we enable support for custom extensions
* of the TSDoc parser, we may provide a way to register custom message identifiers.
*/
isKnownMessageId(messageId) {
return TSDocMessageId_1.allTsdocMessageIdsSet.has(messageId);
}
/**
* Returns the list of {@link TSDocMessageId} strings that are implemented by this release of the TSDoc parser.
*
* @privateRemarks
*
* Why this API is associated with TSDocConfiguration: In the future, if we enable support for custom extensions
* of the TSDoc parser, we may provide a way to register custom message identifiers.
*/
get allTsdocMessageIds() {
return TSDocMessageId_1.allTsdocMessageIds;
}
_requireTagToBeDefined(tagDefinition) {
const matching = this._tagDefinitionsByName.get(tagDefinition.tagNameWithUpperCase);
if (matching) {
if (matching === tagDefinition) {
return;
}
}
throw new Error('The specified TSDocTagDefinition is not defined for this TSDocConfiguration');
}
}
exports.TSDocConfiguration = TSDocConfiguration;
//# sourceMappingURL=TSDocConfiguration.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,49 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TSDocTagDefinition = exports.TSDocTagSyntaxKind = void 0;
const StringChecks_1 = require("../parser/StringChecks");
const Standardization_1 = require("../details/Standardization");
/**
* Determines the type of syntax for a TSDocTagDefinition
*/
var TSDocTagSyntaxKind;
(function (TSDocTagSyntaxKind) {
/**
* The tag is intended to be an inline tag. For example: `{@link}`.
*/
TSDocTagSyntaxKind[TSDocTagSyntaxKind["InlineTag"] = 0] = "InlineTag";
/**
* The tag is intended to be a block tag that starts a new documentation
* section. For example: `@remarks`
*/
TSDocTagSyntaxKind[TSDocTagSyntaxKind["BlockTag"] = 1] = "BlockTag";
/**
* The tag is intended to be a modifier tag whose presence indicates
* an aspect of the associated API item. For example: `@internal`
*/
TSDocTagSyntaxKind[TSDocTagSyntaxKind["ModifierTag"] = 2] = "ModifierTag";
})(TSDocTagSyntaxKind || (exports.TSDocTagSyntaxKind = TSDocTagSyntaxKind = {}));
/**
* Defines a TSDoc tag that will be understood by the TSDocParser.
*/
class TSDocTagDefinition {
constructor(parameters) {
StringChecks_1.StringChecks.validateTSDocTagName(parameters.tagName);
this.tagName = parameters.tagName;
this.tagNameWithUpperCase = parameters.tagName.toUpperCase();
this.syntaxKind = parameters.syntaxKind;
this.standardization =
parameters.standardization || Standardization_1.Standardization.None;
this.allowMultiple = !!parameters.allowMultiple;
}
/**
* Throws an exception if `tagName` is not a valid TSDoc tag name.
*/
static validateTSDocTagName(tagName) {
StringChecks_1.StringChecks.validateTSDocTagName(tagName);
}
}
exports.TSDocTagDefinition = TSDocTagDefinition;
//# sourceMappingURL=TSDocTagDefinition.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TSDocTagDefinition.js","sourceRoot":"","sources":["../../src/configuration/TSDocTagDefinition.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,yDAAsD;AACtD,gEAA6D;AAE7D;;GAEG;AACH,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,qEAAS,CAAA;IAET;;;OAGG;IACH,mEAAQ,CAAA;IAER;;;OAGG;IACH,yEAAW,CAAA;AACb,CAAC,EAjBW,kBAAkB,kCAAlB,kBAAkB,QAiB7B;AAkBD;;GAEG;AACH,MAAa,kBAAkB;IA8B7B,YAAmB,UAAyC;QAC1D,2BAAY,CAAC,oBAAoB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,oBAAoB,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC7D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;QACxC,IAAI,CAAC,eAAe;YACjB,UAAoD,CAAC,eAAe,IAAI,iCAAe,CAAC,IAAI,CAAC;QAChG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC;IAClD,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,oBAAoB,CAAC,OAAe;QAChD,2BAAY,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF;AA9CD,gDA8CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { StringChecks } from '../parser/StringChecks';\r\nimport { Standardization } from '../details/Standardization';\r\n\r\n/**\r\n * Determines the type of syntax for a TSDocTagDefinition\r\n */\r\nexport enum TSDocTagSyntaxKind {\r\n /**\r\n * The tag is intended to be an inline tag. For example: `{@link}`.\r\n */\r\n InlineTag,\r\n\r\n /**\r\n * The tag is intended to be a block tag that starts a new documentation\r\n * section. For example: `@remarks`\r\n */\r\n BlockTag,\r\n\r\n /**\r\n * The tag is intended to be a modifier tag whose presence indicates\r\n * an aspect of the associated API item. For example: `@internal`\r\n */\r\n ModifierTag\r\n}\r\n\r\n/**\r\n * Constructor parameters for {@link TSDocTagDefinition}\r\n */\r\nexport interface ITSDocTagDefinitionParameters {\r\n tagName: string;\r\n syntaxKind: TSDocTagSyntaxKind;\r\n allowMultiple?: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface ITSDocTagDefinitionInternalParameters extends ITSDocTagDefinitionParameters {\r\n standardization: Standardization;\r\n}\r\n\r\n/**\r\n * Defines a TSDoc tag that will be understood by the TSDocParser.\r\n */\r\nexport class TSDocTagDefinition {\r\n /**\r\n * The TSDoc tag name. TSDoc tag names start with an at-sign (`@`) followed\r\n * by ASCII letters using \"camelCase\" capitalization.\r\n */\r\n public readonly tagName: string;\r\n\r\n /**\r\n * The TSDoc tag name in all capitals, which is used for performing\r\n * case-insensitive comparisons or lookups.\r\n */\r\n public readonly tagNameWithUpperCase: string;\r\n\r\n /**\r\n * Specifies the expected syntax for this tag.\r\n */\r\n public readonly syntaxKind: TSDocTagSyntaxKind;\r\n\r\n /**\r\n * Indicates the level of support expected from documentation tools that implement\r\n * the standard.\r\n */\r\n public readonly standardization: Standardization;\r\n\r\n /**\r\n * If true, then this TSDoc tag may appear multiple times in a doc comment.\r\n * By default, a tag may only appear once.\r\n */\r\n public readonly allowMultiple: boolean;\r\n\r\n public constructor(parameters: ITSDocTagDefinitionParameters) {\r\n StringChecks.validateTSDocTagName(parameters.tagName);\r\n this.tagName = parameters.tagName;\r\n this.tagNameWithUpperCase = parameters.tagName.toUpperCase();\r\n this.syntaxKind = parameters.syntaxKind;\r\n this.standardization =\r\n (parameters as ITSDocTagDefinitionInternalParameters).standardization || Standardization.None;\r\n this.allowMultiple = !!parameters.allowMultiple;\r\n }\r\n\r\n /**\r\n * Throws an exception if `tagName` is not a valid TSDoc tag name.\r\n */\r\n public static validateTSDocTagName(tagName: string): void {\r\n StringChecks.validateTSDocTagName(tagName);\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,51 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TSDocValidationConfiguration = void 0;
/**
* Part of the {@link TSDocConfiguration} object.
*/
class TSDocValidationConfiguration {
constructor() {
/**
* Set `ignoreUndefinedTags` to true to silently ignore unrecognized tags,
* instead of reporting a warning.
*
* @remarks
* Normally the parser will issue errors when it encounters tag names that do not
* have a corresponding definition in {@link TSDocConfiguration.tagDefinitions}.
* This helps to catch common mistakes such as a misspelled tag.
*
* @defaultValue `false`
*/
this.ignoreUndefinedTags = false;
/**
* Set `reportUnsupportedTags` to true to issue a warning for tags that are not
* supported by your tool.
*
* @remarks
* The TSDoc standard defines may tags. By default it assumes that if your tool does
* not implement one of these tags, then it will simply ignore it. But sometimes this
* may be misleading for developers. (For example, they might write an `@example` block
* and then be surprised if it doesn't appear in the documentation output.).
*
* For a better experience, you can tell the parser which tags you support, and then it
* will issue warnings wherever unsupported tags are used. This is done using
* {@link TSDocConfiguration.setSupportForTag}. Note that calling that function
* automatically sets `reportUnsupportedTags` to true.
*
* @defaultValue `false`
*/
this.reportUnsupportedTags = false;
/**
* Set `reportUnsupportedHtmlElements` to true to issue a warning for HTML elements which
* are not defined in your TSDoc configuration's `supportedHtmlElements` field.
*
* @defaultValue `false`
*/
this.reportUnsupportedHtmlElements = false;
}
}
exports.TSDocValidationConfiguration = TSDocValidationConfiguration;
//# sourceMappingURL=TSDocValidationConfiguration.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TSDocValidationConfiguration.js","sourceRoot":"","sources":["../../src/configuration/TSDocValidationConfiguration.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;GAEG;AACH,MAAa,4BAA4B;IAAzC;QACE;;;;;;;;;;WAUG;QACI,wBAAmB,GAAY,KAAK,CAAC;QAE5C;;;;;;;;;;;;;;;;WAgBG;QACI,0BAAqB,GAAY,KAAK,CAAC;QAE9C;;;;;WAKG;QACI,kCAA6B,GAAY,KAAK,CAAC;IACxD,CAAC;CAAA;AAxCD,oEAwCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * Part of the {@link TSDocConfiguration} object.\r\n */\r\nexport class TSDocValidationConfiguration {\r\n /**\r\n * Set `ignoreUndefinedTags` to true to silently ignore unrecognized tags,\r\n * instead of reporting a warning.\r\n *\r\n * @remarks\r\n * Normally the parser will issue errors when it encounters tag names that do not\r\n * have a corresponding definition in {@link TSDocConfiguration.tagDefinitions}.\r\n * This helps to catch common mistakes such as a misspelled tag.\r\n *\r\n * @defaultValue `false`\r\n */\r\n public ignoreUndefinedTags: boolean = false;\r\n\r\n /**\r\n * Set `reportUnsupportedTags` to true to issue a warning for tags that are not\r\n * supported by your tool.\r\n *\r\n * @remarks\r\n * The TSDoc standard defines may tags. By default it assumes that if your tool does\r\n * not implement one of these tags, then it will simply ignore it. But sometimes this\r\n * may be misleading for developers. (For example, they might write an `@example` block\r\n * and then be surprised if it doesn't appear in the documentation output.).\r\n *\r\n * For a better experience, you can tell the parser which tags you support, and then it\r\n * will issue warnings wherever unsupported tags are used. This is done using\r\n * {@link TSDocConfiguration.setSupportForTag}. Note that calling that function\r\n * automatically sets `reportUnsupportedTags` to true.\r\n *\r\n * @defaultValue `false`\r\n */\r\n public reportUnsupportedTags: boolean = false;\r\n\r\n /**\r\n * Set `reportUnsupportedHtmlElements` to true to issue a warning for HTML elements which\r\n * are not defined in your TSDoc configuration's `supportedHtmlElements` field.\r\n *\r\n * @defaultValue `false`\r\n */\r\n public reportUnsupportedHtmlElements: boolean = false;\r\n}\r\n"]}

View File

@@ -0,0 +1,72 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ModifierTagSet = void 0;
const TSDocTagDefinition_1 = require("../configuration/TSDocTagDefinition");
/**
* Represents a set of modifier tags that were extracted from a doc comment.
*
* @remarks
* TSDoc modifier tags are block tags that do not have any associated rich text content.
* Instead, their presence or absence acts as an on/off switch, indicating some aspect
* of the underlying API item. For example, the `@internal` modifier indicates that a
* signature is internal (i.e. not part of the public API contract).
*/
class ModifierTagSet {
constructor() {
this._nodes = [];
// NOTE: To implement case insensitivity, the keys in this set are always upper-case.
// This convention makes the normalization more obvious (and as a general practice handles
// the Turkish "i" character correctly).
this._nodesByName = new Map();
}
/**
* The original block tag nodes that defined the modifiers in this set, excluding duplicates.
*/
get nodes() {
return this._nodes;
}
/**
* Returns true if the set contains a DocBlockTag with the specified tag name.
* Note that synonyms are not considered. The comparison is case-insensitive.
* @param modifierTagName - The name of the tag, including the `@` prefix For example, `@internal`
*/
hasTagName(modifierTagName) {
return this._nodesByName.has(modifierTagName.toUpperCase());
}
/**
* Returns true if the set contains a DocBlockTag matching the specified tag definition.
* Note that synonyms are not considered. The comparison is case-insensitive.
* The TSDocTagDefinition must be a modifier tag.
* @param tagName - The name of the tag, including the `@` prefix For example, `@internal`
*/
hasTag(modifierTagDefinition) {
return !!this.tryGetTag(modifierTagDefinition);
}
/**
* Returns a DocBlockTag matching the specified tag definition, or undefined if no such
* tag was added to the set. If there were multiple instances, returned object will be
* the first one to be added.
*/
tryGetTag(modifierTagDefinition) {
if (modifierTagDefinition.syntaxKind !== TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag) {
throw new Error('The tag definition is not a modifier tag');
}
return this._nodesByName.get(modifierTagDefinition.tagNameWithUpperCase);
}
/**
* Adds a new modifier tag to the set. If a tag already exists with the same name,
* then no change is made, and the return value is false.
*/
addTag(blockTag) {
if (this._nodesByName.has(blockTag.tagNameWithUpperCase)) {
return false;
}
this._nodesByName.set(blockTag.tagNameWithUpperCase, blockTag);
this._nodes.push(blockTag);
return true;
}
}
exports.ModifierTagSet = ModifierTagSet;
//# sourceMappingURL=ModifierTagSet.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ModifierTagSet.js","sourceRoot":"","sources":["../../src/details/ModifierTagSet.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,4EAAkG;AAElG;;;;;;;;GAQG;AACH,MAAa,cAAc;IAA3B;QACmB,WAAM,GAAkB,EAAE,CAAC;QAE5C,qFAAqF;QACrF,0FAA0F;QAC1F,wCAAwC;QACvB,iBAAY,GAA6B,IAAI,GAAG,EAAuB,CAAC;IAsD3F,CAAC;IApDC;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,UAAU,CAAC,eAAuB;QACvC,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,qBAAyC;QACrD,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;IACjD,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,qBAAyC;QACxD,IAAI,qBAAqB,CAAC,UAAU,KAAK,uCAAkB,CAAC,WAAW,EAAE,CAAC;YACxE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,QAAqB;QACjC,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;YACzD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5DD,wCA4DC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { DocBlockTag } from '../nodes/DocBlockTag';\r\nimport { type TSDocTagDefinition, TSDocTagSyntaxKind } from '../configuration/TSDocTagDefinition';\r\n\r\n/**\r\n * Represents a set of modifier tags that were extracted from a doc comment.\r\n *\r\n * @remarks\r\n * TSDoc modifier tags are block tags that do not have any associated rich text content.\r\n * Instead, their presence or absence acts as an on/off switch, indicating some aspect\r\n * of the underlying API item. For example, the `@internal` modifier indicates that a\r\n * signature is internal (i.e. not part of the public API contract).\r\n */\r\nexport class ModifierTagSet {\r\n private readonly _nodes: DocBlockTag[] = [];\r\n\r\n // NOTE: To implement case insensitivity, the keys in this set are always upper-case.\r\n // This convention makes the normalization more obvious (and as a general practice handles\r\n // the Turkish \"i\" character correctly).\r\n private readonly _nodesByName: Map<string, DocBlockTag> = new Map<string, DocBlockTag>();\r\n\r\n /**\r\n * The original block tag nodes that defined the modifiers in this set, excluding duplicates.\r\n */\r\n public get nodes(): ReadonlyArray<DocBlockTag> {\r\n return this._nodes;\r\n }\r\n\r\n /**\r\n * Returns true if the set contains a DocBlockTag with the specified tag name.\r\n * Note that synonyms are not considered. The comparison is case-insensitive.\r\n * @param modifierTagName - The name of the tag, including the `@` prefix For example, `@internal`\r\n */\r\n public hasTagName(modifierTagName: string): boolean {\r\n return this._nodesByName.has(modifierTagName.toUpperCase());\r\n }\r\n\r\n /**\r\n * Returns true if the set contains a DocBlockTag matching the specified tag definition.\r\n * Note that synonyms are not considered. The comparison is case-insensitive.\r\n * The TSDocTagDefinition must be a modifier tag.\r\n * @param tagName - The name of the tag, including the `@` prefix For example, `@internal`\r\n */\r\n public hasTag(modifierTagDefinition: TSDocTagDefinition): boolean {\r\n return !!this.tryGetTag(modifierTagDefinition);\r\n }\r\n\r\n /**\r\n * Returns a DocBlockTag matching the specified tag definition, or undefined if no such\r\n * tag was added to the set. If there were multiple instances, returned object will be\r\n * the first one to be added.\r\n */\r\n public tryGetTag(modifierTagDefinition: TSDocTagDefinition): DocBlockTag | undefined {\r\n if (modifierTagDefinition.syntaxKind !== TSDocTagSyntaxKind.ModifierTag) {\r\n throw new Error('The tag definition is not a modifier tag');\r\n }\r\n return this._nodesByName.get(modifierTagDefinition.tagNameWithUpperCase);\r\n }\r\n\r\n /**\r\n * Adds a new modifier tag to the set. If a tag already exists with the same name,\r\n * then no change is made, and the return value is false.\r\n */\r\n public addTag(blockTag: DocBlockTag): boolean {\r\n if (this._nodesByName.has(blockTag.tagNameWithUpperCase)) {\r\n return false;\r\n }\r\n\r\n this._nodesByName.set(blockTag.tagNameWithUpperCase, blockTag);\r\n this._nodes.push(blockTag);\r\n\r\n return true;\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,81 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.StandardModifierTagSet = void 0;
const ModifierTagSet_1 = require("./ModifierTagSet");
const StandardTags_1 = require("./StandardTags");
/**
* Extends the ModifierTagSet base class with getters for modifiers that
* are part of the standardized core tags for TSDoc.
*/
class StandardModifierTagSet extends ModifierTagSet_1.ModifierTagSet {
/**
* Returns true if the `@alpha` modifier tag was specified.
*/
isAlpha() {
return this.hasTag(StandardTags_1.StandardTags.alpha);
}
/**
* Returns true if the `@beta` modifier tag was specified.
*/
isBeta() {
return this.hasTag(StandardTags_1.StandardTags.beta);
}
/**
* Returns true if the `@eventProperty` modifier tag was specified.
*/
isEventProperty() {
return this.hasTag(StandardTags_1.StandardTags.eventProperty);
}
/**
* Returns true if the `@experimental` modifier tag was specified.
*/
isExperimental() {
return this.hasTag(StandardTags_1.StandardTags.experimental);
}
/**
* Returns true if the `@internal` modifier tag was specified.
*/
isInternal() {
return this.hasTag(StandardTags_1.StandardTags.internal);
}
/**
* Returns true if the `@override` modifier tag was specified.
*/
isOverride() {
return this.hasTag(StandardTags_1.StandardTags.override);
}
/**
* Returns true if the `@packageDocumentation` modifier tag was specified.
*/
isPackageDocumentation() {
return this.hasTag(StandardTags_1.StandardTags.packageDocumentation);
}
/**
* Returns true if the `@public` modifier tag was specified.
*/
isPublic() {
return this.hasTag(StandardTags_1.StandardTags.public);
}
/**
* Returns true if the `@readonly` modifier tag was specified.
*/
isReadonly() {
return this.hasTag(StandardTags_1.StandardTags.readonly);
}
/**
* Returns true if the `@sealed` modifier tag was specified.
*/
isSealed() {
return this.hasTag(StandardTags_1.StandardTags.sealed);
}
/**
* Returns true if the `@virtual` modifier tag was specified.
*/
isVirtual() {
return this.hasTag(StandardTags_1.StandardTags.virtual);
}
}
exports.StandardModifierTagSet = StandardModifierTagSet;
//# sourceMappingURL=StandardModifierTagSet.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"StandardModifierTagSet.js","sourceRoot":"","sources":["../../src/details/StandardModifierTagSet.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,qDAAkD;AAClD,iDAA8C;AAE9C;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,+BAAc;IACxD;;OAEG;IACI,OAAO;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,2BAAY,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,MAAM;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,2BAAY,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACI,eAAe;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,2BAAY,CAAC,aAAa,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACI,cAAc;QACnB,OAAO,IAAI,CAAC,MAAM,CAAC,2BAAY,CAAC,YAAY,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,2BAAY,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,2BAAY,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,sBAAsB;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,2BAAY,CAAC,oBAAoB,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,2BAAY,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,2BAAY,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,2BAAY,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,2BAAY,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;CACF;AA7ED,wDA6EC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { ModifierTagSet } from './ModifierTagSet';\r\nimport { StandardTags } from './StandardTags';\r\n\r\n/**\r\n * Extends the ModifierTagSet base class with getters for modifiers that\r\n * are part of the standardized core tags for TSDoc.\r\n */\r\nexport class StandardModifierTagSet extends ModifierTagSet {\r\n /**\r\n * Returns true if the `@alpha` modifier tag was specified.\r\n */\r\n public isAlpha(): boolean {\r\n return this.hasTag(StandardTags.alpha);\r\n }\r\n\r\n /**\r\n * Returns true if the `@beta` modifier tag was specified.\r\n */\r\n public isBeta(): boolean {\r\n return this.hasTag(StandardTags.beta);\r\n }\r\n\r\n /**\r\n * Returns true if the `@eventProperty` modifier tag was specified.\r\n */\r\n public isEventProperty(): boolean {\r\n return this.hasTag(StandardTags.eventProperty);\r\n }\r\n\r\n /**\r\n * Returns true if the `@experimental` modifier tag was specified.\r\n */\r\n public isExperimental(): boolean {\r\n return this.hasTag(StandardTags.experimental);\r\n }\r\n\r\n /**\r\n * Returns true if the `@internal` modifier tag was specified.\r\n */\r\n public isInternal(): boolean {\r\n return this.hasTag(StandardTags.internal);\r\n }\r\n\r\n /**\r\n * Returns true if the `@override` modifier tag was specified.\r\n */\r\n public isOverride(): boolean {\r\n return this.hasTag(StandardTags.override);\r\n }\r\n\r\n /**\r\n * Returns true if the `@packageDocumentation` modifier tag was specified.\r\n */\r\n public isPackageDocumentation(): boolean {\r\n return this.hasTag(StandardTags.packageDocumentation);\r\n }\r\n\r\n /**\r\n * Returns true if the `@public` modifier tag was specified.\r\n */\r\n public isPublic(): boolean {\r\n return this.hasTag(StandardTags.public);\r\n }\r\n\r\n /**\r\n * Returns true if the `@readonly` modifier tag was specified.\r\n */\r\n public isReadonly(): boolean {\r\n return this.hasTag(StandardTags.readonly);\r\n }\r\n\r\n /**\r\n * Returns true if the `@sealed` modifier tag was specified.\r\n */\r\n public isSealed(): boolean {\r\n return this.hasTag(StandardTags.sealed);\r\n }\r\n\r\n /**\r\n * Returns true if the `@virtual` modifier tag was specified.\r\n */\r\n public isVirtual(): boolean {\r\n return this.hasTag(StandardTags.virtual);\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,561 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.StandardTags = void 0;
const TSDocTagDefinition_1 = require("../configuration/TSDocTagDefinition");
const Standardization_1 = require("./Standardization");
/**
* Tags whose meaning is defined by the TSDoc standard.
*/
class StandardTags {
static _defineTag(parameters) {
return new TSDocTagDefinition_1.TSDocTagDefinition(parameters);
}
}
exports.StandardTags = StandardTags;
/**
* (Discretionary)
*
* Suggested meaning: Designates that an API item's release stage is "alpha".
* It is intended to be used by third-party developers eventually, but has not
* yet been released. The tooling may trim the declaration from a public release.
*
* @remarks
* Example implementations: API Extractor
*/
StandardTags.alpha = StandardTags._defineTag({
tagName: '@alpha',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag,
standardization: Standardization_1.Standardization.Discretionary
});
/**
* (Discretionary)
*
* Suggested meaning: Designates that an API item's release stage is "beta".
* It has been released to third-party developers experimentally for the purpose of
* collecting feedback. The API should not be used in production, because its contract may
* change without notice. The tooling may trim the declaration from a public release,
* but may include it in a developer preview release.
*
* @remarks
* Example implementations: API Extractor
*
* Synonyms: `@experimental`
*/
StandardTags.beta = StandardTags._defineTag({
tagName: '@beta',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag,
standardization: Standardization_1.Standardization.Discretionary
});
/**
* (Extended)
*
* ECMAScript decorators are sometimes an important part of an API contract.
* However, today the TypeScript compiler does not represent decorators in the
* .d.ts output files used by API consumers. The `@decorator` tag provides a workaround,
* enabling a decorator expressions to be quoted in a doc comment.
*
* @example
* ```ts
* class Book {
* /**
* * The title of the book.
* * @decorator `@jsonSerialized`
* * @decorator `@jsonFormat(JsonFormats.Url)`
* *
*+/
* @jsonSerialized
* @jsonFormat(JsonFormats.Url)
* public website: string;
* }
* ```
*/
StandardTags.decorator = StandardTags._defineTag({
tagName: '@decorator',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
allowMultiple: true,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Extended)
*
* This block tag is used to document the default value for a field or property,
* if a value is not assigned explicitly.
*
* @remarks
* This tag should only be used with fields or properties that are members of a class or interface.
*/
StandardTags.defaultValue = StandardTags._defineTag({
tagName: '@defaultValue',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Core)
*
* This block tag communicates that an API item is no longer supported and may be removed
* in a future release. The `@deprecated` tag is followed by a sentence describing
* the recommended alternative. It recursively applies to members of the container.
* For example, if a class is deprecated, then so are all of its members.
*/
StandardTags.deprecated = StandardTags._defineTag({
tagName: '@deprecated',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
standardization: Standardization_1.Standardization.Core
});
/**
* (Extended)
*
* When applied to a class or interface property, this indicates that the property
* returns an event object that event handlers can be attached to. The event-handling
* API is implementation-defined, but typically the property return type would be a class
* with members such as `addHandler()` and `removeHandler()`. A documentation tool can
* display such properties under an "Events" heading instead of the usual "Properties" heading.
*/
StandardTags.eventProperty = StandardTags._defineTag({
tagName: '@eventProperty',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Extended)
*
* Indicates a documentation section that should be presented as an example
* illustrating how to use the API. It may include a code sample.
*/
StandardTags.example = StandardTags._defineTag({
tagName: '@example',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
allowMultiple: true,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Discretionary)
*
* Suggested meaning: Same semantics as `@beta`, but used by tools that don't support
* an `@alpha` release stage.
*
* @remarks
* Example implementations: Angular API documenter
*
* Synonyms: `@beta`
*/
StandardTags.experimental = StandardTags._defineTag({
tagName: '@experimental',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag,
standardization: Standardization_1.Standardization.Discretionary
});
/**
* (Extended)
*
* This inline tag is used to automatically generate an API item's documentation by
* copying it from another API item. The inline tag parameter contains a reference
* to the other item, which may be an unrelated class, or even an import from a
* separate NPM package.
*
* @remarks
* What gets copied
*
* The `@inheritDoc` tag does not copy the entire comment body. Only the following
* components are copied:
* - summary section
* - `@remarks` block
* - `@params` blocks
* - `@typeParam` blocks
* - `@returns` block
* Other tags such as `@defaultValue` or `@example` are not copied, and need to be
* explicitly included after the `@inheritDoc` tag.
*
* TODO: The notation for API item references is still being standardized. See this issue:
* https://github.com/microsoft/tsdoc/issues/9
*/
StandardTags.inheritDoc = StandardTags._defineTag({
tagName: '@inheritDoc',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.InlineTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Discretionary)
*
* Suggested meaning: Designates that an API item is not planned to be used by
* third-party developers. The tooling may trim the declaration from a public release.
* In some implementations, certain designated packages may be allowed to consume
* internal API items, e.g. because the packages are components of the same product.
*
* @remarks
* Example implementations: API Extractor
*/
StandardTags.internal = StandardTags._defineTag({
tagName: '@internal',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag,
standardization: Standardization_1.Standardization.Discretionary
});
/**
* (Core)
*
* The `{@label}` inline tag is used to label a declaration, so that it can be referenced
* using a selector in the TSDoc declaration reference notation.
*
* @remarks
* TODO: The `{@label}` notation is still being standardized. See this issue:
* https://github.com/microsoft/tsdoc/issues/9
*/
StandardTags.label = StandardTags._defineTag({
tagName: '@label',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.InlineTag,
standardization: Standardization_1.Standardization.Core
});
/**
* (Core)
*
* The `{@link}` inline tag is used to create hyperlinks to other pages in a
* documentation system or general internet URLs. In particular, it supports
* expressions for referencing API items.
*
* @remarks
* TODO: The `{@link}` notation is still being standardized. See this issue:
* https://github.com/microsoft/tsdoc/issues/9
*/
StandardTags.link = StandardTags._defineTag({
tagName: '@link',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.InlineTag,
allowMultiple: true,
standardization: Standardization_1.Standardization.Core
});
/**
* (Extended)
*
* This modifier has similar semantics to the `override` keyword in C# or Java.
* For a member function or property, explicitly indicates that this definition
* is overriding (i.e. redefining) the definition inherited from the base class.
* The base class definition would normally be marked as `virtual`.
*
* @remarks
* A documentation tool may enforce that the `@virtual`, `@override`, and/or `@sealed`
* modifiers are consistently applied, but this is not required by the TSDoc standard.
*/
StandardTags.override = StandardTags._defineTag({
tagName: '@override',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Core)
*
* Used to indicate a doc comment that describes an entire NPM package (as opposed
* to an individual API item belonging to that package). The `@packageDocumentation` comment
* is found in the *.d.ts file that acts as the entry point for the package, and it
* should be the first `/**` comment encountered in that file. A comment containing a
* `@packageDocumentation` tag should never be used to describe an individual API item.
*/
StandardTags.packageDocumentation = StandardTags._defineTag({
tagName: '@packageDocumentation',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag,
standardization: Standardization_1.Standardization.Core
});
/**
* (Core)
*
* Used to document a function parameter. The `@param` tag is followed by a parameter
* name, followed by a hyphen, followed by a description. The TSDoc parser recognizes
* this syntax and will extract it into a DocParamBlock node.
*/
StandardTags.param = StandardTags._defineTag({
tagName: '@param',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
allowMultiple: true,
standardization: Standardization_1.Standardization.Core
});
/**
* (Core)
*
* Starts a section of additional documentation content that is not intended for a
* public audience. A tool must omit this entire section from the API reference web site,
* generated *.d.ts file, and any other outputs incorporating the content.
*/
StandardTags.privateRemarks = StandardTags._defineTag({
tagName: '@privateRemarks',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
standardization: Standardization_1.Standardization.Core
});
/**
* (Discretionary)
*
* Suggested meaning: Designates that an API item's release stage is "public".
* It has been officially released to third-party developers, and its signature is
* guaranteed to be stable (e.g. following Semantic Versioning rules).
*
* @remarks
* Example implementations: API Extractor
*/
StandardTags.public = StandardTags._defineTag({
tagName: '@public',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag,
standardization: Standardization_1.Standardization.Discretionary
});
/**
* (Extended)
*
* This modifier tag indicates that an API item should be documented as being read-only,
* even if the TypeScript type system may indicate otherwise. For example, suppose a
* class property has a setter function that always throws an exception explaining that
* the property cannot be assigned; in this situation, the `@readonly` modifier can be
* added so that the property is shown as read-only in the documentation.
*
* @remarks
* Example implementations: API Extractor
*/
StandardTags.readonly = StandardTags._defineTag({
tagName: '@readonly',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Core)
*
* The main documentation for an API item is separated into a brief "summary" section,
* optionally followed by a more detailed "remarks" section. On a documentation web site,
* index pages (e.g. showing members of a class) will show only the brief summaries,
* whereas a detail pages (e.g. describing a single member) will show the summary followed
* by the remarks. The `@remarks` block tag ends the summary section, and begins the
* remarks section for a doc comment.
*/
StandardTags.remarks = StandardTags._defineTag({
tagName: '@remarks',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
standardization: Standardization_1.Standardization.Core
});
/**
* (Core)
*
* Used to document the return value for a function.
*/
StandardTags.returns = StandardTags._defineTag({
tagName: '@returns',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
standardization: Standardization_1.Standardization.Core
});
/**
* (Extended)
*
* This modifier has similar semantics to the `sealed` keyword in C# or Java.
* For a class, indicates that subclasses must not inherit from the class.
* For a member function or property, indicates that subclasses must not override
* (i.e. redefine) the member.
*
* @remarks
* A documentation tool may enforce that the `@virtual`, `@override`, and/or `@sealed`
* modifiers are consistently applied, but this is not required by the TSDoc standard.
*/
StandardTags.sealed = StandardTags._defineTag({
tagName: '@sealed',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Extended)
*
* Used to build a list of references to an API item or other resource that may be related to the
* current item.
*
* @remarks
*
* For example:
*
* ```ts
* /**
* * Parses a string containing a Uniform Resource Locator (URL).
* * @see {@link ParsedUrl} for the returned data structure
* * @see {@link https://tools.ietf.org/html/rfc1738|RFC 1738}
* * for syntax
* * @see your developer SDK for code samples
* * @param url - the string to be parsed
* * @returns the parsed result
* &#42;/
* function parseURL(url: string): ParsedUrl;
* ```
*
* `@see` is a block tag. Each block becomes an item in the list of references. For example, a documentation
* system might render the above blocks as follows:
*
* ```markdown
* `function parseURL(url: string): ParsedUrl;`
*
* Parses a string containing a Uniform Resource Locator (URL).
*
* ## See Also
* - ParsedUrl for the returned data structure
* - RFC 1738 for syntax
* - your developer SDK for code samples
* ```
*
* NOTE: JSDoc attempts to automatically hyperlink the text immediately after `@see`. Because this is ambiguous
* with plain text, TSDoc instead requires an explicit `{@link}` tag to make hyperlinks.
*/
StandardTags.see = StandardTags._defineTag({
tagName: '@see',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Extended)
*
* Used to document an exception type that may be thrown by a function or property.
*
* @remarks
*
* A separate `@throws` block should be used to document each exception type. This tag is for informational
* purposes only, and does not restrict other types from being thrown. It is suggested, but not required,
* for the `@throws` block to start with a line containing only the name of the exception.
*
* For example:
*
* ```ts
* /**
* * Retrieves metadata about a book from the catalog.
* *
* * @param isbnCode - the ISBN number for the book
* * @returns the retrieved book object
* *
* * @throws {@link IsbnSyntaxError}
* * This exception is thrown if the input is not a valid ISBN number.
* *
* * @throws {@link book-lib#BookNotFoundError}
* * Thrown if the ISBN number is valid, but no such book exists in the catalog.
* *
* * @public
* &#42;/
* function fetchBookByIsbn(isbnCode: string): Book;
* ```
*/
StandardTags.throws = StandardTags._defineTag({
tagName: '@throws',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
allowMultiple: true,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Core)
*
* Used to document a generic parameter. The `@typeParam` tag is followed by a parameter
* name, followed by a hyphen, followed by a description. The TSDoc parser recognizes
* this syntax and will extract it into a DocParamBlock node.
*/
StandardTags.typeParam = StandardTags._defineTag({
tagName: '@typeParam',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
allowMultiple: true,
standardization: Standardization_1.Standardization.Core
});
/**
* (Extended)
*
* This modifier has similar semantics to the `virtual` keyword in C# or Java.
* For a member function or property, explicitly indicates that subclasses may override
* (i.e. redefine) the member.
*
* @remarks
* A documentation tool may enforce that the `@virtual`, `@override`, and/or `@sealed`
* modifiers are consistently applied, but this is not required by the TSDoc standard.
*/
StandardTags.virtual = StandardTags._defineTag({
tagName: '@virtual',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.ModifierTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Extended)
*
* Used to specify the JSX factory function to use when compiling JSX syntax.
*
* @remarks
* The TypeScript compiler recognizes this tag and specifies its behavior:
*
* @see {@link https://www.typescriptlang.org/tsconfig/#jsx}
*/
StandardTags.jsx = StandardTags._defineTag({
tagName: '@jsx',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Extended)
*
* Used to specify the JSX runtime to use when compiling JSX syntax.
*
* @remarks
* The TypeScript compiler recognizes this tag and specifies its behavior:
*
* @see {@link https://www.typescriptlang.org/tsconfig/#jsx}
*/
StandardTags.jsxRuntime = StandardTags._defineTag({
tagName: '@jsxRuntime',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Extended)
*
* Used to specify the JSX fragment factory to use when compiling JSX syntax.
*
* @remarks
* The TypeScript compiler recognizes this tag and specifies its behavior:
*
* @see {@link https://www.typescriptlang.org/tsconfig/#jsx}
*/
StandardTags.jsxFrag = StandardTags._defineTag({
tagName: '@jsxFrag',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* (Extended)
*
* Used to specify the JSX import source when compiling JSX syntax.
*
* @remarks
* The TypeScript compiler recognizes this tag and specifies its behavior:
*
* @see {@link https://www.typescriptlang.org/tsconfig/#jsx}
*/
StandardTags.jsxImportSource = StandardTags._defineTag({
tagName: '@jsxImportSource',
syntaxKind: TSDocTagDefinition_1.TSDocTagSyntaxKind.BlockTag,
standardization: Standardization_1.Standardization.Extended
});
/**
* Returns the full list of all core tags.
*/
StandardTags.allDefinitions = [
StandardTags.alpha,
StandardTags.beta,
StandardTags.defaultValue,
StandardTags.decorator,
StandardTags.deprecated,
StandardTags.eventProperty,
StandardTags.example,
StandardTags.experimental,
StandardTags.inheritDoc,
StandardTags.internal,
StandardTags.label,
StandardTags.link,
StandardTags.override,
StandardTags.packageDocumentation,
StandardTags.param,
StandardTags.privateRemarks,
StandardTags.public,
StandardTags.readonly,
StandardTags.remarks,
StandardTags.returns,
StandardTags.sealed,
StandardTags.see,
StandardTags.throws,
StandardTags.typeParam,
StandardTags.virtual,
StandardTags.jsx,
StandardTags.jsxRuntime,
StandardTags.jsxFrag,
StandardTags.jsxImportSource
];
//# sourceMappingURL=StandardTags.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,39 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Standardization = void 0;
/**
* Used to group the {@link StandardTags} definitions according to the level of support
* expected from documentation tools that implement the standard.
*/
var Standardization;
(function (Standardization) {
/**
* TSDoc tags in the "Core" standardization group are considered essential.
* Their meaning is standardized, and every documentation tool is expected
* to recognize them. The TSDoc parser library typically provides dedicated APIs
* for accessing these tags.
*/
Standardization["Core"] = "Core";
/**
* TSDoc tags in the "Extended" standardization group are optional. Documentation tools
* may or may not support them. If they do, the syntax and semantics should conform to
* the TSDoc standard definitions.
*/
Standardization["Extended"] = "Extended";
/**
* TSDoc tags in the "Discretionary" standardization group are optional. Although the
* syntax is specified, the semantics for these tags are implementation-specific
* (and sometimes difficult to describe completely without referring to a specific
* implementation). Discretionary tags are included in the TSDoc standard to ensure that
* if two different popular tools use the same tag name, developers can expect the syntax
* to be the same, and the semantics to be somewhat similar.
*/
Standardization["Discretionary"] = "Discretionary";
/**
* The tag is not part of the TSDoc standard. All user-defined tags are assigned to this group.
*/
Standardization["None"] = "None";
})(Standardization || (exports.Standardization = Standardization = {}));
//# sourceMappingURL=Standardization.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Standardization.js","sourceRoot":"","sources":["../../src/details/Standardization.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;GAGG;AACH,IAAY,eA8BX;AA9BD,WAAY,eAAe;IACzB;;;;;OAKG;IACH,gCAAa,CAAA;IAEb;;;;OAIG;IACH,wCAAqB,CAAA;IAErB;;;;;;;OAOG;IACH,kDAA+B,CAAA;IAE/B;;OAEG;IACH,gCAAa,CAAA;AACf,CAAC,EA9BW,eAAe,+BAAf,eAAe,QA8B1B","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * Used to group the {@link StandardTags} definitions according to the level of support\r\n * expected from documentation tools that implement the standard.\r\n */\r\nexport enum Standardization {\r\n /**\r\n * TSDoc tags in the \"Core\" standardization group are considered essential.\r\n * Their meaning is standardized, and every documentation tool is expected\r\n * to recognize them. The TSDoc parser library typically provides dedicated APIs\r\n * for accessing these tags.\r\n */\r\n Core = 'Core',\r\n\r\n /**\r\n * TSDoc tags in the \"Extended\" standardization group are optional. Documentation tools\r\n * may or may not support them. If they do, the syntax and semantics should conform to\r\n * the TSDoc standard definitions.\r\n */\r\n Extended = 'Extended',\r\n\r\n /**\r\n * TSDoc tags in the \"Discretionary\" standardization group are optional. Although the\r\n * syntax is specified, the semantics for these tags are implementation-specific\r\n * (and sometimes difficult to describe completely without referring to a specific\r\n * implementation). Discretionary tags are included in the TSDoc standard to ensure that\r\n * if two different popular tools use the same tag name, developers can expect the syntax\r\n * to be the same, and the semantics to be somewhat similar.\r\n */\r\n Discretionary = 'Discretionary',\r\n\r\n /**\r\n * The tag is not part of the TSDoc standard. All user-defined tags are assigned to this group.\r\n */\r\n None = 'None'\r\n}\r\n"]}

View File

@@ -0,0 +1,79 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlainTextEmitter = void 0;
const nodes_1 = require("../nodes");
/**
* Renders a DocNode tree as plain text, without any rich text formatting or markup.
*/
class PlainTextEmitter {
static hasAnyTextContent(nodeOrNodes, requiredCharacters) {
if (requiredCharacters === undefined || requiredCharacters < 1) {
requiredCharacters = 1; // default
}
let nodes;
if (nodeOrNodes instanceof nodes_1.DocNode) {
nodes = [nodeOrNodes];
}
else {
nodes = nodeOrNodes;
}
const foundCharacters = PlainTextEmitter._scanTextContent(nodes, requiredCharacters, 0);
return foundCharacters >= requiredCharacters;
}
static _scanTextContent(nodes, requiredCharacters, foundCharacters) {
for (const node of nodes) {
switch (node.kind) {
case nodes_1.DocNodeKind.FencedCode:
const docFencedCode = node;
foundCharacters += PlainTextEmitter._countNonSpaceCharacters(docFencedCode.code);
break;
case nodes_1.DocNodeKind.CodeSpan:
const docCodeSpan = node;
foundCharacters += PlainTextEmitter._countNonSpaceCharacters(docCodeSpan.code);
break;
case nodes_1.DocNodeKind.EscapedText:
const docEscapedText = node;
foundCharacters += PlainTextEmitter._countNonSpaceCharacters(docEscapedText.decodedText);
break;
case nodes_1.DocNodeKind.LinkTag:
const docLinkTag = node;
foundCharacters += PlainTextEmitter._countNonSpaceCharacters(docLinkTag.linkText || '');
break;
case nodes_1.DocNodeKind.PlainText:
const docPlainText = node;
foundCharacters += PlainTextEmitter._countNonSpaceCharacters(docPlainText.text);
break;
}
if (foundCharacters >= requiredCharacters) {
break;
}
foundCharacters += PlainTextEmitter._scanTextContent(node.getChildNodes(), requiredCharacters, foundCharacters);
if (foundCharacters >= requiredCharacters) {
break;
}
}
return foundCharacters;
}
static _countNonSpaceCharacters(s) {
let count = 0;
const length = s.length;
let i = 0;
while (i < length) {
switch (s.charCodeAt(i)) {
case 32: // space
case 9: // tab
case 13: // CR
case 10: // LF
break;
default:
++count;
}
++i;
}
return count;
}
}
exports.PlainTextEmitter = PlainTextEmitter;
//# sourceMappingURL=PlainTextEmitter.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,39 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.StringBuilder = void 0;
/**
* This class allows a large text string to be constructed incrementally by appending small chunks. The final
* string can be obtained by calling StringBuilder.toString().
*
* @remarks
* A naive approach might use the `+=` operator to append strings: This would have the downside of copying
* the entire string each time a chunk is appended, resulting in `O(n^2)` bytes of memory being allocated
* (and later freed by the garbage collector), and many of the allocations could be very large objects.
* StringBuilder avoids this overhead by accumulating the chunks in an array, and efficiently joining them
* when `getText()` is finally called.
*/
class StringBuilder {
constructor() {
this._chunks = [];
}
/** {@inheritdoc IStringBuilder.append} */
append(text) {
this._chunks.push(text);
}
/** {@inheritdoc IStringBuilder.toString} */
toString() {
if (this._chunks.length === 0) {
return '';
}
if (this._chunks.length > 1) {
const joined = this._chunks.join('');
this._chunks.length = 1;
this._chunks[0] = joined;
}
return this._chunks[0];
}
}
exports.StringBuilder = StringBuilder;
//# sourceMappingURL=StringBuilder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"StringBuilder.js","sourceRoot":"","sources":["../../src/emitters/StringBuilder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AA0B3D;;;;;;;;;;GAUG;AACH,MAAa,aAAa;IAGxB;QACE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED,0CAA0C;IACnC,MAAM,CAAC,IAAY;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,4CAA4C;IACrC,QAAQ;QACb,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,MAAM,GAAW,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC7C,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;QAC3B,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;CACF;AA1BD,sCA0BC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * An interface for a builder object that allows a large text string to be constructed incrementally by appending\r\n * small chunks.\r\n *\r\n * @remarks\r\n *\r\n * {@link StringBuilder} is the default implementation of this contract.\r\n */\r\nexport interface IStringBuilder {\r\n /**\r\n * Append the specified text to the buffer.\r\n */\r\n append(text: string): void;\r\n\r\n /**\r\n * Returns a single string containing all the text that was appended to the buffer so far.\r\n *\r\n * @remarks\r\n *\r\n * This is a potentially expensive operation.\r\n */\r\n toString(): string;\r\n}\r\n\r\n/**\r\n * This class allows a large text string to be constructed incrementally by appending small chunks. The final\r\n * string can be obtained by calling StringBuilder.toString().\r\n *\r\n * @remarks\r\n * A naive approach might use the `+=` operator to append strings: This would have the downside of copying\r\n * the entire string each time a chunk is appended, resulting in `O(n^2)` bytes of memory being allocated\r\n * (and later freed by the garbage collector), and many of the allocations could be very large objects.\r\n * StringBuilder avoids this overhead by accumulating the chunks in an array, and efficiently joining them\r\n * when `getText()` is finally called.\r\n */\r\nexport class StringBuilder implements IStringBuilder {\r\n private _chunks: string[];\r\n\r\n public constructor() {\r\n this._chunks = [];\r\n }\r\n\r\n /** {@inheritdoc IStringBuilder.append} */\r\n public append(text: string): void {\r\n this._chunks.push(text);\r\n }\r\n\r\n /** {@inheritdoc IStringBuilder.toString} */\r\n public toString(): string {\r\n if (this._chunks.length === 0) {\r\n return '';\r\n }\r\n\r\n if (this._chunks.length > 1) {\r\n const joined: string = this._chunks.join('');\r\n this._chunks.length = 1;\r\n this._chunks[0] = joined;\r\n }\r\n\r\n return this._chunks[0];\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,371 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TSDocEmitter = void 0;
const DocNode_1 = require("../nodes/DocNode");
const DocNodeTransforms_1 = require("../transforms/DocNodeTransforms");
const StandardTags_1 = require("../details/StandardTags");
var LineState;
(function (LineState) {
LineState[LineState["Closed"] = 0] = "Closed";
LineState[LineState["StartOfLine"] = 1] = "StartOfLine";
LineState[LineState["MiddleOfLine"] = 2] = "MiddleOfLine";
})(LineState || (LineState = {}));
/**
* Renders a DocNode tree as a code comment.
*/
class TSDocEmitter {
constructor() {
this.eol = '\n';
// Whether to emit the /** */ framing
this._emitCommentFraming = true;
// This state machine is used by the writer functions to generate the /** */ framing around the emitted lines
this._lineState = LineState.Closed;
// State for _ensureLineSkipped()
this._previousLineHadContent = false;
// Normally a paragraph is precede by a blank line (unless it's the first thing written).
// But sometimes we want the paragraph to be attached to the previous element, e.g. when it's part of
// an "@param" block. Setting _hangingParagraph=true accomplishes that.
this._hangingParagraph = false;
}
renderComment(output, docComment) {
this._emitCommentFraming = true;
this._renderCompleteObject(output, docComment);
}
renderHtmlTag(output, htmlTag) {
this._emitCommentFraming = false;
this._renderCompleteObject(output, htmlTag);
}
renderDeclarationReference(output, declarationReference) {
this._emitCommentFraming = false;
this._renderCompleteObject(output, declarationReference);
}
_renderCompleteObject(output, docNode) {
this._output = output;
this._lineState = LineState.Closed;
this._previousLineHadContent = false;
this._hangingParagraph = false;
this._renderNode(docNode);
this._writeEnd();
}
_renderNode(docNode) {
if (docNode === undefined) {
return;
}
switch (docNode.kind) {
case DocNode_1.DocNodeKind.Block:
const docBlock = docNode;
this._ensureLineSkipped();
this._renderNode(docBlock.blockTag);
if (docBlock.blockTag.tagNameWithUpperCase === StandardTags_1.StandardTags.returns.tagNameWithUpperCase ||
docBlock.blockTag.tagNameWithUpperCase === StandardTags_1.StandardTags.defaultValue.tagNameWithUpperCase) {
this._writeContent(' ');
this._hangingParagraph = true;
}
this._renderNode(docBlock.content);
break;
case DocNode_1.DocNodeKind.BlockTag:
const docBlockTag = docNode;
if (this._lineState === LineState.MiddleOfLine) {
this._writeContent(' ');
}
this._writeContent(docBlockTag.tagName);
break;
case DocNode_1.DocNodeKind.CodeSpan:
const docCodeSpan = docNode;
this._writeContent('`');
this._writeContent(docCodeSpan.code);
this._writeContent('`');
break;
case DocNode_1.DocNodeKind.Comment:
const docComment = docNode;
this._renderNodes([
docComment.summarySection,
docComment.remarksBlock,
docComment.privateRemarks,
docComment.deprecatedBlock,
docComment.params,
docComment.typeParams,
docComment.returnsBlock,
...docComment.customBlocks,
...docComment.seeBlocks,
docComment.inheritDocTag
]);
if (docComment.modifierTagSet.nodes.length > 0) {
this._ensureLineSkipped();
this._renderNodes(docComment.modifierTagSet.nodes);
}
break;
case DocNode_1.DocNodeKind.DeclarationReference:
const docDeclarationReference = docNode;
this._writeContent(docDeclarationReference.packageName);
this._writeContent(docDeclarationReference.importPath);
if (docDeclarationReference.packageName !== undefined ||
docDeclarationReference.importPath !== undefined) {
this._writeContent('#');
}
this._renderNodes(docDeclarationReference.memberReferences);
break;
case DocNode_1.DocNodeKind.ErrorText:
const docErrorText = docNode;
this._writeContent(docErrorText.text);
break;
case DocNode_1.DocNodeKind.EscapedText:
const docEscapedText = docNode;
this._writeContent(docEscapedText.encodedText);
break;
case DocNode_1.DocNodeKind.FencedCode:
const docFencedCode = docNode;
this._ensureAtStartOfLine();
this._writeContent('```');
this._writeContent(docFencedCode.language);
this._writeNewline();
this._writeContent(docFencedCode.code);
this._writeContent('```');
this._writeNewline();
this._writeNewline();
break;
case DocNode_1.DocNodeKind.HtmlAttribute:
const docHtmlAttribute = docNode;
this._writeContent(docHtmlAttribute.name);
this._writeContent(docHtmlAttribute.spacingAfterName);
this._writeContent('=');
this._writeContent(docHtmlAttribute.spacingAfterEquals);
this._writeContent(docHtmlAttribute.value);
this._writeContent(docHtmlAttribute.spacingAfterValue);
break;
case DocNode_1.DocNodeKind.HtmlEndTag:
const docHtmlEndTag = docNode;
this._writeContent('</');
this._writeContent(docHtmlEndTag.name);
this._writeContent('>');
break;
case DocNode_1.DocNodeKind.HtmlStartTag:
const docHtmlStartTag = docNode;
this._writeContent('<');
this._writeContent(docHtmlStartTag.name);
this._writeContent(docHtmlStartTag.spacingAfterName);
let needsSpace = docHtmlStartTag.spacingAfterName === undefined || docHtmlStartTag.spacingAfterName.length === 0;
for (const attribute of docHtmlStartTag.htmlAttributes) {
if (needsSpace) {
this._writeContent(' ');
}
this._renderNode(attribute);
needsSpace = attribute.spacingAfterValue === undefined || attribute.spacingAfterValue.length === 0;
}
this._writeContent(docHtmlStartTag.selfClosingTag ? '/>' : '>');
break;
case DocNode_1.DocNodeKind.InheritDocTag:
const docInheritDocTag = docNode;
this._renderInlineTag(docInheritDocTag, () => {
if (docInheritDocTag.declarationReference) {
this._writeContent(' ');
this._renderNode(docInheritDocTag.declarationReference);
}
});
break;
case DocNode_1.DocNodeKind.InlineTag:
const docInlineTag = docNode;
this._renderInlineTag(docInlineTag, () => {
if (docInlineTag.tagContent.length > 0) {
this._writeContent(' ');
this._writeContent(docInlineTag.tagContent);
}
});
break;
case DocNode_1.DocNodeKind.LinkTag:
const docLinkTag = docNode;
this._renderInlineTag(docLinkTag, () => {
if (docLinkTag.urlDestination !== undefined || docLinkTag.codeDestination !== undefined) {
if (docLinkTag.urlDestination !== undefined) {
this._writeContent(' ');
this._writeContent(docLinkTag.urlDestination);
}
else if (docLinkTag.codeDestination !== undefined) {
this._writeContent(' ');
this._renderNode(docLinkTag.codeDestination);
}
}
if (docLinkTag.linkText !== undefined) {
this._writeContent(' ');
this._writeContent('|');
this._writeContent(' ');
this._writeContent(docLinkTag.linkText);
}
});
break;
case DocNode_1.DocNodeKind.MemberIdentifier:
const docMemberIdentifier = docNode;
if (docMemberIdentifier.hasQuotes) {
this._writeContent('"');
this._writeContent(docMemberIdentifier.identifier); // todo: encoding
this._writeContent('"');
}
else {
this._writeContent(docMemberIdentifier.identifier);
}
break;
case DocNode_1.DocNodeKind.MemberReference:
const docMemberReference = docNode;
if (docMemberReference.hasDot) {
this._writeContent('.');
}
if (docMemberReference.selector) {
this._writeContent('(');
}
if (docMemberReference.memberSymbol) {
this._renderNode(docMemberReference.memberSymbol);
}
else {
this._renderNode(docMemberReference.memberIdentifier);
}
if (docMemberReference.selector) {
this._writeContent(':');
this._renderNode(docMemberReference.selector);
this._writeContent(')');
}
break;
case DocNode_1.DocNodeKind.MemberSelector:
const docMemberSelector = docNode;
this._writeContent(docMemberSelector.selector);
break;
case DocNode_1.DocNodeKind.MemberSymbol:
const docMemberSymbol = docNode;
this._writeContent('[');
this._renderNode(docMemberSymbol.symbolReference);
this._writeContent(']');
break;
case DocNode_1.DocNodeKind.Section:
const docSection = docNode;
this._renderNodes(docSection.nodes);
break;
case DocNode_1.DocNodeKind.Paragraph:
const trimmedParagraph = DocNodeTransforms_1.DocNodeTransforms.trimSpacesInParagraph(docNode);
if (trimmedParagraph.nodes.length > 0) {
if (this._hangingParagraph) {
// If it's a hanging paragraph, then don't skip a line
this._hangingParagraph = false;
}
else {
this._ensureLineSkipped();
}
this._renderNodes(trimmedParagraph.nodes);
this._writeNewline();
}
break;
case DocNode_1.DocNodeKind.ParamBlock:
const docParamBlock = docNode;
this._ensureLineSkipped();
this._renderNode(docParamBlock.blockTag);
this._writeContent(' ');
this._writeContent(docParamBlock.parameterName);
this._writeContent(' - ');
this._hangingParagraph = true;
this._renderNode(docParamBlock.content);
this._hangingParagraph = false;
break;
case DocNode_1.DocNodeKind.ParamCollection:
const docParamCollection = docNode;
this._renderNodes(docParamCollection.blocks);
break;
case DocNode_1.DocNodeKind.PlainText:
const docPlainText = docNode;
this._writeContent(docPlainText.text);
break;
}
}
_renderInlineTag(docInlineTagBase, writeInlineTagContent) {
this._writeContent('{');
this._writeContent(docInlineTagBase.tagName);
writeInlineTagContent();
this._writeContent('}');
}
_renderNodes(docNodes) {
for (const docNode of docNodes) {
this._renderNode(docNode);
}
}
// Calls _writeNewline() only if we're not already at the start of a new line
_ensureAtStartOfLine() {
if (this._lineState === LineState.MiddleOfLine) {
this._writeNewline();
}
}
// Calls _writeNewline() if needed to ensure that we have skipped at least one line
_ensureLineSkipped() {
this._ensureAtStartOfLine();
if (this._previousLineHadContent) {
this._writeNewline();
}
}
// Writes literal text content. If it contains newlines, they will automatically be converted to
// _writeNewline() calls, to ensure that "*" is written at the start of each line.
_writeContent(content) {
if (content === undefined || content.length === 0) {
return;
}
const splitLines = content.split(/\r?\n/g);
if (splitLines.length > 1) {
let firstLine = true;
for (const line of splitLines) {
if (firstLine) {
firstLine = false;
}
else {
this._writeNewline();
}
this._writeContent(line);
}
return;
}
if (this._lineState === LineState.Closed) {
if (this._emitCommentFraming) {
this._output.append('/**' + this.eol + ' *');
}
this._lineState = LineState.StartOfLine;
}
if (this._lineState === LineState.StartOfLine) {
if (this._emitCommentFraming) {
this._output.append(' ');
}
}
this._output.append(content);
this._lineState = LineState.MiddleOfLine;
this._previousLineHadContent = true;
}
// Starts a new line, and inserts "/**" or "*" as appropriate.
_writeNewline() {
if (this._lineState === LineState.Closed) {
if (this._emitCommentFraming) {
this._output.append('/**' + this.eol + ' *');
}
this._lineState = LineState.StartOfLine;
}
this._previousLineHadContent = this._lineState === LineState.MiddleOfLine;
if (this._emitCommentFraming) {
this._output.append(this.eol + ' *');
}
else {
this._output.append(this.eol);
}
this._lineState = LineState.StartOfLine;
this._hangingParagraph = false;
}
// Closes the comment, adding the final "*/" delimiter
_writeEnd() {
if (this._lineState === LineState.MiddleOfLine) {
if (this._emitCommentFraming) {
this._writeNewline();
}
}
if (this._lineState !== LineState.Closed) {
if (this._emitCommentFraming) {
this._output.append('/' + this.eol);
}
this._lineState = LineState.Closed;
}
}
}
exports.TSDocEmitter = TSDocEmitter;
//# sourceMappingURL=TSDocEmitter.js.map

File diff suppressed because one or more lines are too long

63
node_modules/@microsoft/tsdoc/lib-commonjs/index.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocNodeTransforms = exports.TSDocParser = exports.TSDocMessageId = exports.TokenSequence = exports.TokenKind = exports.Token = exports.TextRange = exports.ParserMessageLog = exports.ParserMessage = exports.ParserContext = exports.TSDocEmitter = exports.StringBuilder = exports.PlainTextEmitter = exports.ModifierTagSet = exports.StandardModifierTagSet = exports.Standardization = exports.StandardTags = exports.TSDocValidationConfiguration = exports.TSDocTagDefinition = exports.TSDocTagSyntaxKind = exports.TSDocConfiguration = exports.DocNodeManager = void 0;
var DocNodeManager_1 = require("./configuration/DocNodeManager");
Object.defineProperty(exports, "DocNodeManager", { enumerable: true, get: function () { return DocNodeManager_1.DocNodeManager; } });
var TSDocConfiguration_1 = require("./configuration/TSDocConfiguration");
Object.defineProperty(exports, "TSDocConfiguration", { enumerable: true, get: function () { return TSDocConfiguration_1.TSDocConfiguration; } });
var TSDocTagDefinition_1 = require("./configuration/TSDocTagDefinition");
Object.defineProperty(exports, "TSDocTagSyntaxKind", { enumerable: true, get: function () { return TSDocTagDefinition_1.TSDocTagSyntaxKind; } });
Object.defineProperty(exports, "TSDocTagDefinition", { enumerable: true, get: function () { return TSDocTagDefinition_1.TSDocTagDefinition; } });
var TSDocValidationConfiguration_1 = require("./configuration/TSDocValidationConfiguration");
Object.defineProperty(exports, "TSDocValidationConfiguration", { enumerable: true, get: function () { return TSDocValidationConfiguration_1.TSDocValidationConfiguration; } });
var StandardTags_1 = require("./details/StandardTags");
Object.defineProperty(exports, "StandardTags", { enumerable: true, get: function () { return StandardTags_1.StandardTags; } });
var Standardization_1 = require("./details/Standardization");
Object.defineProperty(exports, "Standardization", { enumerable: true, get: function () { return Standardization_1.Standardization; } });
var StandardModifierTagSet_1 = require("./details/StandardModifierTagSet");
Object.defineProperty(exports, "StandardModifierTagSet", { enumerable: true, get: function () { return StandardModifierTagSet_1.StandardModifierTagSet; } });
var ModifierTagSet_1 = require("./details/ModifierTagSet");
Object.defineProperty(exports, "ModifierTagSet", { enumerable: true, get: function () { return ModifierTagSet_1.ModifierTagSet; } });
var PlainTextEmitter_1 = require("./emitters/PlainTextEmitter");
Object.defineProperty(exports, "PlainTextEmitter", { enumerable: true, get: function () { return PlainTextEmitter_1.PlainTextEmitter; } });
var StringBuilder_1 = require("./emitters/StringBuilder");
Object.defineProperty(exports, "StringBuilder", { enumerable: true, get: function () { return StringBuilder_1.StringBuilder; } });
var TSDocEmitter_1 = require("./emitters/TSDocEmitter");
Object.defineProperty(exports, "TSDocEmitter", { enumerable: true, get: function () { return TSDocEmitter_1.TSDocEmitter; } });
__exportStar(require("./nodes"), exports);
var ParserContext_1 = require("./parser/ParserContext");
Object.defineProperty(exports, "ParserContext", { enumerable: true, get: function () { return ParserContext_1.ParserContext; } });
var ParserMessage_1 = require("./parser/ParserMessage");
Object.defineProperty(exports, "ParserMessage", { enumerable: true, get: function () { return ParserMessage_1.ParserMessage; } });
var ParserMessageLog_1 = require("./parser/ParserMessageLog");
Object.defineProperty(exports, "ParserMessageLog", { enumerable: true, get: function () { return ParserMessageLog_1.ParserMessageLog; } });
var TextRange_1 = require("./parser/TextRange");
Object.defineProperty(exports, "TextRange", { enumerable: true, get: function () { return TextRange_1.TextRange; } });
var Token_1 = require("./parser/Token");
Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return Token_1.Token; } });
Object.defineProperty(exports, "TokenKind", { enumerable: true, get: function () { return Token_1.TokenKind; } });
var TokenSequence_1 = require("./parser/TokenSequence");
Object.defineProperty(exports, "TokenSequence", { enumerable: true, get: function () { return TokenSequence_1.TokenSequence; } });
var TSDocMessageId_1 = require("./parser/TSDocMessageId");
Object.defineProperty(exports, "TSDocMessageId", { enumerable: true, get: function () { return TSDocMessageId_1.TSDocMessageId; } });
var TSDocParser_1 = require("./parser/TSDocParser");
Object.defineProperty(exports, "TSDocParser", { enumerable: true, get: function () { return TSDocParser_1.TSDocParser; } });
var DocNodeTransforms_1 = require("./transforms/DocNodeTransforms");
Object.defineProperty(exports, "DocNodeTransforms", { enumerable: true, get: function () { return DocNodeTransforms_1.DocNodeTransforms; } });
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;AAE3D,iEAIwC;AAHtC,gHAAA,cAAc,OAAA;AAIhB,yEAAwE;AAA/D,wHAAA,kBAAkB,OAAA;AAC3B,yEAI4C;AAF1C,wHAAA,kBAAkB,OAAA;AAClB,wHAAA,kBAAkB,OAAA;AAEpB,6FAA4F;AAAnF,4IAAA,4BAA4B,OAAA;AAErC,uDAAsD;AAA7C,4GAAA,YAAY,OAAA;AACrB,6DAA4D;AAAnD,kHAAA,eAAe,OAAA;AACxB,2EAA0E;AAAjE,gIAAA,sBAAsB,OAAA;AAC/B,2DAA0D;AAAjD,gHAAA,cAAc,OAAA;AAEvB,gEAA+D;AAAtD,oHAAA,gBAAgB,OAAA;AACzB,0DAA8E;AAArE,8GAAA,aAAa,OAAA;AACtB,wDAAuD;AAA9C,4GAAA,YAAY,OAAA;AAErB,0CAAwB;AAExB,wDAAuD;AAA9C,8GAAA,aAAa,OAAA;AACtB,wDAAsF;AAA7E,8GAAA,aAAa,OAAA;AACtB,8DAA6D;AAApD,oHAAA,gBAAgB,OAAA;AACzB,gDAAmE;AAA1D,sGAAA,SAAS,OAAA;AAClB,wCAAkD;AAAzC,8FAAA,KAAK,OAAA;AAAE,kGAAA,SAAS,OAAA;AACzB,wDAAsF;AAA7E,8GAAA,aAAa,OAAA;AACtB,0DAAyD;AAAhD,gHAAA,cAAc,OAAA;AACvB,oDAAmD;AAA1C,0GAAA,WAAW,OAAA;AAEpB,oEAAmE;AAA1D,sHAAA,iBAAiB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nexport {\r\n DocNodeManager,\r\n type IDocNodeDefinition,\r\n type DocNodeConstructor\r\n} from './configuration/DocNodeManager';\r\nexport { TSDocConfiguration } from './configuration/TSDocConfiguration';\r\nexport {\r\n type ITSDocTagDefinitionParameters,\r\n TSDocTagSyntaxKind,\r\n TSDocTagDefinition\r\n} from './configuration/TSDocTagDefinition';\r\nexport { TSDocValidationConfiguration } from './configuration/TSDocValidationConfiguration';\r\n\r\nexport { StandardTags } from './details/StandardTags';\r\nexport { Standardization } from './details/Standardization';\r\nexport { StandardModifierTagSet } from './details/StandardModifierTagSet';\r\nexport { ModifierTagSet } from './details/ModifierTagSet';\r\n\r\nexport { PlainTextEmitter } from './emitters/PlainTextEmitter';\r\nexport { StringBuilder, type IStringBuilder } from './emitters/StringBuilder';\r\nexport { TSDocEmitter } from './emitters/TSDocEmitter';\r\n\r\nexport * from './nodes';\r\n\r\nexport { ParserContext } from './parser/ParserContext';\r\nexport { ParserMessage, type IParserMessageParameters } from './parser/ParserMessage';\r\nexport { ParserMessageLog } from './parser/ParserMessageLog';\r\nexport { TextRange, type ITextLocation } from './parser/TextRange';\r\nexport { Token, TokenKind } from './parser/Token';\r\nexport { TokenSequence, type ITokenSequenceParameters } from './parser/TokenSequence';\r\nexport { TSDocMessageId } from './parser/TSDocMessageId';\r\nexport { TSDocParser } from './parser/TSDocParser';\r\n\r\nexport { DocNodeTransforms } from './transforms/DocNodeTransforms';\r\n"]}

View File

@@ -0,0 +1,92 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BuiltInDocNodes = void 0;
const DocNode_1 = require("./DocNode");
const nodes = __importStar(require(".."));
class BuiltInDocNodes {
static register(configuration) {
const docNodeManager = configuration.docNodeManager;
docNodeManager.registerDocNodes('@microsoft/tsdoc', [
{ docNodeKind: DocNode_1.DocNodeKind.Block, constructor: nodes.DocBlock },
{ docNodeKind: DocNode_1.DocNodeKind.BlockTag, constructor: nodes.DocBlockTag },
{ docNodeKind: DocNode_1.DocNodeKind.CodeSpan, constructor: nodes.DocCodeSpan },
{ docNodeKind: DocNode_1.DocNodeKind.Comment, constructor: nodes.DocComment },
{ docNodeKind: DocNode_1.DocNodeKind.DeclarationReference, constructor: nodes.DocDeclarationReference },
{ docNodeKind: DocNode_1.DocNodeKind.ErrorText, constructor: nodes.DocErrorText },
{ docNodeKind: DocNode_1.DocNodeKind.EscapedText, constructor: nodes.DocEscapedText },
{ docNodeKind: DocNode_1.DocNodeKind.Excerpt, constructor: nodes.DocExcerpt },
{ docNodeKind: DocNode_1.DocNodeKind.FencedCode, constructor: nodes.DocFencedCode },
{ docNodeKind: DocNode_1.DocNodeKind.HtmlAttribute, constructor: nodes.DocHtmlAttribute },
{ docNodeKind: DocNode_1.DocNodeKind.HtmlEndTag, constructor: nodes.DocHtmlEndTag },
{ docNodeKind: DocNode_1.DocNodeKind.HtmlStartTag, constructor: nodes.DocHtmlStartTag },
{ docNodeKind: DocNode_1.DocNodeKind.InheritDocTag, constructor: nodes.DocInheritDocTag },
{ docNodeKind: DocNode_1.DocNodeKind.InlineTag, constructor: nodes.DocInlineTag },
{ docNodeKind: DocNode_1.DocNodeKind.LinkTag, constructor: nodes.DocLinkTag },
{ docNodeKind: DocNode_1.DocNodeKind.MemberIdentifier, constructor: nodes.DocMemberIdentifier },
{ docNodeKind: DocNode_1.DocNodeKind.MemberReference, constructor: nodes.DocMemberReference },
{ docNodeKind: DocNode_1.DocNodeKind.MemberSelector, constructor: nodes.DocMemberSelector },
{ docNodeKind: DocNode_1.DocNodeKind.MemberSymbol, constructor: nodes.DocMemberSymbol },
{ docNodeKind: DocNode_1.DocNodeKind.Paragraph, constructor: nodes.DocParagraph },
{ docNodeKind: DocNode_1.DocNodeKind.ParamBlock, constructor: nodes.DocParamBlock },
{ docNodeKind: DocNode_1.DocNodeKind.ParamCollection, constructor: nodes.DocParamCollection },
{ docNodeKind: DocNode_1.DocNodeKind.PlainText, constructor: nodes.DocPlainText },
{ docNodeKind: DocNode_1.DocNodeKind.Section, constructor: nodes.DocSection },
{ docNodeKind: DocNode_1.DocNodeKind.SoftBreak, constructor: nodes.DocSoftBreak }
]);
docNodeManager.registerAllowableChildren(DocNode_1.DocNodeKind.Section, [
DocNode_1.DocNodeKind.FencedCode,
DocNode_1.DocNodeKind.Paragraph,
DocNode_1.DocNodeKind.HtmlStartTag,
DocNode_1.DocNodeKind.HtmlEndTag
]);
docNodeManager.registerAllowableChildren(DocNode_1.DocNodeKind.Paragraph, [
DocNode_1.DocNodeKind.BlockTag,
DocNode_1.DocNodeKind.CodeSpan,
DocNode_1.DocNodeKind.ErrorText,
DocNode_1.DocNodeKind.EscapedText,
DocNode_1.DocNodeKind.HtmlStartTag,
DocNode_1.DocNodeKind.HtmlEndTag,
DocNode_1.DocNodeKind.InlineTag,
DocNode_1.DocNodeKind.LinkTag,
DocNode_1.DocNodeKind.PlainText,
DocNode_1.DocNodeKind.SoftBreak
]);
}
}
exports.BuiltInDocNodes = BuiltInDocNodes;
//# sourceMappingURL=BuiltInDocNodes.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,44 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocBlock = void 0;
const DocNode_1 = require("./DocNode");
const DocSection_1 = require("./DocSection");
/**
* Represents a section that is introduced by a TSDoc block tag.
* For example, an `@example` block.
*/
class DocBlock extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
this._blockTag = parameters.blockTag;
this._content = new DocSection_1.DocSection({ configuration: this.configuration });
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.Block;
}
/**
* The TSDoc tag that introduces this section.
*/
get blockTag() {
return this._blockTag;
}
/**
* The TSDoc tag that introduces this section.
*/
get content() {
return this._content;
}
/** @override */
onGetChildNodes() {
return [this.blockTag, this._content];
}
}
exports.DocBlock = DocBlock;
//# sourceMappingURL=DocBlock.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocBlock.js","sourceRoot":"","sources":["../../src/nodes/DocBlock.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAyG;AACzG,6CAA0C;AAiB1C;;;GAGG;AACH,MAAa,QAAS,SAAQ,iBAAO;IAInC;;;OAGG;IACH,YAAmB,UAA2D;QAC5E,KAAK,CAAC,UAAU,CAAC,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAU,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,gBAAgB;IACN,eAAe;QACvB,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;CACF;AArCD,4BAqCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, DocNode, type IDocNodeParameters, type IDocNodeParsedParameters } from './DocNode';\r\nimport { DocSection } from './DocSection';\r\nimport type { DocBlockTag } from './DocBlockTag';\r\n\r\n/**\r\n * Constructor parameters for {@link DocBlock}.\r\n */\r\nexport interface IDocBlockParameters extends IDocNodeParameters {\r\n blockTag: DocBlockTag;\r\n}\r\n\r\n/**\r\n * Constructor parameters for {@link DocBlock}.\r\n */\r\nexport interface IDocBlockParsedParameters extends IDocNodeParsedParameters {\r\n blockTag: DocBlockTag;\r\n}\r\n\r\n/**\r\n * Represents a section that is introduced by a TSDoc block tag.\r\n * For example, an `@example` block.\r\n */\r\nexport class DocBlock extends DocNode {\r\n private readonly _blockTag: DocBlockTag;\r\n private readonly _content: DocSection;\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocBlockParameters | IDocBlockParsedParameters) {\r\n super(parameters);\r\n this._blockTag = parameters.blockTag;\r\n this._content = new DocSection({ configuration: this.configuration });\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.Block;\r\n }\r\n\r\n /**\r\n * The TSDoc tag that introduces this section.\r\n */\r\n public get blockTag(): DocBlockTag {\r\n return this._blockTag;\r\n }\r\n\r\n /**\r\n * The TSDoc tag that introduces this section.\r\n */\r\n public get content(): DocSection {\r\n return this._content;\r\n }\r\n\r\n /** @override */\r\n protected onGetChildNodes(): ReadonlyArray<DocNode | undefined> {\r\n return [this.blockTag, this._content];\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,60 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocBlockTag = void 0;
const DocNode_1 = require("./DocNode");
const StringChecks_1 = require("../parser/StringChecks");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* Represents a TSDoc block tag such as `@param` or `@public`.
*/
class DocBlockTag extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
StringChecks_1.StringChecks.validateTSDocTagName(parameters.tagName);
this._tagName = parameters.tagName;
this._tagNameWithUpperCase = parameters.tagName.toUpperCase();
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
this._tagNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.BlockTag,
content: parameters.tagNameExcerpt
});
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.BlockTag;
}
/**
* The TSDoc tag name. TSDoc tag names start with an at-sign (`@`) followed
* by ASCII letters using "camelCase" capitalization.
*/
get tagName() {
return this._tagName;
}
/**
* The TSDoc tag name in all capitals, which is used for performing
* case-insensitive comparisons or lookups.
*/
get tagNameWithUpperCase() {
return this._tagNameWithUpperCase;
}
/** @override */
onGetChildNodes() {
return [this._tagNameExcerpt];
}
getTokenSequence() {
if (!this._tagNameExcerpt) {
throw new Error('DocBlockTag.getTokenSequence() failed because this object did not originate from a parsed input');
}
return this._tagNameExcerpt.content;
}
}
exports.DocBlockTag = DocBlockTag;
//# sourceMappingURL=DocBlockTag.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocBlockTag.js","sourceRoot":"","sources":["../../src/nodes/DocBlockTag.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAyG;AACzG,yDAAsD;AAEtD,6CAAuD;AAiBvD;;GAEG;AACH,MAAa,WAAY,SAAQ,iBAAO;IAKtC;;;OAGG;IACH,YAAmB,UAAiE;QAClF,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,2BAAY,CAAC,oBAAoB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC;QACnC,IAAI,CAAC,qBAAqB,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAE9D,IAAI,iBAAO,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,eAAe,GAAG,IAAI,uBAAU,CAAC;gBACpC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,WAAW,EAAE,wBAAW,CAAC,QAAQ;gBACjC,OAAO,EAAE,UAAU,CAAC,cAAc;aACnC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,IAAW,oBAAoB;QAC7B,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;IAED,gBAAgB;IACN,eAAe;QACvB,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAChC,CAAC;IAEM,gBAAgB;QACrB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACb,iGAAiG,CAClG,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;IACtC,CAAC;CACF;AA3DD,kCA2DC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, DocNode, type IDocNodeParameters, type IDocNodeParsedParameters } from './DocNode';\r\nimport { StringChecks } from '../parser/StringChecks';\r\nimport type { TokenSequence } from '../parser/TokenSequence';\r\nimport { DocExcerpt, ExcerptKind } from './DocExcerpt';\r\n\r\n/**\r\n * Constructor parameters for {@link DocBlockTag}.\r\n */\r\nexport interface IDocBlockTagParameters extends IDocNodeParameters {\r\n tagName: string;\r\n}\r\n\r\n/**\r\n * Constructor parameters for {@link DocBlockTag}.\r\n */\r\nexport interface IDocBlockTagParsedParameters extends IDocNodeParsedParameters {\r\n tagName: string;\r\n tagNameExcerpt: TokenSequence;\r\n}\r\n\r\n/**\r\n * Represents a TSDoc block tag such as `@param` or `@public`.\r\n */\r\nexport class DocBlockTag extends DocNode {\r\n private readonly _tagName: string;\r\n private readonly _tagNameWithUpperCase: string;\r\n private readonly _tagNameExcerpt: DocExcerpt | undefined;\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocBlockTagParameters | IDocBlockTagParsedParameters) {\r\n super(parameters);\r\n\r\n StringChecks.validateTSDocTagName(parameters.tagName);\r\n this._tagName = parameters.tagName;\r\n this._tagNameWithUpperCase = parameters.tagName.toUpperCase();\r\n\r\n if (DocNode.isParsedParameters(parameters)) {\r\n this._tagNameExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.BlockTag,\r\n content: parameters.tagNameExcerpt\r\n });\r\n }\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.BlockTag;\r\n }\r\n\r\n /**\r\n * The TSDoc tag name. TSDoc tag names start with an at-sign (`@`) followed\r\n * by ASCII letters using \"camelCase\" capitalization.\r\n */\r\n public get tagName(): string {\r\n return this._tagName;\r\n }\r\n\r\n /**\r\n * The TSDoc tag name in all capitals, which is used for performing\r\n * case-insensitive comparisons or lookups.\r\n */\r\n public get tagNameWithUpperCase(): string {\r\n return this._tagNameWithUpperCase;\r\n }\r\n\r\n /** @override */\r\n protected onGetChildNodes(): ReadonlyArray<DocNode | undefined> {\r\n return [this._tagNameExcerpt];\r\n }\r\n\r\n public getTokenSequence(): TokenSequence {\r\n if (!this._tagNameExcerpt) {\r\n throw new Error(\r\n 'DocBlockTag.getTokenSequence() failed because this object did not originate from a parsed input'\r\n );\r\n }\r\n return this._tagNameExcerpt.content;\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,59 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocCodeSpan = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* Represents CommonMark-style code span, i.e. code surrounded by
* backtick characters.
*/
class DocCodeSpan extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
this._openingDelimiterExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.CodeSpan_OpeningDelimiter,
content: parameters.openingDelimiterExcerpt
});
this._codeExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.CodeSpan_Code,
content: parameters.codeExcerpt
});
this._closingDelimiterExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.CodeSpan_ClosingDelimiter,
content: parameters.closingDelimiterExcerpt
});
}
else {
this._code = parameters.code;
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.CodeSpan;
}
/**
* The text that should be rendered as code, excluding the backtick delimiters.
*/
get code() {
if (this._code === undefined) {
this._code = this._codeExcerpt.content.toString();
}
return this._code;
}
/** @override */
onGetChildNodes() {
return [this._openingDelimiterExcerpt, this._codeExcerpt, this._closingDelimiterExcerpt];
}
}
exports.DocCodeSpan = DocCodeSpan;
//# sourceMappingURL=DocCodeSpan.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocCodeSpan.js","sourceRoot":"","sources":["../../src/nodes/DocCodeSpan.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAyG;AAEzG,6CAAuD;AAoBvD;;;GAGG;AACH,MAAa,WAAY,SAAQ,iBAAO;IAWtC;;;OAGG;IACH,YAAmB,UAAiE;QAClF,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,iBAAO,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,wBAAwB,GAAG,IAAI,uBAAU,CAAC;gBAC7C,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,WAAW,EAAE,wBAAW,CAAC,yBAAyB;gBAClD,OAAO,EAAE,UAAU,CAAC,uBAAuB;aAC5C,CAAC,CAAC;YACH,IAAI,CAAC,YAAY,GAAG,IAAI,uBAAU,CAAC;gBACjC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,WAAW,EAAE,wBAAW,CAAC,aAAa;gBACtC,OAAO,EAAE,UAAU,CAAC,WAAW;aAChC,CAAC,CAAC;YACH,IAAI,CAAC,wBAAwB,GAAG,IAAI,uBAAU,CAAC;gBAC7C,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,WAAW,EAAE,wBAAW,CAAC,yBAAyB;gBAClD,OAAO,EAAE,UAAU,CAAC,uBAAuB;aAC5C,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACb,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrD,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,gBAAgB;IACN,eAAe;QACvB,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAC3F,CAAC;CACF;AA1DD,kCA0DC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, type IDocNodeParameters, DocNode, type IDocNodeParsedParameters } from './DocNode';\r\nimport type { TokenSequence } from '../parser/TokenSequence';\r\nimport { DocExcerpt, ExcerptKind } from './DocExcerpt';\r\n\r\n/**\r\n * Constructor parameters for {@link DocCodeSpan}.\r\n */\r\nexport interface IDocCodeSpanParameters extends IDocNodeParameters {\r\n code: string;\r\n}\r\n\r\n/**\r\n * Constructor parameters for {@link DocCodeSpan}.\r\n */\r\nexport interface IDocCodeSpanParsedParameters extends IDocNodeParsedParameters {\r\n openingDelimiterExcerpt: TokenSequence;\r\n\r\n codeExcerpt: TokenSequence;\r\n\r\n closingDelimiterExcerpt: TokenSequence;\r\n}\r\n\r\n/**\r\n * Represents CommonMark-style code span, i.e. code surrounded by\r\n * backtick characters.\r\n */\r\nexport class DocCodeSpan extends DocNode {\r\n // The opening ` delimiter\r\n private readonly _openingDelimiterExcerpt: DocExcerpt | undefined;\r\n\r\n // The code content\r\n private _code: string | undefined;\r\n private readonly _codeExcerpt: DocExcerpt | undefined;\r\n\r\n // The closing ` delimiter\r\n private readonly _closingDelimiterExcerpt: DocExcerpt | undefined;\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocCodeSpanParameters | IDocCodeSpanParsedParameters) {\r\n super(parameters);\r\n\r\n if (DocNode.isParsedParameters(parameters)) {\r\n this._openingDelimiterExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.CodeSpan_OpeningDelimiter,\r\n content: parameters.openingDelimiterExcerpt\r\n });\r\n this._codeExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.CodeSpan_Code,\r\n content: parameters.codeExcerpt\r\n });\r\n this._closingDelimiterExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.CodeSpan_ClosingDelimiter,\r\n content: parameters.closingDelimiterExcerpt\r\n });\r\n } else {\r\n this._code = parameters.code;\r\n }\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.CodeSpan;\r\n }\r\n\r\n /**\r\n * The text that should be rendered as code, excluding the backtick delimiters.\r\n */\r\n public get code(): string {\r\n if (this._code === undefined) {\r\n this._code = this._codeExcerpt!.content.toString();\r\n }\r\n return this._code;\r\n }\r\n\r\n /** @override */\r\n protected onGetChildNodes(): ReadonlyArray<DocNode | undefined> {\r\n return [this._openingDelimiterExcerpt, this._codeExcerpt, this._closingDelimiterExcerpt];\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,99 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocComment = void 0;
const DocNode_1 = require("./DocNode");
const DocSection_1 = require("./DocSection");
const StandardModifierTagSet_1 = require("../details/StandardModifierTagSet");
const StringBuilder_1 = require("../emitters/StringBuilder");
const TSDocEmitter_1 = require("../emitters/TSDocEmitter");
const DocParamCollection_1 = require("./DocParamCollection");
/**
* Represents an entire documentation comment conforming to the TSDoc structure.
* This is the root of the DocNode tree.
*/
class DocComment extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
this.summarySection = new DocSection_1.DocSection({ configuration: this.configuration });
this.remarksBlock = undefined;
this.privateRemarks = undefined;
this.deprecatedBlock = undefined;
this.params = new DocParamCollection_1.DocParamCollection({ configuration: this.configuration });
this.typeParams = new DocParamCollection_1.DocParamCollection({ configuration: this.configuration });
this.returnsBlock = undefined;
this.modifierTagSet = new StandardModifierTagSet_1.StandardModifierTagSet();
this._seeBlocks = [];
this._customBlocks = [];
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.Comment;
}
/**
* The collection of all `@see` DockBlockTag nodes belonging to this doc comment.
*/
get seeBlocks() {
return this._seeBlocks;
}
/**
* The collection of all DocBlock nodes belonging to this doc comment.
*/
get customBlocks() {
return this._customBlocks;
}
/**
* Append an item to the seeBlocks collection.
* @internal
*/
_appendSeeBlock(block) {
this._seeBlocks.push(block);
}
/**
* Append an item to the customBlocks collection.
*/
appendCustomBlock(block) {
this._customBlocks.push(block);
}
/** @override */
onGetChildNodes() {
return [
this.summarySection,
this.remarksBlock,
this.privateRemarks,
this.deprecatedBlock,
this.params.count > 0 ? this.params : undefined,
this.typeParams.count > 0 ? this.typeParams : undefined,
this.returnsBlock,
...this.customBlocks,
...this.seeBlocks,
this.inheritDocTag,
...this.modifierTagSet.nodes
];
}
/**
* Generates a doc comment corresponding to the `DocComment` tree. The output is in a normalized form,
* and may ignore formatting/spacing from the original input.
*
* @remarks
* After parsing a string, and possibly modifying the result, `emitAsTsdoc()` can be used to render the result
* as a doc comment in a normalized format. It can also be used to emit a `DocComment` tree that was constructed
* manually.
*
* This method is provided as convenience for simple use cases. To customize the output, or if you need
* to render into a `StringBuilder`, use the {@link TSDocEmitter} class instead.
*/
emitAsTsdoc() {
const stringBuilder = new StringBuilder_1.StringBuilder();
const emitter = new TSDocEmitter_1.TSDocEmitter();
emitter.renderComment(stringBuilder, this);
return stringBuilder.toString();
}
}
exports.DocComment = DocComment;
//# sourceMappingURL=DocComment.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,126 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocDeclarationReference = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
const StringBuilder_1 = require("../emitters/StringBuilder");
const TSDocEmitter_1 = require("../emitters/TSDocEmitter");
/**
* Represents a declaration reference.
*
* @remarks
* Declaration references are TSDoc expressions used by tags such as `{@link}`
* or `{@inheritDoc}` that need to refer to another declaration.
*/
class DocDeclarationReference extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
if (parameters.packageNameExcerpt) {
this._packageNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.DeclarationReference_PackageName,
content: parameters.packageNameExcerpt
});
}
if (parameters.importPathExcerpt) {
this._importPathExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.DeclarationReference_ImportPath,
content: parameters.importPathExcerpt
});
}
if (parameters.importHashExcerpt) {
this._importHashExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.DeclarationReference_ImportHash,
content: parameters.importHashExcerpt
});
}
if (parameters.spacingAfterImportHashExcerpt) {
this._spacingAfterImportHashExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterImportHashExcerpt
});
}
}
else {
this._packageName = parameters.packageName;
this._importPath = parameters.importPath;
}
this._memberReferences = [];
if (parameters.memberReferences) {
this._memberReferences.push(...parameters.memberReferences);
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.DeclarationReference;
}
/**
* The optional package name, which may optionally include an NPM scope.
*
* Example: `"@scope/my-package"`
*/
get packageName() {
if (this._packageName === undefined) {
if (this._packageNameExcerpt !== undefined) {
this._packageName = this._packageNameExcerpt.content.toString();
}
}
return this._packageName;
}
/**
* The optional import path. If a package name is provided, then if an import path is provided,
* the path must start with a "/" delimiter; otherwise paths are resolved relative to the source file
* containing the reference.
*
* Example: `"/path1/path2"`
* Example: `"./path1/path2"`
* Example: `"../path2/path2"`
*/
get importPath() {
if (this._importPath === undefined) {
if (this._importPathExcerpt !== undefined) {
this._importPath = this._importPathExcerpt.content.toString();
}
}
return this._importPath;
}
/**
* The chain of member references that indicate the declaration being referenced.
* If this list is empty, then either the packageName or importPath must be provided,
* because the reference refers to a module.
*/
get memberReferences() {
return this._memberReferences;
}
/**
* Generates the TSDoc representation of this declaration reference.
*/
emitAsTsdoc() {
const stringBuilder = new StringBuilder_1.StringBuilder();
const emitter = new TSDocEmitter_1.TSDocEmitter();
emitter.renderDeclarationReference(stringBuilder, this);
return stringBuilder.toString();
}
/** @override */
onGetChildNodes() {
return [
this._packageNameExcerpt,
this._importPathExcerpt,
this._importHashExcerpt,
this._spacingAfterImportHashExcerpt,
...this._memberReferences
];
}
}
exports.DocDeclarationReference = DocDeclarationReference;
//# sourceMappingURL=DocDeclarationReference.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,80 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocErrorText = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* Represents a span of text that contained invalid markup.
* The characters should be rendered as plain text.
*/
class DocErrorText extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
this._textExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.ErrorText,
content: parameters.textExcerpt
});
this._messageId = parameters.messageId;
this._errorMessage = parameters.errorMessage;
this._errorLocation = parameters.errorLocation;
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.ErrorText;
}
/**
* The characters that should be rendered as plain text because they
* could not be parsed successfully.
*/
get text() {
if (this._text === undefined) {
this._text = this._textExcerpt.content.toString();
}
return this._text;
}
get textExcerpt() {
if (this._textExcerpt) {
return this._textExcerpt.content;
}
else {
return undefined;
}
}
/**
* The TSDoc error message identifier.
*/
get messageId() {
return this._messageId;
}
/**
* A description of why the character could not be parsed.
*/
get errorMessage() {
return this._errorMessage;
}
/**
* The range of characters that caused the error. In general these may be
* somewhat farther ahead in the input stream from the DocErrorText node itself.
*
* @remarks
* For example, for the malformed HTML tag `<a href="123" @ /a>`, the DocErrorText node
* will correspond to the `<` character that looked like an HTML tag, whereas the
* error location might be the `@` character that caused the trouble.
*/
get errorLocation() {
return this._errorLocation;
}
/** @override */
onGetChildNodes() {
return [this._textExcerpt];
}
}
exports.DocErrorText = DocErrorText;
//# sourceMappingURL=DocErrorText.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocErrorText.js","sourceRoot":"","sources":["../../src/nodes/DocErrorText.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAgF;AAEhF,6CAAuD;AAcvD;;;GAGG;AACH,MAAa,YAAa,SAAQ,iBAAO;IAQvC;;;OAGG;IACH,YAAmB,UAAyC;QAC1D,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,CAAC,YAAY,GAAG,IAAI,uBAAU,CAAC;YACjC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,WAAW,EAAE,wBAAW,CAAC,SAAS;YAClC,OAAO,EAAE,UAAU,CAAC,WAAW;SAChC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,YAAY,CAAC;QAC7C,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,aAAa,CAAC;IACjD,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,IAAW,IAAI;QACb,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAW,WAAW;QACpB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;;;;;OAQG;IACH,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,gBAAgB;IACN,eAAe;QACvB,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7B,CAAC;CACF;AAjFD,oCAiFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, DocNode, type IDocNodeParsedParameters } from './DocNode';\r\nimport type { TokenSequence } from '../parser/TokenSequence';\r\nimport { DocExcerpt, ExcerptKind } from './DocExcerpt';\r\nimport type { TSDocMessageId } from '../parser/TSDocMessageId';\r\n\r\n/**\r\n * Constructor parameters for {@link DocErrorText}.\r\n */\r\nexport interface IDocErrorTextParsedParameters extends IDocNodeParsedParameters {\r\n textExcerpt: TokenSequence;\r\n\r\n messageId: TSDocMessageId;\r\n errorMessage: string;\r\n errorLocation: TokenSequence;\r\n}\r\n\r\n/**\r\n * Represents a span of text that contained invalid markup.\r\n * The characters should be rendered as plain text.\r\n */\r\nexport class DocErrorText extends DocNode {\r\n private _text: string | undefined;\r\n private readonly _textExcerpt: DocExcerpt;\r\n\r\n private readonly _messageId: TSDocMessageId;\r\n private readonly _errorMessage: string;\r\n private readonly _errorLocation: TokenSequence;\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocErrorTextParsedParameters) {\r\n super(parameters);\r\n\r\n this._textExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.ErrorText,\r\n content: parameters.textExcerpt\r\n });\r\n\r\n this._messageId = parameters.messageId;\r\n this._errorMessage = parameters.errorMessage;\r\n this._errorLocation = parameters.errorLocation;\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.ErrorText;\r\n }\r\n\r\n /**\r\n * The characters that should be rendered as plain text because they\r\n * could not be parsed successfully.\r\n */\r\n public get text(): string {\r\n if (this._text === undefined) {\r\n this._text = this._textExcerpt.content.toString();\r\n }\r\n return this._text;\r\n }\r\n\r\n public get textExcerpt(): TokenSequence | undefined {\r\n if (this._textExcerpt) {\r\n return this._textExcerpt.content;\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n\r\n /**\r\n * The TSDoc error message identifier.\r\n */\r\n public get messageId(): TSDocMessageId {\r\n return this._messageId;\r\n }\r\n\r\n /**\r\n * A description of why the character could not be parsed.\r\n */\r\n public get errorMessage(): string {\r\n return this._errorMessage;\r\n }\r\n\r\n /**\r\n * The range of characters that caused the error. In general these may be\r\n * somewhat farther ahead in the input stream from the DocErrorText node itself.\r\n *\r\n * @remarks\r\n * For example, for the malformed HTML tag `<a href=\"123\" @ /a>`, the DocErrorText node\r\n * will correspond to the `<` character that looked like an HTML tag, whereas the\r\n * error location might be the `@` character that caused the trouble.\r\n */\r\n public get errorLocation(): TokenSequence {\r\n return this._errorLocation;\r\n }\r\n\r\n /** @override */\r\n protected onGetChildNodes(): ReadonlyArray<DocNode | undefined> {\r\n return [this._textExcerpt];\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,71 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocEscapedText = exports.EscapeStyle = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* The style of escaping to be used with DocEscapedText.
*/
var EscapeStyle;
(function (EscapeStyle) {
/**
* Use a backslash symbol to escape the character.
*/
EscapeStyle[EscapeStyle["CommonMarkBackslash"] = 0] = "CommonMarkBackslash";
})(EscapeStyle || (exports.EscapeStyle = EscapeStyle = {}));
/**
* Represents a text character that should be escaped as a TSDoc symbol.
* @remarks
* Note that renders will normally apply appropriate escaping when rendering
* DocPlainText in a format such as HTML or TSDoc. The DocEscapedText node
* forces a specific escaping that may not be the default.
*/
class DocEscapedText extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
this._escapeStyle = parameters.escapeStyle;
this._encodedTextExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.EscapedText,
content: parameters.encodedTextExcerpt
});
this._decodedText = parameters.decodedText;
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.EscapedText;
}
/**
* The style of escaping to be performed.
*/
get escapeStyle() {
return this._escapeStyle;
}
/**
* The text sequence including escapes.
*/
get encodedText() {
if (this._encodedText === undefined) {
this._encodedText = this._encodedTextExcerpt.content.toString();
}
return this._encodedText;
}
/**
* The text without escaping.
*/
get decodedText() {
return this._decodedText;
}
/** @override */
onGetChildNodes() {
return [this._encodedTextExcerpt];
}
}
exports.DocEscapedText = DocEscapedText;
//# sourceMappingURL=DocEscapedText.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocEscapedText.js","sourceRoot":"","sources":["../../src/nodes/DocEscapedText.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAgF;AAChF,6CAAuD;AAYvD;;GAEG;AACH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB;;OAEG;IACH,2EAAmB,CAAA;AACrB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED;;;;;;GAMG;AACH,MAAa,cAAe,SAAQ,iBAAO;IAQzC;;;OAGG;IACH,YAAmB,UAA2C;QAC5D,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC;QAE3C,IAAI,CAAC,mBAAmB,GAAG,IAAI,uBAAU,CAAC;YACxC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,WAAW,EAAE,wBAAW,CAAC,WAAW;YACpC,OAAO,EAAE,UAAU,CAAC,kBAAkB;SACvC,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC;IAC7C,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,WAAW,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QACpB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QAClE,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,gBAAgB;IACN,eAAe;QACvB,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACpC,CAAC;CACF;AA3DD,wCA2DC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, type IDocNodeParsedParameters, DocNode } from './DocNode';\r\nimport { DocExcerpt, ExcerptKind } from './DocExcerpt';\r\nimport type { TokenSequence } from '../parser/TokenSequence';\r\n\r\n/**\r\n * Constructor parameters for {@link DocEscapedText}.\r\n */\r\nexport interface IDocEscapedTextParsedParameters extends IDocNodeParsedParameters {\r\n escapeStyle: EscapeStyle;\r\n encodedTextExcerpt: TokenSequence;\r\n decodedText: string;\r\n}\r\n\r\n/**\r\n * The style of escaping to be used with DocEscapedText.\r\n */\r\nexport enum EscapeStyle {\r\n /**\r\n * Use a backslash symbol to escape the character.\r\n */\r\n CommonMarkBackslash\r\n}\r\n\r\n/**\r\n * Represents a text character that should be escaped as a TSDoc symbol.\r\n * @remarks\r\n * Note that renders will normally apply appropriate escaping when rendering\r\n * DocPlainText in a format such as HTML or TSDoc. The DocEscapedText node\r\n * forces a specific escaping that may not be the default.\r\n */\r\nexport class DocEscapedText extends DocNode {\r\n private readonly _escapeStyle: EscapeStyle;\r\n\r\n private _encodedText: string | undefined;\r\n private readonly _encodedTextExcerpt: DocExcerpt;\r\n\r\n private readonly _decodedText: string;\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocEscapedTextParsedParameters) {\r\n super(parameters);\r\n\r\n this._escapeStyle = parameters.escapeStyle;\r\n\r\n this._encodedTextExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.EscapedText,\r\n content: parameters.encodedTextExcerpt\r\n });\r\n\r\n this._decodedText = parameters.decodedText;\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.EscapedText;\r\n }\r\n\r\n /**\r\n * The style of escaping to be performed.\r\n */\r\n public get escapeStyle(): EscapeStyle {\r\n return this._escapeStyle;\r\n }\r\n\r\n /**\r\n * The text sequence including escapes.\r\n */\r\n public get encodedText(): string {\r\n if (this._encodedText === undefined) {\r\n this._encodedText = this._encodedTextExcerpt.content.toString();\r\n }\r\n return this._encodedText;\r\n }\r\n\r\n /**\r\n * The text without escaping.\r\n */\r\n public get decodedText(): string {\r\n return this._decodedText;\r\n }\r\n\r\n /** @override */\r\n protected onGetChildNodes(): ReadonlyArray<DocNode | undefined> {\r\n return [this._encodedTextExcerpt];\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,126 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocExcerpt = exports.ExcerptKind = void 0;
const DocNode_1 = require("./DocNode");
const Token_1 = require("../parser/Token");
/* eslint-disable @typescript-eslint/naming-convention */
/**
* Indicates the type of {@link DocExcerpt}.
*/
var ExcerptKind;
(function (ExcerptKind) {
ExcerptKind["Spacing"] = "Spacing";
ExcerptKind["BlockTag"] = "BlockTag";
ExcerptKind["CodeSpan_OpeningDelimiter"] = "CodeSpan_OpeningDelimiter";
ExcerptKind["CodeSpan_Code"] = "CodeSpan_Code";
ExcerptKind["CodeSpan_ClosingDelimiter"] = "CodeSpan_ClosingDelimiter";
ExcerptKind["DeclarationReference_PackageName"] = "DeclarationReference_PackageName";
ExcerptKind["DeclarationReference_ImportPath"] = "DeclarationReference_ImportPath";
ExcerptKind["DeclarationReference_ImportHash"] = "DeclarationReference_ImportHash";
/**
* Input characters that were reported as an error and do not appear to be part of a valid expression.
* A syntax highlighter might display them with an error color (e.g. red).
*/
ExcerptKind["ErrorText"] = "ErrorText";
/**
* Input characters that do not conform to the TSDoc specification, but were recognized by the parser, for example
* as a known JSDoc pattern. A syntax highlighter should not display them with an error color (e.g. red)
* because the error reporting may be suppressed for "lax" parsing of legacy source code.
*/
ExcerptKind["NonstandardText"] = "NonstandardText";
ExcerptKind["EscapedText"] = "EscapedText";
ExcerptKind["FencedCode_OpeningFence"] = "FencedCode_OpeningFence";
ExcerptKind["FencedCode_Language"] = "FencedCode_Language";
ExcerptKind["FencedCode_Code"] = "FencedCode_Code";
ExcerptKind["FencedCode_ClosingFence"] = "FencedCode_ClosingFence";
ExcerptKind["HtmlAttribute_Name"] = "HtmlAttribute_Name";
ExcerptKind["HtmlAttribute_Equals"] = "HtmlAttribute_Equals";
ExcerptKind["HtmlAttribute_Value"] = "HtmlAttribute_Value";
ExcerptKind["HtmlEndTag_OpeningDelimiter"] = "HtmlEndTag_OpeningDelimiter";
ExcerptKind["HtmlEndTag_Name"] = "HtmlEndTag_Name";
ExcerptKind["HtmlEndTag_ClosingDelimiter"] = "HtmlEndTag_ClosingDelimiter";
ExcerptKind["HtmlStartTag_OpeningDelimiter"] = "HtmlStartTag_OpeningDelimiter";
ExcerptKind["HtmlStartTag_Name"] = "HtmlStartTag_Name";
ExcerptKind["HtmlStartTag_ClosingDelimiter"] = "HtmlStartTag_ClosingDelimiter";
ExcerptKind["InlineTag_OpeningDelimiter"] = "InlineTag_OpeningDelimiter";
ExcerptKind["InlineTag_TagName"] = "InlineTag_TagName";
ExcerptKind["InlineTag_TagContent"] = "InlineTag_TagContent";
ExcerptKind["InlineTag_ClosingDelimiter"] = "InlineTag_ClosingDelimiter";
ExcerptKind["LinkTag_UrlDestination"] = "LinkTag_UrlDestination";
ExcerptKind["LinkTag_Pipe"] = "LinkTag_Pipe";
ExcerptKind["LinkTag_LinkText"] = "LinkTag_LinkText";
ExcerptKind["MemberIdentifier_LeftQuote"] = "MemberIdentifier_LeftQuote";
ExcerptKind["MemberIdentifier_Identifier"] = "MemberIdentifier_Identifier";
ExcerptKind["MemberIdentifier_RightQuote"] = "MemberIdentifier_RightQuote";
ExcerptKind["MemberReference_Dot"] = "MemberReference_Dot";
ExcerptKind["MemberReference_LeftParenthesis"] = "MemberReference_LeftParenthesis";
ExcerptKind["MemberReference_Colon"] = "MemberReference_Colon";
ExcerptKind["MemberReference_RightParenthesis"] = "MemberReference_RightParenthesis";
ExcerptKind["MemberSelector"] = "MemberSelector";
ExcerptKind["DocMemberSymbol_LeftBracket"] = "DocMemberSymbol_LeftBracket";
ExcerptKind["DocMemberSymbol_RightBracket"] = "DocMemberSymbol_RightBracket";
ExcerptKind["ParamBlock_ParameterName"] = "ParamBlock_ParameterName";
ExcerptKind["ParamBlock_Hyphen"] = "ParamBlock_Hyphen";
ExcerptKind["PlainText"] = "PlainText";
ExcerptKind["SoftBreak"] = "SoftBreak";
})(ExcerptKind || (exports.ExcerptKind = ExcerptKind = {}));
/**
* Represents a parsed token sequence.
*
* @remarks
* When a `DocNode` is created by parsing a doc comment, it will have `DocExcerpt` child nodes corresponding to
* the parsed syntax elements such as names, keywords, punctuation, and spaces. These excerpts indicate the original
* coordinates of the syntax element, and thus can be used for syntax highlighting and precise error reporting.
* They could also be used to rewrite specific words in a source file (e.g. renaming a parameter) without disturbing
* any other characters in the file.
*
* Every parsed character will correspond to at most one DocExcerpt object. In other words, excerpts never overlap.
* A given excerpt can span multiple comment lines, and it may contain gaps, for example to skip the `*` character
* that starts a new TSDoc comment line.
*/
class DocExcerpt extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (parameters.excerptKind === ExcerptKind.Spacing) {
for (const token of parameters.content.tokens) {
switch (token.kind) {
case Token_1.TokenKind.Spacing:
case Token_1.TokenKind.Newline:
case Token_1.TokenKind.EndOfInput:
break;
default:
throw new Error(`The excerptKind=Spacing but the range contains a non-whitespace token`);
}
}
}
this._excerptKind = parameters.excerptKind;
this._content = parameters.content;
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.Excerpt;
}
/**
* Indicates the kind of DocExcerpt.
*/
get excerptKind() {
return this._excerptKind;
}
/**
* The input token sequence corresponding to this excerpt.
* @remarks
* Note that a token sequence can span multiple input lines and may contain gaps, for example to skip the `*`
* character that starts a new TSDoc comment line.
*/
get content() {
return this._content;
}
}
exports.DocExcerpt = DocExcerpt;
//# sourceMappingURL=DocExcerpt.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,133 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocFencedCode = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* Represents CommonMark-style code fence, i.e. a block of program code that
* starts and ends with a line comprised of three backticks. The opening delimiter
* can also specify a language for a syntax highlighter.
*/
class DocFencedCode extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
this._openingFenceExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.FencedCode_OpeningFence,
content: parameters.openingFenceExcerpt
});
if (parameters.spacingAfterOpeningFenceExcerpt) {
this._spacingAfterOpeningFenceExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterOpeningFenceExcerpt
});
}
if (parameters.languageExcerpt) {
this._languageExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.FencedCode_Language,
content: parameters.languageExcerpt
});
}
if (parameters.spacingAfterLanguageExcerpt) {
this._spacingAfterLanguageExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterLanguageExcerpt
});
}
this._codeExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.FencedCode_Code,
content: parameters.codeExcerpt
});
if (parameters.spacingBeforeClosingFenceExcerpt) {
this._spacingBeforeClosingFenceExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingBeforeClosingFenceExcerpt
});
}
this._closingFenceExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.FencedCode_ClosingFence,
content: parameters.closingFenceExcerpt
});
if (parameters.spacingAfterClosingFenceExcerpt) {
this._spacingAfterClosingFenceExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterClosingFenceExcerpt
});
}
}
else {
this._code = parameters.code;
this._language = parameters.language;
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.FencedCode;
}
/**
* A name that can optionally be included after the opening code fence delimiter,
* on the same line as the three backticks. This name indicates the programming language
* for the code, which a syntax highlighter may use to style the code block.
*
* @remarks
* The TSDoc standard requires that the language "ts" should be interpreted to mean TypeScript.
* Other languages names may be supported, but this is implementation dependent.
*
* CommonMark refers to this field as the "info string".
*
* @privateRemarks
* Examples of language strings supported by GitHub flavored markdown:
* https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml
*/
get language() {
if (this._language === undefined) {
if (this._languageExcerpt !== undefined) {
this._language = this._languageExcerpt.content.toString();
}
else {
this._language = '';
}
}
return this._language;
}
/**
* The text that should be rendered as code.
*/
get code() {
if (this._code === undefined) {
if (this._codeExcerpt !== undefined) {
this._code = this._codeExcerpt.content.toString();
}
}
return this._code;
}
/** @override */
onGetChildNodes() {
return [
this._openingFenceExcerpt,
this._spacingAfterOpeningFenceExcerpt,
this._languageExcerpt,
this._spacingAfterLanguageExcerpt,
this._codeExcerpt,
this._spacingBeforeClosingFenceExcerpt,
this._closingFenceExcerpt,
this._spacingAfterClosingFenceExcerpt
];
}
}
exports.DocFencedCode = DocFencedCode;
//# sourceMappingURL=DocFencedCode.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,137 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocHtmlAttribute = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* Represents an HTML attribute inside a DocHtmlStartTag or DocHtmlEndTag.
*
* Example: `href="#"` inside `<a href="#" />`
*/
class DocHtmlAttribute extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
this._nameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.HtmlAttribute_Name,
content: parameters.nameExcerpt
});
if (parameters.spacingAfterNameExcerpt) {
this._spacingAfterNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterNameExcerpt
});
}
this._equalsExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.HtmlAttribute_Equals,
content: parameters.equalsExcerpt
});
if (parameters.spacingAfterEqualsExcerpt) {
this._spacingAfterEqualsExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterEqualsExcerpt
});
}
this._valueExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.HtmlAttribute_Value,
content: parameters.valueExcerpt
});
if (parameters.spacingAfterValueExcerpt) {
this._spacingAfterValueExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterValueExcerpt
});
}
}
else {
this._name = parameters.name;
this._spacingAfterName = parameters.spacingAfterName;
this._spacingAfterEquals = parameters.spacingAfterEquals;
this._value = parameters.value;
this._spacingAfterValue = parameters.spacingAfterValue;
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.HtmlAttribute;
}
/**
* The HTML attribute name.
*/
get name() {
if (this._name === undefined) {
this._name = this._nameExcerpt.content.toString();
}
return this._name;
}
/**
* Explicit whitespace that a renderer should insert after the HTML attribute name.
* If undefined, then the renderer can use a formatting rule to generate appropriate spacing.
*/
get spacingAfterName() {
if (this._spacingAfterName === undefined) {
if (this._spacingAfterNameExcerpt !== undefined) {
this._spacingAfterName = this._spacingAfterNameExcerpt.content.toString();
}
}
return this._spacingAfterName;
}
/**
* Explicit whitespace that a renderer should insert after the "=".
* If undefined, then the renderer can use a formatting rule to generate appropriate spacing.
*/
get spacingAfterEquals() {
if (this._spacingAfterEquals === undefined) {
if (this._spacingAfterEqualsExcerpt !== undefined) {
this._spacingAfterEquals = this._spacingAfterEqualsExcerpt.content.toString();
}
}
return this._spacingAfterEquals;
}
/**
* The HTML attribute value.
*/
get value() {
if (this._value === undefined) {
this._value = this._valueExcerpt.content.toString();
}
return this._value;
}
/**
* Explicit whitespace that a renderer should insert after the HTML attribute name.
* If undefined, then the renderer can use a formatting rule to generate appropriate spacing.
*/
get spacingAfterValue() {
if (this._spacingAfterValue === undefined) {
if (this._spacingAfterValueExcerpt !== undefined) {
this._spacingAfterValue = this._spacingAfterValueExcerpt.content.toString();
}
}
return this._spacingAfterValue;
}
/** @override */
onGetChildNodes() {
return [
this._nameExcerpt,
this._spacingAfterNameExcerpt,
this._equalsExcerpt,
this._spacingAfterEqualsExcerpt,
this._valueExcerpt,
this._spacingAfterValueExcerpt
];
}
}
exports.DocHtmlAttribute = DocHtmlAttribute;
//# sourceMappingURL=DocHtmlAttribute.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,82 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocHtmlEndTag = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
const StringBuilder_1 = require("../emitters/StringBuilder");
const TSDocEmitter_1 = require("../emitters/TSDocEmitter");
/**
* Represents an HTML end tag. Example: `</a>`
*/
class DocHtmlEndTag extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
this._openingDelimiterExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.HtmlEndTag_OpeningDelimiter,
content: parameters.openingDelimiterExcerpt
});
this._nameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.HtmlEndTag_Name,
content: parameters.nameExcerpt
});
if (parameters.spacingAfterNameExcerpt) {
this._spacingAfterNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterNameExcerpt
});
}
this._closingDelimiterExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.HtmlEndTag_ClosingDelimiter,
content: parameters.closingDelimiterExcerpt
});
}
else {
this._name = parameters.name;
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.HtmlEndTag;
}
/**
* The HTML element name.
*/
get name() {
if (this._name === undefined) {
this._name = this._nameExcerpt.content.toString();
}
return this._name;
}
/**
* Generates the HTML for this tag.
*/
emitAsHtml() {
// NOTE: Here we're assuming that the TSDoc representation for a tag is also a valid HTML expression.
const stringBuilder = new StringBuilder_1.StringBuilder();
const emitter = new TSDocEmitter_1.TSDocEmitter();
emitter.renderHtmlTag(stringBuilder, this);
return stringBuilder.toString();
}
/** @override */
onGetChildNodes() {
return [
this._openingDelimiterExcerpt,
this._nameExcerpt,
this._spacingAfterNameExcerpt,
this._closingDelimiterExcerpt
];
}
}
exports.DocHtmlEndTag = DocHtmlEndTag;
//# sourceMappingURL=DocHtmlEndTag.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,115 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocHtmlStartTag = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
const StringBuilder_1 = require("../emitters/StringBuilder");
const TSDocEmitter_1 = require("../emitters/TSDocEmitter");
/**
* Represents an HTML start tag, which may or may not be self-closing.
*
* Example: `<a href="#" />`
*/
class DocHtmlStartTag extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
this._openingDelimiterExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.HtmlStartTag_OpeningDelimiter,
content: parameters.openingDelimiterExcerpt
});
this._nameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.HtmlStartTag_Name,
content: parameters.nameExcerpt
});
if (parameters.spacingAfterNameExcerpt) {
this._spacingAfterNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterNameExcerpt
});
}
this._closingDelimiterExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.HtmlStartTag_ClosingDelimiter,
content: parameters.closingDelimiterExcerpt
});
}
else {
this._name = parameters.name;
this._spacingAfterName = parameters.spacingAfterName;
}
this._htmlAttributes = [];
if (parameters.htmlAttributes) {
this._htmlAttributes.push(...parameters.htmlAttributes);
}
this._selfClosingTag = !!parameters.selfClosingTag;
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.HtmlStartTag;
}
/**
* The HTML element name.
*/
get name() {
if (this._name === undefined) {
this._name = this._nameExcerpt.content.toString();
}
return this._name;
}
/**
* The HTML attributes belonging to this HTML element.
*/
get htmlAttributes() {
return this._htmlAttributes;
}
/**
* If true, then the HTML tag ends with `/>` instead of `>`.
*/
get selfClosingTag() {
return this._selfClosingTag;
}
/**
* Explicit whitespace that a renderer should insert after the HTML element name.
* If undefined, then the renderer can use a formatting rule to generate appropriate spacing.
*/
get spacingAfterName() {
if (this._spacingAfterName === undefined) {
if (this._spacingAfterNameExcerpt !== undefined) {
this._spacingAfterName = this._spacingAfterNameExcerpt.content.toString();
}
}
return this._spacingAfterName;
}
/**
* Generates the HTML for this tag.
*/
emitAsHtml() {
// NOTE: Here we're assuming that the TSDoc representation for a tag is also a valid HTML expression.
const stringBuilder = new StringBuilder_1.StringBuilder();
const emitter = new TSDocEmitter_1.TSDocEmitter();
emitter.renderHtmlTag(stringBuilder, this);
return stringBuilder.toString();
}
/** @override */
onGetChildNodes() {
return [
this._openingDelimiterExcerpt,
this._nameExcerpt,
this._spacingAfterNameExcerpt,
...this._htmlAttributes,
this._closingDelimiterExcerpt
];
}
}
exports.DocHtmlStartTag = DocHtmlStartTag;
//# sourceMappingURL=DocHtmlStartTag.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,41 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocInheritDocTag = void 0;
const DocNode_1 = require("./DocNode");
const DocInlineTagBase_1 = require("./DocInlineTagBase");
/**
* Represents an `{@inheritDoc}` tag.
*/
class DocInheritDocTag extends DocInlineTagBase_1.DocInlineTagBase {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (this.tagNameWithUpperCase !== '@INHERITDOC') {
throw new Error('DocInheritDocTag requires the tag name to be "{@inheritDoc}"');
}
this._declarationReference = parameters.declarationReference;
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.InheritDocTag;
}
/**
* The declaration that the documentation will be inherited from.
* If omitted, the documentation will be inherited from the parent class.
*/
get declarationReference() {
return this._declarationReference;
}
/** @override */
getChildNodesForContent() {
// abstract
return [this._declarationReference];
}
}
exports.DocInheritDocTag = DocInheritDocTag;
//# sourceMappingURL=DocInheritDocTag.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocInheritDocTag.js","sourceRoot":"","sources":["../../src/nodes/DocInheritDocTag.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAsD;AAEtD,yDAI4B;AAgB5B;;GAEG;AACH,MAAa,gBAAiB,SAAQ,mCAAgB;IAGpD;;;OAGG;IACH,YAAmB,UAA2E;QAC5F,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,IAAI,CAAC,oBAAoB,KAAK,aAAa,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QAClF,CAAC;QAED,IAAI,CAAC,qBAAqB,GAAG,UAAU,CAAC,oBAAoB,CAAC;IAC/D,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,aAAa,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,IAAW,oBAAoB;QAC7B,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;IAED,gBAAgB;IACN,uBAAuB;QAC/B,WAAW;QACX,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACtC,CAAC;CACF;AAnCD,4CAmCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, type DocNode } from './DocNode';\r\nimport type { DocDeclarationReference } from './DocDeclarationReference';\r\nimport {\r\n DocInlineTagBase,\r\n type IDocInlineTagBaseParsedParameters,\r\n type IDocInlineTagBaseParameters\r\n} from './DocInlineTagBase';\r\n\r\n/**\r\n * Constructor parameters for {@link DocInheritDocTag}.\r\n */\r\nexport interface IDocInheritDocTagParameters extends IDocInlineTagBaseParameters {\r\n declarationReference?: DocDeclarationReference;\r\n}\r\n\r\n/**\r\n * Constructor parameters for {@link DocInheritDocTag}.\r\n */\r\nexport interface IDocInheritDocTagParsedParameters extends IDocInlineTagBaseParsedParameters {\r\n declarationReference?: DocDeclarationReference;\r\n}\r\n\r\n/**\r\n * Represents an `{@inheritDoc}` tag.\r\n */\r\nexport class DocInheritDocTag extends DocInlineTagBase {\r\n private readonly _declarationReference: DocDeclarationReference | undefined;\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocInheritDocTagParameters | IDocInheritDocTagParsedParameters) {\r\n super(parameters);\r\n\r\n if (this.tagNameWithUpperCase !== '@INHERITDOC') {\r\n throw new Error('DocInheritDocTag requires the tag name to be \"{@inheritDoc}\"');\r\n }\r\n\r\n this._declarationReference = parameters.declarationReference;\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.InheritDocTag;\r\n }\r\n\r\n /**\r\n * The declaration that the documentation will be inherited from.\r\n * If omitted, the documentation will be inherited from the parent class.\r\n */\r\n public get declarationReference(): DocDeclarationReference | undefined {\r\n return this._declarationReference;\r\n }\r\n\r\n /** @override */\r\n protected getChildNodesForContent(): ReadonlyArray<DocNode | undefined> {\r\n // abstract\r\n return [this._declarationReference];\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,67 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocInlineTag = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
const DocInlineTagBase_1 = require("./DocInlineTagBase");
/**
* Represents a generic TSDoc inline tag, including custom tags.
*
* @remarks
* NOTE: Certain tags such as `{@link}` and `{@inheritDoc}` have specialized structures and parser rules,
* and thus are represented using {@link DocLinkTag} or {@link DocInheritDocTag} instead. However, if the
* specialized parser rule encounters a syntax error, but the outer framing is correct, then the parser constructs
* a generic `DocInlineTag` instead of `DocErrorText`. This means, for example, that it is possible sometimes for
* `DocInlineTag.tagName` to be `"@link"`.
*/
class DocInlineTag extends DocInlineTagBase_1.DocInlineTagBase {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
if (parameters.tagContentExcerpt) {
this._tagContentExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.InlineTag_TagContent,
content: parameters.tagContentExcerpt
});
}
}
else {
this._tagContent = parameters.tagContent;
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.InlineTag;
}
/**
* The tag content.
* @remarks
* For example, if the tag is `{@myTag x=12.34 y=56.78 }` then the tag content
* would be `x=12.34 y=56.78 `, including the trailing space but not the leading space.
*/
get tagContent() {
if (this._tagContent === undefined) {
if (this._tagContentExcerpt) {
this._tagContent = this._tagContentExcerpt.content.toString();
}
else {
return '';
}
}
return this._tagContent;
}
/** @override */
getChildNodesForContent() {
// abstract
return [this._tagContentExcerpt];
}
}
exports.DocInlineTag = DocInlineTag;
//# sourceMappingURL=DocInlineTag.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocInlineTag.js","sourceRoot":"","sources":["../../src/nodes/DocInlineTag.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAiD;AAEjD,6CAAuD;AACvD,yDAI4B;AAgB5B;;;;;;;;;GASG;AACH,MAAa,YAAa,SAAQ,mCAAgB;IAIhD;;;OAGG;IACH,YAAmB,UAAmE;QACpF,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,iBAAO,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3C,IAAI,UAAU,CAAC,iBAAiB,EAAE,CAAC;gBACjC,IAAI,CAAC,kBAAkB,GAAG,IAAI,uBAAU,CAAC;oBACvC,aAAa,EAAE,IAAI,CAAC,aAAa;oBACjC,WAAW,EAAE,wBAAW,CAAC,oBAAoB;oBAC7C,OAAO,EAAE,UAAU,CAAC,iBAAiB;iBACtC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;QAC3C,CAAC;IACH,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,IAAW,UAAU;QACnB,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACnC,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YAChE,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,gBAAgB;IACN,uBAAuB;QAC/B,WAAW;QACX,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACnC,CAAC;CACF;AAnDD,oCAmDC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, DocNode } from './DocNode';\r\nimport type { TokenSequence } from '../parser/TokenSequence';\r\nimport { DocExcerpt, ExcerptKind } from './DocExcerpt';\r\nimport {\r\n type IDocInlineTagBaseParameters,\r\n type IDocInlineTagBaseParsedParameters,\r\n DocInlineTagBase\r\n} from './DocInlineTagBase';\r\n\r\n/**\r\n * Constructor parameters for {@link DocInlineTag}.\r\n */\r\nexport interface IDocInlineTagParameters extends IDocInlineTagBaseParameters {\r\n tagContent: string;\r\n}\r\n\r\n/**\r\n * Constructor parameters for {@link DocInlineTag}.\r\n */\r\nexport interface IDocInlineTagParsedParameters extends IDocInlineTagBaseParsedParameters {\r\n tagContentExcerpt?: TokenSequence;\r\n}\r\n\r\n/**\r\n * Represents a generic TSDoc inline tag, including custom tags.\r\n *\r\n * @remarks\r\n * NOTE: Certain tags such as `{@link}` and `{@inheritDoc}` have specialized structures and parser rules,\r\n * and thus are represented using {@link DocLinkTag} or {@link DocInheritDocTag} instead. However, if the\r\n * specialized parser rule encounters a syntax error, but the outer framing is correct, then the parser constructs\r\n * a generic `DocInlineTag` instead of `DocErrorText`. This means, for example, that it is possible sometimes for\r\n * `DocInlineTag.tagName` to be `\"@link\"`.\r\n */\r\nexport class DocInlineTag extends DocInlineTagBase {\r\n private _tagContent: string | undefined;\r\n private readonly _tagContentExcerpt: DocExcerpt | undefined;\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocInlineTagParameters | IDocInlineTagParsedParameters) {\r\n super(parameters);\r\n\r\n if (DocNode.isParsedParameters(parameters)) {\r\n if (parameters.tagContentExcerpt) {\r\n this._tagContentExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.InlineTag_TagContent,\r\n content: parameters.tagContentExcerpt\r\n });\r\n }\r\n } else {\r\n this._tagContent = parameters.tagContent;\r\n }\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.InlineTag;\r\n }\r\n\r\n /**\r\n * The tag content.\r\n * @remarks\r\n * For example, if the tag is `{@myTag x=12.34 y=56.78 }` then the tag content\r\n * would be `x=12.34 y=56.78 `, including the trailing space but not the leading space.\r\n */\r\n public get tagContent(): string {\r\n if (this._tagContent === undefined) {\r\n if (this._tagContentExcerpt) {\r\n this._tagContent = this._tagContentExcerpt.content.toString();\r\n } else {\r\n return '';\r\n }\r\n }\r\n return this._tagContent;\r\n }\r\n\r\n /** @override */\r\n protected getChildNodesForContent(): ReadonlyArray<DocNode | undefined> {\r\n // abstract\r\n return [this._tagContentExcerpt];\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,77 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocInlineTagBase = void 0;
const DocNode_1 = require("./DocNode");
const StringChecks_1 = require("../parser/StringChecks");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* The abstract base class for {@link DocInlineTag}, {@link DocLinkTag}, and {@link DocInheritDocTag}.
*/
class DocInlineTagBase extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
StringChecks_1.StringChecks.validateTSDocTagName(parameters.tagName);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
this._openingDelimiterExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.InlineTag_OpeningDelimiter,
content: parameters.openingDelimiterExcerpt
});
this._tagNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.InlineTag_TagName,
content: parameters.tagNameExcerpt
});
if (parameters.spacingAfterTagNameExcerpt) {
this._spacingAfterTagNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterTagNameExcerpt
});
}
this._closingDelimiterExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.InlineTag_ClosingDelimiter,
content: parameters.closingDelimiterExcerpt
});
}
this._tagName = parameters.tagName;
this._tagNameWithUpperCase = parameters.tagName.toUpperCase();
}
/**
* The TSDoc tag name. TSDoc tag names start with an at-sign (`@`) followed
* by ASCII letters using "camelCase" capitalization.
*
* @remarks
* For example, if the inline tag is `{@link Guid.toString | the toString() method}`
* then the tag name would be `@link`.
*/
get tagName() {
return this._tagName;
}
/**
* The TSDoc tag name in all capitals, which is used for performing
* case-insensitive comparisons or lookups.
*/
get tagNameWithUpperCase() {
return this._tagNameWithUpperCase;
}
/** @override @sealed */
onGetChildNodes() {
return [
this._openingDelimiterExcerpt,
this._tagNameExcerpt,
this._spacingAfterTagNameExcerpt,
...this.getChildNodesForContent(),
this._closingDelimiterExcerpt
];
}
}
exports.DocInlineTagBase = DocInlineTagBase;
//# sourceMappingURL=DocInlineTagBase.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,150 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocLinkTag = void 0;
const DocNode_1 = require("./DocNode");
const DocInlineTagBase_1 = require("./DocInlineTagBase");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* Represents an `{@link}` tag.
*/
class DocLinkTag extends DocInlineTagBase_1.DocInlineTagBase {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (this.tagNameWithUpperCase !== '@LINK') {
throw new Error('DocLinkTag requires the tag name to be "{@link}"');
}
this._codeDestination = parameters.codeDestination;
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
if (parameters.codeDestination !== undefined && parameters.urlDestinationExcerpt !== undefined) {
throw new Error('Either the codeDestination or the urlDestination may be specified, but not both');
}
if (parameters.urlDestinationExcerpt) {
this._urlDestinationExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.LinkTag_UrlDestination,
content: parameters.urlDestinationExcerpt
});
}
if (parameters.spacingAfterDestinationExcerpt) {
this._spacingAfterDestinationExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterDestinationExcerpt
});
}
if (parameters.pipeExcerpt) {
this._pipeExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.LinkTag_Pipe,
content: parameters.pipeExcerpt
});
}
if (parameters.spacingAfterPipeExcerpt) {
this._spacingAfterPipeExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterPipeExcerpt
});
}
if (parameters.linkTextExcerpt) {
this._linkTextExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.LinkTag_LinkText,
content: parameters.linkTextExcerpt
});
}
if (parameters.spacingAfterLinkTextExcerpt) {
this._spacingAfterLinkTextExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterLinkTextExcerpt
});
}
}
else {
if (parameters.codeDestination !== undefined && parameters.urlDestination !== undefined) {
throw new Error('Either the codeDestination or the urlDestination may be specified, but not both');
}
this._urlDestination = parameters.urlDestination;
this._linkText = parameters.linkText;
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.LinkTag;
}
/**
* If the link tag refers to a declaration, this returns the declaration reference object;
* otherwise this property is undefined.
* @remarks
* Either the `codeDestination` or the `urlDestination` property will be defined, but never both.
*/
get codeDestination() {
return this._codeDestination;
}
/**
* If the link tag was an ordinary URI, this returns the URL string;
* otherwise this property is undefined.
* @remarks
* Either the `codeDestination` or the `urlDestination` property will be defined, but never both.
*/
get urlDestination() {
if (this._urlDestination === undefined) {
if (this._urlDestinationExcerpt !== undefined) {
this._urlDestination = this._urlDestinationExcerpt.content.toString();
}
}
return this._urlDestination;
}
/**
* An optional text string that is the hyperlink text. If omitted, the documentation
* renderer will use a default string based on the link itself (e.g. the URL text
* or the declaration identifier).
*
* @remarks
*
* In HTML, the hyperlink can include leading/trailing space characters around the link text.
* For example, this HTML will cause a web browser to `y` and also the space character before
* and after it:
*
* ```html
* x<a href="#Button"> y </a> z
* ```
*
* Unlike HTML, TSDoc trims leading/trailing spaces. For example, this TSDoc will be
* displayed `xy z` and underline only the `y` character:
*
* ```
* x{@link Button | y } z
* ```
*/
get linkText() {
if (this._linkText === undefined) {
if (this._linkTextExcerpt !== undefined) {
this._linkText = this._linkTextExcerpt.content.toString();
}
}
return this._linkText;
}
/** @override */
getChildNodesForContent() {
// abstract
return [
this._codeDestination,
this._urlDestinationExcerpt,
this._spacingAfterDestinationExcerpt,
this._pipeExcerpt,
this._spacingAfterPipeExcerpt,
this._linkTextExcerpt,
this._spacingAfterLinkTextExcerpt
];
}
}
exports.DocLinkTag = DocLinkTag;
//# sourceMappingURL=DocLinkTag.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,92 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocMemberIdentifier = void 0;
const DocNode_1 = require("./DocNode");
const StringChecks_1 = require("../parser/StringChecks");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* A member identifier is part of a {@link DocMemberReference}.
*/
class DocMemberIdentifier extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
if (parameters.leftQuoteExcerpt) {
this._leftQuoteExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.MemberIdentifier_LeftQuote,
content: parameters.leftQuoteExcerpt
});
}
this._identifierExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.MemberIdentifier_Identifier,
content: parameters.identifierExcerpt
});
if (parameters.rightQuoteExcerpt) {
this._rightQuoteExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.MemberIdentifier_RightQuote,
content: parameters.rightQuoteExcerpt
});
}
}
else {
this._identifier = parameters.identifier;
}
}
/**
* Tests whether the input string can be used without quotes as a member identifier in a declaration reference.
* If not, {@link DocMemberIdentifier.hasQuotes} will be required.
*
* @remarks
* In order to be used without quotes, the string must follow the identifier syntax for ECMAScript / TypeScript,
* and it must not be one of the reserved words used for system selectors (such as `instance`, `static`,
* `constructor`, etc).
*/
static isValidIdentifier(identifier) {
return !StringChecks_1.StringChecks.explainIfInvalidUnquotedMemberIdentifier(identifier);
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.MemberIdentifier;
}
/**
* The identifier string without any quote encoding.
*
* @remarks
* If the value is not a valid ECMAScript identifier, it will be quoted as a
* string literal during rendering.
*/
get identifier() {
if (this._identifier === undefined) {
this._identifier = this._identifierExcerpt.content.toString();
}
return this._identifier;
}
/**
* Returns true if the identifier will be rendered as a quoted string literal
* instead of as a programming language identifier. This is required if the
* `identifier` property is not a valid ECMAScript identifier.
*/
get hasQuotes() {
if (this._identifierExcerpt) {
return !!this._leftQuoteExcerpt;
}
else {
return !DocMemberIdentifier.isValidIdentifier(this.identifier);
}
}
/** @override */
onGetChildNodes() {
return [this._leftQuoteExcerpt, this._identifierExcerpt, this._rightQuoteExcerpt];
}
}
exports.DocMemberIdentifier = DocMemberIdentifier;
//# sourceMappingURL=DocMemberIdentifier.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,159 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocMemberReference = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* A {@link DocDeclarationReference | declaration reference} includes a chain of
* member references represented using `DocMemberReference` nodes.
*
* @remarks
* For example, `example-library#ui.controls.Button.(render:static)` is a
* declaration reference that contains three member references:
* `ui`, `.controls`, and `.Button`, and `.(render:static)`.
*/
class DocMemberReference extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
this._hasDot = !!parameters.dotExcerpt;
if (parameters.dotExcerpt) {
this._dotExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.MemberReference_Dot,
content: parameters.dotExcerpt
});
}
if (parameters.spacingAfterDotExcerpt) {
this._spacingAfterDotExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterDotExcerpt
});
}
if (parameters.leftParenthesisExcerpt) {
this._leftParenthesisExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.MemberReference_LeftParenthesis,
content: parameters.leftParenthesisExcerpt
});
}
if (parameters.spacingAfterLeftParenthesisExcerpt) {
this._spacingAfterLeftParenthesisExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterLeftParenthesisExcerpt
});
}
if (parameters.spacingAfterMemberExcerpt) {
this._spacingAfterMemberExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterMemberExcerpt
});
}
if (parameters.colonExcerpt) {
this._colonExcerpt = new DocExcerpt_1.DocExcerpt({
excerptKind: DocExcerpt_1.ExcerptKind.MemberReference_Colon,
configuration: this.configuration,
content: parameters.colonExcerpt
});
}
if (parameters.spacingAfterColonExcerpt) {
this._spacingAfterColonExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterColonExcerpt
});
}
if (parameters.spacingAfterSelectorExcerpt) {
this._spacingAfterSelectorExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterSelectorExcerpt
});
}
if (parameters.rightParenthesisExcerpt) {
this._rightParenthesisExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.MemberReference_RightParenthesis,
content: parameters.rightParenthesisExcerpt
});
}
if (parameters.spacingAfterRightParenthesisExcerpt) {
this._spacingAfterRightParenthesisExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterRightParenthesisExcerpt
});
}
}
else {
this._hasDot = parameters.hasDot;
}
this._memberIdentifier = parameters.memberIdentifier;
this._memberSymbol = parameters.memberSymbol;
this._selector = parameters.selector;
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.MemberReference;
}
/**
* True if this member reference is preceded by a dot (".") token.
* It should be false only for the first member in the chain.
*/
get hasDot() {
return this._hasDot;
}
/**
* The identifier for the referenced member.
* @remarks
* Either `memberIdentifier` or `memberSymbol` may be specified, but not both.
*/
get memberIdentifier() {
return this._memberIdentifier;
}
/**
* The ECMAScript 6 symbol expression, which may be used instead of an identifier
* to indicate the referenced member.
* @remarks
* Either `memberIdentifier` or `memberSymbol` may be specified, but not both.
*/
get memberSymbol() {
return this._memberSymbol;
}
/**
* A TSDoc selector, which may be optionally when the identifier or symbol is insufficient
* to unambiguously determine the referenced declaration.
*/
get selector() {
return this._selector;
}
/** @override */
onGetChildNodes() {
return [
this._dotExcerpt,
this._spacingAfterDotExcerpt,
this._leftParenthesisExcerpt,
this._spacingAfterLeftParenthesisExcerpt,
this._memberIdentifier,
this._memberSymbol,
this._spacingAfterMemberExcerpt,
this._colonExcerpt,
this._spacingAfterColonExcerpt,
this._selector,
this._spacingAfterSelectorExcerpt,
this._rightParenthesisExcerpt,
this._spacingAfterRightParenthesisExcerpt
];
}
}
exports.DocMemberReference = DocMemberReference;
//# sourceMappingURL=DocMemberReference.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,142 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocMemberSelector = exports.SelectorKind = void 0;
const DocNode_1 = require("./DocNode");
const StringChecks_1 = require("../parser/StringChecks");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* Kinds of TSDoc selectors.
*/
var SelectorKind;
(function (SelectorKind) {
/**
* Used in cases where the parser encounters a string that is incorrect but
* valid enough that a DocMemberSelector node was created.
*/
SelectorKind["Error"] = "error";
/**
* System selectors are always all lower-case and belong to a set of predefined label names.
*/
SelectorKind["System"] = "system";
/**
* Index selectors are integer numbers. They provide an alternative way of referencing
* overloaded functions, based on the order in which the declarations appear in
* a source file.
*
* @remarks
* Warning: Index selectors are not recommended; they are intended to provide a temporary
* workaround for situations where an external library neglected to declare a `{@label}` tag
* and cannot be easily fixed.
*/
SelectorKind["Index"] = "index";
/**
* Label selectors refer to labels created using the `{@label}` TSDoc tag.
* The labels are always comprised of upper-case letters or numbers separated by underscores,
* and the first character cannot be a number.
*/
SelectorKind["Label"] = "label";
})(SelectorKind || (exports.SelectorKind = SelectorKind = {}));
/**
*/
class DocMemberSelector extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
this._selectorExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.MemberSelector,
content: parameters.selectorExcerpt
});
this._selector = parameters.selectorExcerpt.toString();
}
else {
this._selector = parameters.selector;
}
this._selectorKind = SelectorKind.Error;
this._errorMessage = undefined;
// The logic below will always either (1) assign selectorKind or (2) else assign an errorMessage
if (this._selector.length === 0) {
this._errorMessage = 'The selector cannot be an empty string';
}
else if (DocMemberSelector._likeIndexSelectorRegExp.test(this._selector)) {
// It looks like an index selector
if (DocMemberSelector._indexSelectorRegExp.test(this._selector)) {
this._selectorKind = SelectorKind.Index;
}
else {
this._errorMessage = 'If the selector begins with a number, it must be a positive integer value';
}
}
else if (DocMemberSelector._likeLabelSelectorRegExp.test(this._selector)) {
// It looks like a label selector
if (DocMemberSelector._labelSelectorRegExp.test(this._selector)) {
this._selectorKind = SelectorKind.Label;
}
else {
this._errorMessage =
'A label selector must be comprised of upper case letters, numbers,' +
' and underscores and must not start with a number';
}
}
else {
if (StringChecks_1.StringChecks.isSystemSelector(this._selector)) {
this._selectorKind = SelectorKind.System;
}
else if (DocMemberSelector._likeSystemSelectorRegExp.test(this._selector)) {
// It looks like a system selector, but is not
this._errorMessage =
`The selector ${JSON.stringify(this._selector)}` +
` is not a recognized TSDoc system selector name`;
}
else {
// It doesn't look like anything we recognize
this._errorMessage = 'Invalid syntax for selector';
}
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.MemberSelector;
}
/**
* The text representation of the selector.
*
* @remarks
* For system selectors, it will be a predefined lower case name.
* For label selectors, it will be an upper case name defined using the `{@label}` tag.
* For index selectors, it will be a positive integer.
*/
get selector() {
return this._selector;
}
/**
* Indicates the kind of selector.
*/
get selectorKind() {
return this._selectorKind;
}
/**
* If the `selectorKind` is `SelectorKind.Error`, this string will be defined and provide
* more detail about why the string was not valid.
*/
get errorMessage() {
return this._errorMessage;
}
/** @override */
onGetChildNodes() {
return [this._selectorExcerpt];
}
}
exports.DocMemberSelector = DocMemberSelector;
DocMemberSelector._likeIndexSelectorRegExp = /^[0-9]/;
DocMemberSelector._indexSelectorRegExp = /^[1-9][0-9]*$/;
DocMemberSelector._likeLabelSelectorRegExp = /^[A-Z_]/u;
DocMemberSelector._labelSelectorRegExp = /^[A-Z_][A-Z0-9_]+$/;
DocMemberSelector._likeSystemSelectorRegExp = /^[a-z]+$/u;
//# sourceMappingURL=DocMemberSelector.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,68 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocMemberSymbol = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* Represents a reference to an ECMAScript 6 symbol that is used
* to identify a member declaration.
*
* @example
*
* In the declaration reference `{@link MyClass.([MySymbols.example]:instance)}`,
* the member symbol `[MySymbols.example]` might be used to reference a property
* of the class.
*/
class DocMemberSymbol extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
this._leftBracketExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.DocMemberSymbol_LeftBracket,
content: parameters.leftBracketExcerpt
});
if (parameters.spacingAfterLeftBracketExcerpt) {
this._spacingAfterLeftBracketExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterLeftBracketExcerpt
});
}
this._rightBracketExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.DocMemberSymbol_RightBracket,
content: parameters.rightBracketExcerpt
});
}
this._symbolReference = parameters.symbolReference;
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.MemberSymbol;
}
/**
* The declaration reference for the ECMAScript 6 symbol that will act as
* the identifier for the member.
*/
get symbolReference() {
return this._symbolReference;
}
/** @override */
onGetChildNodes() {
return [
this._leftBracketExcerpt,
this._spacingAfterLeftBracketExcerpt,
this._symbolReference,
this._rightBracketExcerpt
];
}
}
exports.DocMemberSymbol = DocMemberSymbol;
//# sourceMappingURL=DocMemberSymbol.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocMemberSymbol.js","sourceRoot":"","sources":["../../src/nodes/DocMemberSymbol.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAyG;AAGzG,6CAAuD;AAqBvD;;;;;;;;;GASG;AACH,MAAa,eAAgB,SAAQ,iBAAO;IAQ1C;;;OAGG;IACH,YAAmB,UAAyE;QAC1F,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,iBAAO,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,mBAAmB,GAAG,IAAI,uBAAU,CAAC;gBACxC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,WAAW,EAAE,wBAAW,CAAC,2BAA2B;gBACpD,OAAO,EAAE,UAAU,CAAC,kBAAkB;aACvC,CAAC,CAAC;YAEH,IAAI,UAAU,CAAC,8BAA8B,EAAE,CAAC;gBAC9C,IAAI,CAAC,+BAA+B,GAAG,IAAI,uBAAU,CAAC;oBACpD,aAAa,EAAE,IAAI,CAAC,aAAa;oBACjC,WAAW,EAAE,wBAAW,CAAC,OAAO;oBAChC,OAAO,EAAE,UAAU,CAAC,8BAA8B;iBACnD,CAAC,CAAC;YACL,CAAC;YAED,IAAI,CAAC,oBAAoB,GAAG,IAAI,uBAAU,CAAC;gBACzC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,WAAW,EAAE,wBAAW,CAAC,4BAA4B;gBACrD,OAAO,EAAE,UAAU,CAAC,mBAAmB;aACxC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC,eAAe,CAAC;IACrD,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,YAAY,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,gBAAgB;IACN,eAAe;QACvB,OAAO;YACL,IAAI,CAAC,mBAAmB;YACxB,IAAI,CAAC,+BAA+B;YACpC,IAAI,CAAC,gBAAgB;YACrB,IAAI,CAAC,oBAAoB;SAC1B,CAAC;IACJ,CAAC;CACF;AA9DD,0CA8DC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, DocNode, type IDocNodeParameters, type IDocNodeParsedParameters } from './DocNode';\r\nimport type { DocDeclarationReference } from './DocDeclarationReference';\r\nimport type { TokenSequence } from '../parser/TokenSequence';\r\nimport { DocExcerpt, ExcerptKind } from './DocExcerpt';\r\n\r\n/**\r\n * Constructor parameters for {@link DocMemberSymbol}.\r\n */\r\nexport interface IDocMemberSymbolParameters extends IDocNodeParameters {\r\n symbolReference: DocDeclarationReference;\r\n}\r\n\r\n/**\r\n * Constructor parameters for {@link DocMemberSymbol}.\r\n */\r\nexport interface IDocMemberSymbolParsedParameters extends IDocNodeParsedParameters {\r\n leftBracketExcerpt: TokenSequence;\r\n spacingAfterLeftBracketExcerpt?: TokenSequence;\r\n\r\n symbolReference: DocDeclarationReference;\r\n\r\n rightBracketExcerpt: TokenSequence;\r\n}\r\n\r\n/**\r\n * Represents a reference to an ECMAScript 6 symbol that is used\r\n * to identify a member declaration.\r\n *\r\n * @example\r\n *\r\n * In the declaration reference `{@link MyClass.([MySymbols.example]:instance)}`,\r\n * the member symbol `[MySymbols.example]` might be used to reference a property\r\n * of the class.\r\n */\r\nexport class DocMemberSymbol extends DocNode {\r\n private readonly _leftBracketExcerpt: DocExcerpt | undefined;\r\n private readonly _spacingAfterLeftBracketExcerpt: DocExcerpt | undefined;\r\n\r\n private readonly _symbolReference: DocDeclarationReference;\r\n\r\n private readonly _rightBracketExcerpt: DocExcerpt | undefined;\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocMemberSymbolParameters | IDocMemberSymbolParsedParameters) {\r\n super(parameters);\r\n\r\n if (DocNode.isParsedParameters(parameters)) {\r\n this._leftBracketExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.DocMemberSymbol_LeftBracket,\r\n content: parameters.leftBracketExcerpt\r\n });\r\n\r\n if (parameters.spacingAfterLeftBracketExcerpt) {\r\n this._spacingAfterLeftBracketExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.Spacing,\r\n content: parameters.spacingAfterLeftBracketExcerpt\r\n });\r\n }\r\n\r\n this._rightBracketExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.DocMemberSymbol_RightBracket,\r\n content: parameters.rightBracketExcerpt\r\n });\r\n }\r\n\r\n this._symbolReference = parameters.symbolReference;\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.MemberSymbol;\r\n }\r\n\r\n /**\r\n * The declaration reference for the ECMAScript 6 symbol that will act as\r\n * the identifier for the member.\r\n */\r\n public get symbolReference(): DocDeclarationReference {\r\n return this._symbolReference;\r\n }\r\n\r\n /** @override */\r\n protected onGetChildNodes(): ReadonlyArray<DocNode | undefined> {\r\n return [\r\n this._leftBracketExcerpt,\r\n this._spacingAfterLeftBracketExcerpt,\r\n this._symbolReference,\r\n this._rightBracketExcerpt\r\n ];\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,80 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocNode = exports.DocNodeKind = void 0;
/**
* Indicates the type of {@link DocNode}.
*
* @remarks
* When creating custom subclasses of `DocNode`, it's recommended to create your own enum to identify them.
* To avoid naming conflicts between projects, the enum value should be a string comprised of your full
* NPM package name, followed by a "#" symbol, followed by the class name (without the "Doc" prefix).
*/
var DocNodeKind;
(function (DocNodeKind) {
DocNodeKind["Block"] = "Block";
DocNodeKind["BlockTag"] = "BlockTag";
DocNodeKind["Excerpt"] = "Excerpt";
DocNodeKind["FencedCode"] = "FencedCode";
DocNodeKind["CodeSpan"] = "CodeSpan";
DocNodeKind["Comment"] = "Comment";
DocNodeKind["DeclarationReference"] = "DeclarationReference";
DocNodeKind["ErrorText"] = "ErrorText";
DocNodeKind["EscapedText"] = "EscapedText";
DocNodeKind["HtmlAttribute"] = "HtmlAttribute";
DocNodeKind["HtmlEndTag"] = "HtmlEndTag";
DocNodeKind["HtmlStartTag"] = "HtmlStartTag";
DocNodeKind["InheritDocTag"] = "InheritDocTag";
DocNodeKind["InlineTag"] = "InlineTag";
DocNodeKind["LinkTag"] = "LinkTag";
DocNodeKind["MemberIdentifier"] = "MemberIdentifier";
DocNodeKind["MemberReference"] = "MemberReference";
DocNodeKind["MemberSelector"] = "MemberSelector";
DocNodeKind["MemberSymbol"] = "MemberSymbol";
DocNodeKind["Paragraph"] = "Paragraph";
DocNodeKind["ParamBlock"] = "ParamBlock";
DocNodeKind["ParamCollection"] = "ParamCollection";
DocNodeKind["PlainText"] = "PlainText";
DocNodeKind["Section"] = "Section";
DocNodeKind["SoftBreak"] = "SoftBreak";
})(DocNodeKind || (exports.DocNodeKind = DocNodeKind = {}));
/**
* The base class for the parser's Abstract Syntax Tree nodes.
*/
class DocNode {
constructor(parameters) {
this.configuration = parameters.configuration;
}
/**
* Returns the list of child nodes for this node. This is useful for visitors that want
* to scan the tree looking for nodes of a specific type, without having to process
* intermediary nodes.
*/
getChildNodes() {
// Do this sanity check here, since the constructor cannot access abstract members
this.configuration.docNodeManager.throwIfNotRegisteredKind(this.kind);
return this.onGetChildNodes().filter((x) => x !== undefined);
}
/**
* Overridden by child classes to implement {@link DocNode.getChildNodes}.
* @virtual
*/
onGetChildNodes() {
return [];
}
/**
* A type guard that returns true if the input uses the `IDocNodeParsedParameters` (parser scenario).
*
* @remarks
* There are two scenarios for constructing `DocNode` objects. The "builder scenario" constructs the object based on
* literal strings, does NOT create DocExcerpt child nodes, and generally uses the {@link IDocNodeParameters}
* hierarchy for its constructor parameters. The "parser scenario" constructs the object by parsing a TypeScript
* source file, does create DocExcerpt child nodes, and generally uses the {@link IDocNodeParsedParameters} hierarchy.
*/
static isParsedParameters(parameters) {
return parameters.parsed === true;
}
}
exports.DocNode = DocNode;
//# sourceMappingURL=DocNode.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,59 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocNodeContainer = void 0;
const DocNode_1 = require("./DocNode");
/**
* DocNodeContainer is the base class for DocNode classes that allow arbitrary child nodes to be added by the consumer.
* The child classes are {@link DocParagraph} and {@link DocSection}.
*/
class DocNodeContainer extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters, childNodes) {
super(parameters);
this._nodes = [];
if (childNodes !== undefined && childNodes.length > 0) {
this.appendNodes(childNodes);
}
}
/**
* The nodes that were added to this container.
*/
get nodes() {
return this._nodes;
}
/**
* Append a node to the container.
*/
appendNode(docNode) {
if (!this.configuration.docNodeManager.isAllowedChild(this.kind, docNode.kind)) {
throw new Error(`The TSDocConfiguration does not allow a ${this.kind} node to` +
` contain a node of type ${docNode.kind}`);
}
this._nodes.push(docNode);
}
/**
* Append nodes to the container.
*/
appendNodes(docNodes) {
for (const docNode of docNodes) {
this.appendNode(docNode);
}
}
/**
* Remove all nodes from the container.
*/
clearNodes() {
this._nodes.length = 0;
}
/** @override */
onGetChildNodes() {
return this._nodes;
}
}
exports.DocNodeContainer = DocNodeContainer;
//# sourceMappingURL=DocNodeContainer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocNodeContainer.js","sourceRoot":"","sources":["../../src/nodes/DocNodeContainer.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAA4F;AAY5F;;;GAGG;AACH,MAAsB,gBAAiB,SAAQ,iBAAO;IAGpD;;;OAGG;IACH,YACE,UAA2E,EAC3E,UAAmC;QAEnC,KAAK,CAAC,UAAU,CAAC,CAAC;QAVH,WAAM,GAAc,EAAE,CAAC;QAYtC,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtD,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,UAAU,CAAC,OAAgB;QAChC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/E,MAAM,IAAI,KAAK,CACb,2CAA2C,IAAI,CAAC,IAAI,UAAU;gBAC5D,2BAA2B,OAAO,CAAC,IAAI,EAAE,CAC5C,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,MAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,WAAW,CAAC,QAAgC;QACjD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED;;OAEG;IACI,UAAU;QACf,IAAI,CAAC,MAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,gBAAgB;IACN,eAAe;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AA3DD,4CA2DC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNode, type IDocNodeParameters, type IDocNodeParsedParameters } from './DocNode';\r\n\r\n/**\r\n * Constructor parameters for {@link DocNodeContainer}.\r\n */\r\nexport interface IDocNodeContainerParameters extends IDocNodeParameters {}\r\n\r\n/**\r\n * Constructor parameters for {@link DocNodeContainer}.\r\n */\r\nexport interface IDocNodeContainerParsedParameters extends IDocNodeParsedParameters {}\r\n\r\n/**\r\n * DocNodeContainer is the base class for DocNode classes that allow arbitrary child nodes to be added by the consumer.\r\n * The child classes are {@link DocParagraph} and {@link DocSection}.\r\n */\r\nexport abstract class DocNodeContainer extends DocNode {\r\n private readonly _nodes: DocNode[] = [];\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(\r\n parameters: IDocNodeContainerParameters | IDocNodeContainerParsedParameters,\r\n childNodes?: ReadonlyArray<DocNode>\r\n ) {\r\n super(parameters);\r\n\r\n if (childNodes !== undefined && childNodes.length > 0) {\r\n this.appendNodes(childNodes);\r\n }\r\n }\r\n\r\n /**\r\n * The nodes that were added to this container.\r\n */\r\n public get nodes(): ReadonlyArray<DocNode> {\r\n return this._nodes;\r\n }\r\n\r\n /**\r\n * Append a node to the container.\r\n */\r\n public appendNode(docNode: DocNode): void {\r\n if (!this.configuration.docNodeManager.isAllowedChild(this.kind, docNode.kind)) {\r\n throw new Error(\r\n `The TSDocConfiguration does not allow a ${this.kind} node to` +\r\n ` contain a node of type ${docNode.kind}`\r\n );\r\n }\r\n\r\n this._nodes!.push(docNode);\r\n }\r\n\r\n /**\r\n * Append nodes to the container.\r\n */\r\n public appendNodes(docNodes: ReadonlyArray<DocNode>): void {\r\n for (const docNode of docNodes) {\r\n this.appendNode(docNode);\r\n }\r\n }\r\n\r\n /**\r\n * Remove all nodes from the container.\r\n */\r\n public clearNodes(): void {\r\n this._nodes!.length = 0;\r\n }\r\n\r\n /** @override */\r\n protected onGetChildNodes(): ReadonlyArray<DocNode | undefined> {\r\n return this._nodes;\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,27 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocParagraph = void 0;
const DocNode_1 = require("./DocNode");
const DocNodeContainer_1 = require("./DocNodeContainer");
/**
* Represents a paragraph of text, similar to a `<p>` element in HTML.
* Like CommonMark, the TSDoc syntax uses blank lines to delineate paragraphs
* instead of explicitly notating them.
*/
class DocParagraph extends DocNodeContainer_1.DocNodeContainer {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters, childNodes) {
super(parameters, childNodes);
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.Paragraph;
}
}
exports.DocParagraph = DocParagraph;
//# sourceMappingURL=DocParagraph.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocParagraph.js","sourceRoot":"","sources":["../../src/nodes/DocParagraph.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAsD;AACtD,yDAAwF;AAOxF;;;;GAIG;AACH,MAAa,YAAa,SAAQ,mCAAgB;IAChD;;;OAGG;IACH,YAAmB,UAAmC,EAAE,UAAmC;QACzF,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAChC,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,SAAS,CAAC;IAC/B,CAAC;CACF;AAbD,oCAaC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, type DocNode } from './DocNode';\r\nimport { DocNodeContainer, type IDocNodeContainerParameters } from './DocNodeContainer';\r\n\r\n/**\r\n * Constructor parameters for {@link DocParagraph}.\r\n */\r\nexport interface IDocParagraphParameters extends IDocNodeContainerParameters {}\r\n\r\n/**\r\n * Represents a paragraph of text, similar to a `<p>` element in HTML.\r\n * Like CommonMark, the TSDoc syntax uses blank lines to delineate paragraphs\r\n * instead of explicitly notating them.\r\n */\r\nexport class DocParagraph extends DocNodeContainer {\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocParagraphParameters, childNodes?: ReadonlyArray<DocNode>) {\r\n super(parameters, childNodes);\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.Paragraph;\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,122 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocParamBlock = void 0;
const DocNode_1 = require("./DocNode");
const DocBlock_1 = require("./DocBlock");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* Represents a parsed `@param` or `@typeParam` block, which provides a description for a
* function parameter.
*/
class DocParamBlock extends DocBlock_1.DocBlock {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
this._parameterName = parameters.parameterName;
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
if (parameters.spacingBeforeParameterNameExcerpt) {
this._spacingBeforeParameterNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingBeforeParameterNameExcerpt
});
}
if (parameters.unsupportedJsdocTypeBeforeParameterNameExcerpt) {
this._unsupportedJsdocTypeBeforeParameterNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.NonstandardText,
content: parameters.unsupportedJsdocTypeBeforeParameterNameExcerpt
});
}
if (parameters.unsupportedJsdocOptionalNameOpenBracketExcerpt) {
this._unsupportedJsdocOptionalNameOpenBracketExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.NonstandardText,
content: parameters.unsupportedJsdocOptionalNameOpenBracketExcerpt
});
}
this._parameterNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.ParamBlock_ParameterName,
content: parameters.parameterNameExcerpt
});
if (parameters.unsupportedJsdocOptionalNameRestExcerpt) {
this._unsupportedJsdocOptionalNameRestExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.NonstandardText,
content: parameters.unsupportedJsdocOptionalNameRestExcerpt
});
}
if (parameters.spacingAfterParameterNameExcerpt) {
this._spacingAfterParameterNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterParameterNameExcerpt
});
}
if (parameters.unsupportedJsdocTypeAfterParameterNameExcerpt) {
this._unsupportedJsdocTypeAfterParameterNameExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.NonstandardText,
content: parameters.unsupportedJsdocTypeAfterParameterNameExcerpt
});
}
if (parameters.hyphenExcerpt) {
this._hyphenExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.ParamBlock_Hyphen,
content: parameters.hyphenExcerpt
});
}
if (parameters.spacingAfterHyphenExcerpt) {
this._spacingAfterHyphenExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.Spacing,
content: parameters.spacingAfterHyphenExcerpt
});
}
if (parameters.unsupportedJsdocTypeAfterHyphenExcerpt) {
this._unsupportedJsdocTypeAfterHyphenExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.NonstandardText,
content: parameters.unsupportedJsdocTypeAfterHyphenExcerpt
});
}
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.ParamBlock;
}
/**
* The name of the parameter that is being documented.
* For example "width" in `@param width - the width of the object`.
*/
get parameterName() {
return this._parameterName;
}
/** @override */
onGetChildNodes() {
return [
this.blockTag,
this._spacingBeforeParameterNameExcerpt,
this._unsupportedJsdocTypeBeforeParameterNameExcerpt,
this._unsupportedJsdocOptionalNameOpenBracketExcerpt,
this._parameterNameExcerpt,
this._unsupportedJsdocOptionalNameRestExcerpt,
this._spacingAfterParameterNameExcerpt,
this._unsupportedJsdocTypeAfterParameterNameExcerpt,
this._hyphenExcerpt,
this._spacingAfterHyphenExcerpt,
this._unsupportedJsdocTypeAfterHyphenExcerpt,
this.content
];
}
}
exports.DocParamBlock = DocParamBlock;
//# sourceMappingURL=DocParamBlock.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,85 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocParamCollection = void 0;
const DocNode_1 = require("./DocNode");
/**
* Represents a collection of DocParamBlock objects and provides efficient operations for looking up the
* documentation for a specified parameter name.
*/
class DocParamCollection extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
this._blocks = [];
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.ParamCollection;
}
/**
* Provide an iterator for callers that support it.
*/
[Symbol.iterator]() {
return this._blocks[Symbol.iterator]();
}
/**
* Returns the blocks in this collection.
*/
get blocks() {
return this._blocks;
}
/**
* Returns the number of blocks in this collection.
*/
get count() {
return this._blocks.length;
}
/**
* Adds a new block to the collection.
*/
add(docParamBlock) {
this._blocks.push(docParamBlock);
// Allocate the map on demand, since most DocComment parameter collections will be empty
if (this._blocksByName === undefined) {
this._blocksByName = new Map();
}
// The first block to be added takes precedence
if (!this._blocksByName.has(docParamBlock.parameterName)) {
this._blocksByName.set(docParamBlock.parameterName, docParamBlock);
}
}
/**
* Removes all blocks from the collection
*/
clear() {
this._blocks.length = 0;
this._blocksByName = undefined;
}
/**
* Returns the first block whose `parameterName` matches the specified string.
*
* @remarks
* If the collection was parsed from an input containing errors, there could potentially be more than
* one DocParamBlock with the same name. In this situation, tryGetBlockByName() will return the first match
* that it finds.
*
* This lookup is optimized using a dictionary.
*/
tryGetBlockByName(parameterName) {
if (this._blocksByName) {
return this._blocksByName.get(parameterName);
}
return undefined;
}
/** @override */
onGetChildNodes() {
return this._blocks;
}
}
exports.DocParamCollection = DocParamCollection;
//# sourceMappingURL=DocParamCollection.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocParamCollection.js","sourceRoot":"","sources":["../../src/nodes/DocParamCollection.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAA0E;AAQ1E;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,iBAAO;IAI7C;;;OAGG;IACH,YAAmB,UAAyC;QAC1D,KAAK,CAAC,UAAU,CAAC,CAAC;QARH,YAAO,GAAoB,EAAE,CAAC;IAS/C,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,eAAe,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,aAA4B;QACrC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEjC,wFAAwF;QACxF,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YACrC,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAyB,CAAC;QACxD,CAAC;QAED,+CAA+C;QAC/C,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC;YACzD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IAED;;OAEG;IACI,KAAK;QACV,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;IACjC,CAAC;IAED;;;;;;;;;OASG;IACI,iBAAiB,CAAC,aAAqB;QAC5C,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,gBAAgB;IACN,eAAe;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AApFD,gDAoFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, DocNode, type IDocNodeParameters } from './DocNode';\r\nimport type { DocParamBlock } from './DocParamBlock';\r\n\r\n/**\r\n * Constructor parameters for {@link DocParamCollection}.\r\n */\r\nexport interface IDocParamCollectionParameters extends IDocNodeParameters {}\r\n\r\n/**\r\n * Represents a collection of DocParamBlock objects and provides efficient operations for looking up the\r\n * documentation for a specified parameter name.\r\n */\r\nexport class DocParamCollection extends DocNode {\r\n private readonly _blocks: DocParamBlock[] = [];\r\n private _blocksByName: Map<string, DocParamBlock> | undefined;\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocParamCollectionParameters) {\r\n super(parameters);\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.ParamCollection;\r\n }\r\n\r\n /**\r\n * Provide an iterator for callers that support it.\r\n */\r\n public [Symbol.iterator](): IterableIterator<DocParamBlock> {\r\n return this._blocks[Symbol.iterator]();\r\n }\r\n\r\n /**\r\n * Returns the blocks in this collection.\r\n */\r\n public get blocks(): ReadonlyArray<DocParamBlock> {\r\n return this._blocks;\r\n }\r\n\r\n /**\r\n * Returns the number of blocks in this collection.\r\n */\r\n public get count(): number {\r\n return this._blocks.length;\r\n }\r\n\r\n /**\r\n * Adds a new block to the collection.\r\n */\r\n public add(docParamBlock: DocParamBlock): void {\r\n this._blocks.push(docParamBlock);\r\n\r\n // Allocate the map on demand, since most DocComment parameter collections will be empty\r\n if (this._blocksByName === undefined) {\r\n this._blocksByName = new Map<string, DocParamBlock>();\r\n }\r\n\r\n // The first block to be added takes precedence\r\n if (!this._blocksByName.has(docParamBlock.parameterName)) {\r\n this._blocksByName.set(docParamBlock.parameterName, docParamBlock);\r\n }\r\n }\r\n\r\n /**\r\n * Removes all blocks from the collection\r\n */\r\n public clear(): void {\r\n this._blocks.length = 0;\r\n this._blocksByName = undefined;\r\n }\r\n\r\n /**\r\n * Returns the first block whose `parameterName` matches the specified string.\r\n *\r\n * @remarks\r\n * If the collection was parsed from an input containing errors, there could potentially be more than\r\n * one DocParamBlock with the same name. In this situation, tryGetBlockByName() will return the first match\r\n * that it finds.\r\n *\r\n * This lookup is optimized using a dictionary.\r\n */\r\n public tryGetBlockByName(parameterName: string): DocParamBlock | undefined {\r\n if (this._blocksByName) {\r\n return this._blocksByName.get(parameterName);\r\n }\r\n return undefined;\r\n }\r\n\r\n /** @override */\r\n protected onGetChildNodes(): ReadonlyArray<DocNode | undefined> {\r\n return this._blocks;\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,68 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocPlainText = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* Represents a span of comment text that is considered by the parser
* to contain no special symbols or meaning.
*
* @remarks
* The text content must not contain newline characters.
* Use DocSoftBreak to represent manual line splitting.
*/
class DocPlainText extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
this._textExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.PlainText,
content: parameters.textExcerpt
});
}
else {
if (DocPlainText._newlineCharacterRegExp.test(parameters.text)) {
// Use DocSoftBreak to represent manual line splitting
throw new Error('The DocPlainText content must not contain newline characters');
}
this._text = parameters.text;
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.PlainText;
}
/**
* The text content.
*/
get text() {
if (this._text === undefined) {
this._text = this._textExcerpt.content.toString();
}
return this._text;
}
get textExcerpt() {
if (this._textExcerpt) {
return this._textExcerpt.content;
}
else {
return undefined;
}
}
/** @override */
onGetChildNodes() {
return [this._textExcerpt];
}
}
exports.DocPlainText = DocPlainText;
// TODO: We should also prohibit "\r", but this requires updating LineExtractor
// to interpret a lone "\r" as a newline
DocPlainText._newlineCharacterRegExp = /[\n]/;
//# sourceMappingURL=DocPlainText.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocPlainText.js","sourceRoot":"","sources":["../../src/nodes/DocPlainText.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAyG;AAEzG,6CAAuD;AAgBvD;;;;;;;GAOG;AACH,MAAa,YAAa,SAAQ,iBAAO;IAQvC;;;OAGG;IACH,YAAmB,UAAmE;QACpF,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,iBAAO,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,YAAY,GAAG,IAAI,uBAAU,CAAC;gBACjC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,WAAW,EAAE,wBAAW,CAAC,SAAS;gBAClC,OAAO,EAAE,UAAU,CAAC,WAAW;aAChC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,IAAI,YAAY,CAAC,uBAAuB,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/D,sDAAsD;gBACtD,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;YAClF,CAAC;YAED,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACb,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrD,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAW,WAAW;QACpB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,gBAAgB;IACN,eAAe;QACvB,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7B,CAAC;;AAzDH,oCA0DC;AAzDC,+EAA+E;AAC/E,wCAAwC;AAChB,oCAAuB,GAAW,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, type IDocNodeParameters, type IDocNodeParsedParameters, DocNode } from './DocNode';\r\nimport type { TokenSequence } from '../parser/TokenSequence';\r\nimport { DocExcerpt, ExcerptKind } from './DocExcerpt';\r\n\r\n/**\r\n * Constructor parameters for {@link DocPlainText}.\r\n */\r\nexport interface IDocPlainTextParameters extends IDocNodeParameters {\r\n text: string;\r\n}\r\n\r\n/**\r\n * Constructor parameters for {@link DocPlainText}.\r\n */\r\nexport interface IDocPlainTextParsedParameters extends IDocNodeParsedParameters {\r\n textExcerpt: TokenSequence;\r\n}\r\n\r\n/**\r\n * Represents a span of comment text that is considered by the parser\r\n * to contain no special symbols or meaning.\r\n *\r\n * @remarks\r\n * The text content must not contain newline characters.\r\n * Use DocSoftBreak to represent manual line splitting.\r\n */\r\nexport class DocPlainText extends DocNode {\r\n // TODO: We should also prohibit \"\\r\", but this requires updating LineExtractor\r\n // to interpret a lone \"\\r\" as a newline\r\n private static readonly _newlineCharacterRegExp: RegExp = /[\\n]/;\r\n\r\n private _text: string | undefined;\r\n private readonly _textExcerpt: DocExcerpt | undefined;\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocPlainTextParameters | IDocPlainTextParsedParameters) {\r\n super(parameters);\r\n\r\n if (DocNode.isParsedParameters(parameters)) {\r\n this._textExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.PlainText,\r\n content: parameters.textExcerpt\r\n });\r\n } else {\r\n if (DocPlainText._newlineCharacterRegExp.test(parameters.text)) {\r\n // Use DocSoftBreak to represent manual line splitting\r\n throw new Error('The DocPlainText content must not contain newline characters');\r\n }\r\n\r\n this._text = parameters.text;\r\n }\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.PlainText;\r\n }\r\n\r\n /**\r\n * The text content.\r\n */\r\n public get text(): string {\r\n if (this._text === undefined) {\r\n this._text = this._textExcerpt!.content.toString();\r\n }\r\n return this._text;\r\n }\r\n\r\n public get textExcerpt(): TokenSequence | undefined {\r\n if (this._textExcerpt) {\r\n return this._textExcerpt.content;\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n\r\n /** @override */\r\n protected onGetChildNodes(): ReadonlyArray<DocNode | undefined> {\r\n return [this._textExcerpt];\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,49 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocSection = void 0;
const DocNode_1 = require("./DocNode");
const DocParagraph_1 = require("./DocParagraph");
const DocNodeContainer_1 = require("./DocNodeContainer");
/**
* Represents a general block of rich text.
*/
class DocSection extends DocNodeContainer_1.DocNodeContainer {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters, childNodes) {
super(parameters, childNodes);
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.Section;
}
/**
* If the last item in DocSection.nodes is not a DocParagraph, a new paragraph
* is started. Either way, the provided docNode will be appended to the paragraph.
*/
appendNodeInParagraph(docNode) {
let paragraphNode = undefined;
if (this.nodes.length > 0) {
const lastNode = this.nodes[this.nodes.length - 1];
if (lastNode.kind === DocNode_1.DocNodeKind.Paragraph) {
paragraphNode = lastNode;
}
}
if (!paragraphNode) {
paragraphNode = new DocParagraph_1.DocParagraph({ configuration: this.configuration });
this.appendNode(paragraphNode);
}
paragraphNode.appendNode(docNode);
}
appendNodesInParagraph(docNodes) {
for (const docNode of docNodes) {
this.appendNodeInParagraph(docNode);
}
}
}
exports.DocSection = DocSection;
//# sourceMappingURL=DocSection.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocSection.js","sourceRoot":"","sources":["../../src/nodes/DocSection.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAsD;AACtD,iDAA8C;AAC9C,yDAI4B;AAY5B;;GAEG;AACH,MAAa,UAAW,SAAQ,mCAAgB;IAC9C;;;OAGG;IACH,YACE,UAA+D,EAC/D,UAAmC;QAEnC,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAChC,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,OAAO,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACI,qBAAqB,CAAC,OAAgB;QAC3C,IAAI,aAAa,GAA6B,SAAS,CAAC;QAExD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAC5D,IAAI,QAAQ,CAAC,IAAI,KAAK,qBAAW,CAAC,SAAS,EAAE,CAAC;gBAC5C,aAAa,GAAG,QAAwB,CAAC;YAC3C,CAAC;QACH,CAAC;QACD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,aAAa,GAAG,IAAI,2BAAY,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;YACxE,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC;QAED,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAEM,sBAAsB,CAAC,QAAgC;QAC5D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF;AA3CD,gCA2CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { type DocNode, DocNodeKind } from './DocNode';\r\nimport { DocParagraph } from './DocParagraph';\r\nimport {\r\n DocNodeContainer,\r\n type IDocNodeContainerParameters,\r\n type IDocNodeContainerParsedParameters\r\n} from './DocNodeContainer';\r\n\r\n/**\r\n * Constructor parameters for {@link DocSection}.\r\n */\r\nexport interface IDocSectionParameters extends IDocNodeContainerParameters {}\r\n\r\n/**\r\n * Constructor parameters for {@link DocSection}.\r\n */\r\nexport interface IDocSectionParsedParameters extends IDocNodeContainerParsedParameters {}\r\n\r\n/**\r\n * Represents a general block of rich text.\r\n */\r\nexport class DocSection extends DocNodeContainer {\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(\r\n parameters: IDocSectionParameters | IDocSectionParsedParameters,\r\n childNodes?: ReadonlyArray<DocNode>\r\n ) {\r\n super(parameters, childNodes);\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.Section;\r\n }\r\n\r\n /**\r\n * If the last item in DocSection.nodes is not a DocParagraph, a new paragraph\r\n * is started. Either way, the provided docNode will be appended to the paragraph.\r\n */\r\n public appendNodeInParagraph(docNode: DocNode): void {\r\n let paragraphNode: DocParagraph | undefined = undefined;\r\n\r\n if (this.nodes.length > 0) {\r\n const lastNode: DocNode = this.nodes[this.nodes.length - 1];\r\n if (lastNode.kind === DocNodeKind.Paragraph) {\r\n paragraphNode = lastNode as DocParagraph;\r\n }\r\n }\r\n if (!paragraphNode) {\r\n paragraphNode = new DocParagraph({ configuration: this.configuration });\r\n this.appendNode(paragraphNode);\r\n }\r\n\r\n paragraphNode.appendNode(docNode);\r\n }\r\n\r\n public appendNodesInParagraph(docNodes: ReadonlyArray<DocNode>): void {\r\n for (const docNode of docNodes) {\r\n this.appendNodeInParagraph(docNode);\r\n }\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,50 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocSoftBreak = void 0;
const DocNode_1 = require("./DocNode");
const DocExcerpt_1 = require("./DocExcerpt");
/**
* Instructs a renderer to insert an explicit newline in the output.
* (Normally the renderer uses a formatting rule to determine where
* lines should wrap.)
*
* @remarks
* In HTML, a soft break is represented as an ASCII newline character (which does not
* affect the web browser's view), whereas the hard break is the `<br />` element
* (which starts a new line in the web browser's view).
*
* TSDoc follows the same conventions, except the renderer avoids emitting
* two empty lines (because that could start a new CommonMark paragraph).
*/
class DocSoftBreak extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
if (DocNode_1.DocNode.isParsedParameters(parameters)) {
// The type is IDocNodeParsedParameters, which is a base of IDocSoftBreakParsedParameters
// but not a base of IDocSoftBreakParameters. Therefore the type must be IDocSoftBreakParsedParameters.
// TypeScript 4 could infer this, but for some reason TypeScript 5 cannot.
const parsedParameters = parameters;
this._softBreakExcerpt = new DocExcerpt_1.DocExcerpt({
configuration: this.configuration,
excerptKind: DocExcerpt_1.ExcerptKind.SoftBreak,
content: parsedParameters.softBreakExcerpt
});
}
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.SoftBreak;
}
/** @override */
onGetChildNodes() {
return [this._softBreakExcerpt];
}
}
exports.DocSoftBreak = DocSoftBreak;
//# sourceMappingURL=DocSoftBreak.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DocSoftBreak.js","sourceRoot":"","sources":["../../src/nodes/DocSoftBreak.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,uCAAyG;AAEzG,6CAAuD;AAcvD;;;;;;;;;;;;GAYG;AACH,MAAa,YAAa,SAAQ,iBAAO;IAGvC;;;OAGG;IACH,YAAmB,UAAmE;QACpF,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,iBAAO,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3C,yFAAyF;YACzF,uGAAuG;YACvG,0EAA0E;YAC1E,MAAM,gBAAgB,GAAkC,UAA2C,CAAC;YACpG,IAAI,CAAC,iBAAiB,GAAG,IAAI,uBAAU,CAAC;gBACtC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,WAAW,EAAE,wBAAW,CAAC,SAAS;gBAClC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB;aAC3C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,gBAAgB;IAChB,IAAW,IAAI;QACb,OAAO,qBAAW,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,gBAAgB;IACN,eAAe;QACvB,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAClC,CAAC;CACF;AAhCD,oCAgCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { DocNodeKind, type IDocNodeParameters, DocNode, type IDocNodeParsedParameters } from './DocNode';\r\nimport type { TokenSequence } from '../parser/TokenSequence';\r\nimport { DocExcerpt, ExcerptKind } from './DocExcerpt';\r\n\r\n/**\r\n * Constructor parameters for {@link DocSoftBreak}.\r\n */\r\nexport interface IDocSoftBreakParameters extends IDocNodeParameters {}\r\n\r\n/**\r\n * Constructor parameters for {@link DocSoftBreak}.\r\n */\r\nexport interface IDocSoftBreakParsedParameters extends IDocNodeParsedParameters {\r\n softBreakExcerpt: TokenSequence;\r\n}\r\n\r\n/**\r\n * Instructs a renderer to insert an explicit newline in the output.\r\n * (Normally the renderer uses a formatting rule to determine where\r\n * lines should wrap.)\r\n *\r\n * @remarks\r\n * In HTML, a soft break is represented as an ASCII newline character (which does not\r\n * affect the web browser's view), whereas the hard break is the `<br />` element\r\n * (which starts a new line in the web browser's view).\r\n *\r\n * TSDoc follows the same conventions, except the renderer avoids emitting\r\n * two empty lines (because that could start a new CommonMark paragraph).\r\n */\r\nexport class DocSoftBreak extends DocNode {\r\n private readonly _softBreakExcerpt: DocExcerpt | undefined;\r\n\r\n /**\r\n * Don't call this directly. Instead use {@link TSDocParser}\r\n * @internal\r\n */\r\n public constructor(parameters: IDocSoftBreakParameters | IDocSoftBreakParsedParameters) {\r\n super(parameters);\r\n\r\n if (DocNode.isParsedParameters(parameters)) {\r\n // The type is IDocNodeParsedParameters, which is a base of IDocSoftBreakParsedParameters\r\n // but not a base of IDocSoftBreakParameters. Therefore the type must be IDocSoftBreakParsedParameters.\r\n // TypeScript 4 could infer this, but for some reason TypeScript 5 cannot.\r\n const parsedParameters: IDocSoftBreakParsedParameters = parameters as IDocSoftBreakParsedParameters;\r\n this._softBreakExcerpt = new DocExcerpt({\r\n configuration: this.configuration,\r\n excerptKind: ExcerptKind.SoftBreak,\r\n content: parsedParameters.softBreakExcerpt\r\n });\r\n }\r\n }\r\n\r\n /** @override */\r\n public get kind(): DocNodeKind | string {\r\n return DocNodeKind.SoftBreak;\r\n }\r\n\r\n /** @override */\r\n protected onGetChildNodes(): ReadonlyArray<DocNode | undefined> {\r\n return [this._softBreakExcerpt];\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,47 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./DocBlock"), exports);
__exportStar(require("./DocBlockTag"), exports);
__exportStar(require("./DocCodeSpan"), exports);
__exportStar(require("./DocComment"), exports);
__exportStar(require("./DocDeclarationReference"), exports);
__exportStar(require("./DocErrorText"), exports);
__exportStar(require("./DocEscapedText"), exports);
__exportStar(require("./DocExcerpt"), exports);
__exportStar(require("./DocFencedCode"), exports);
__exportStar(require("./DocHtmlAttribute"), exports);
__exportStar(require("./DocHtmlEndTag"), exports);
__exportStar(require("./DocHtmlStartTag"), exports);
__exportStar(require("./DocInheritDocTag"), exports);
__exportStar(require("./DocInlineTag"), exports);
__exportStar(require("./DocInlineTagBase"), exports);
__exportStar(require("./DocLinkTag"), exports);
__exportStar(require("./DocMemberIdentifier"), exports);
__exportStar(require("./DocMemberReference"), exports);
__exportStar(require("./DocMemberSelector"), exports);
__exportStar(require("./DocMemberSymbol"), exports);
__exportStar(require("./DocNode"), exports);
__exportStar(require("./DocNodeContainer"), exports);
__exportStar(require("./DocParagraph"), exports);
__exportStar(require("./DocParamBlock"), exports);
__exportStar(require("./DocParamCollection"), exports);
__exportStar(require("./DocPlainText"), exports);
__exportStar(require("./DocSection"), exports);
__exportStar(require("./DocSoftBreak"), exports);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nodes/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;AAE3D,6CAA2B;AAC3B,gDAA8B;AAC9B,gDAA8B;AAC9B,+CAA6B;AAC7B,4DAA0C;AAC1C,iDAA+B;AAC/B,mDAAiC;AACjC,+CAA6B;AAC7B,kDAAgC;AAChC,qDAAmC;AACnC,kDAAgC;AAChC,oDAAkC;AAClC,qDAAmC;AACnC,iDAA+B;AAC/B,qDAAmC;AACnC,+CAA6B;AAC7B,wDAAsC;AACtC,uDAAqC;AACrC,sDAAoC;AACpC,oDAAkC;AAClC,4CAA0B;AAC1B,qDAAmC;AACnC,iDAA+B;AAC/B,kDAAgC;AAChC,uDAAqC;AACrC,iDAA+B;AAC/B,+CAA6B;AAC7B,iDAA+B","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nexport * from './DocBlock';\r\nexport * from './DocBlockTag';\r\nexport * from './DocCodeSpan';\r\nexport * from './DocComment';\r\nexport * from './DocDeclarationReference';\r\nexport * from './DocErrorText';\r\nexport * from './DocEscapedText';\r\nexport * from './DocExcerpt';\r\nexport * from './DocFencedCode';\r\nexport * from './DocHtmlAttribute';\r\nexport * from './DocHtmlEndTag';\r\nexport * from './DocHtmlStartTag';\r\nexport * from './DocInheritDocTag';\r\nexport * from './DocInlineTag';\r\nexport * from './DocInlineTagBase';\r\nexport * from './DocLinkTag';\r\nexport * from './DocMemberIdentifier';\r\nexport * from './DocMemberReference';\r\nexport * from './DocMemberSelector';\r\nexport * from './DocMemberSymbol';\r\nexport * from './DocNode';\r\nexport * from './DocNodeContainer';\r\nexport * from './DocParagraph';\r\nexport * from './DocParamBlock';\r\nexport * from './DocParamCollection';\r\nexport * from './DocPlainText';\r\nexport * from './DocSection';\r\nexport * from './DocSoftBreak';\r\n"]}

View File

@@ -0,0 +1,156 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.LineExtractor = void 0;
const TSDocMessageId_1 = require("./TSDocMessageId");
// Internal parser state
var State;
(function (State) {
// Initial state, looking for "/*"
State[State["BeginComment1"] = 0] = "BeginComment1";
// Looking for "*" or "* " after "/*"
State[State["BeginComment2"] = 1] = "BeginComment2";
// Like State.CollectingLine except immediately after the "/**"
State[State["CollectingFirstLine"] = 2] = "CollectingFirstLine";
// Collecting characters until we reach a newline
State[State["CollectingLine"] = 3] = "CollectingLine";
// After a newline, looking for the "*" that begins a new line, or the "*/" to end the comment
State[State["AdvancingLine"] = 4] = "AdvancingLine";
// Exiting the parser loop
State[State["Done"] = 5] = "Done";
})(State || (State = {}));
/**
* The main API for parsing TSDoc comments.
*/
class LineExtractor {
/**
* This step parses an entire code comment from slash-star-star until star-slash,
* and extracts the content lines. The lines are stored in IDocCommentParameters.lines
* and the overall text range is assigned to IDocCommentParameters.range.
*/
static extract(parserContext) {
const range = parserContext.sourceRange;
const buffer = range.buffer;
let commentRangeStart = 0;
let commentRangeEnd = 0;
// These must be set before entering CollectingFirstLine, CollectingLine, or AdvancingLine
let collectingLineStart = 0;
let collectingLineEnd = 0;
let nextIndex = range.pos;
let state = State.BeginComment1;
const lines = [];
while (state !== State.Done) {
if (nextIndex >= range.end) {
// reached the end of the input
switch (state) {
case State.BeginComment1:
case State.BeginComment2:
parserContext.log.addMessageForTextRange(TSDocMessageId_1.TSDocMessageId.CommentNotFound, 'Expecting a "/**" comment', range);
return false;
default:
parserContext.log.addMessageForTextRange(TSDocMessageId_1.TSDocMessageId.CommentMissingClosingDelimiter, 'Unexpected end of input', range);
return false;
}
}
const current = buffer[nextIndex];
const currentIndex = nextIndex;
++nextIndex;
const next = nextIndex < range.end ? buffer[nextIndex] : '';
switch (state) {
case State.BeginComment1:
if (current === '/' && next === '*') {
commentRangeStart = currentIndex;
++nextIndex; // skip the star
state = State.BeginComment2;
}
else if (!LineExtractor._whitespaceCharacterRegExp.test(current)) {
parserContext.log.addMessageForTextRange(TSDocMessageId_1.TSDocMessageId.CommentOpeningDelimiterSyntax, 'Expecting a leading "/**"', range.getNewRange(currentIndex, currentIndex + 1));
return false;
}
break;
case State.BeginComment2:
if (current === '*') {
if (next === ' ') {
++nextIndex; // Discard the space after the star
}
collectingLineStart = nextIndex;
collectingLineEnd = nextIndex;
state = State.CollectingFirstLine;
}
else {
parserContext.log.addMessageForTextRange(TSDocMessageId_1.TSDocMessageId.CommentOpeningDelimiterSyntax, 'Expecting a leading "/**"', range.getNewRange(currentIndex, currentIndex + 1));
return false;
}
break;
case State.CollectingFirstLine:
case State.CollectingLine:
if (current === '\n') {
// Ignore an empty line if it is immediately after the "/**"
if (state !== State.CollectingFirstLine || collectingLineEnd > collectingLineStart) {
// Record the line that we collected
lines.push(range.getNewRange(collectingLineStart, collectingLineEnd));
}
collectingLineStart = nextIndex;
collectingLineEnd = nextIndex;
state = State.AdvancingLine;
}
else if (current === '*' && next === '/') {
if (collectingLineEnd > collectingLineStart) {
lines.push(range.getNewRange(collectingLineStart, collectingLineEnd));
}
collectingLineStart = 0;
collectingLineEnd = 0;
++nextIndex; // skip the slash
commentRangeEnd = nextIndex;
state = State.Done;
}
else if (!LineExtractor._whitespaceCharacterRegExp.test(current)) {
collectingLineEnd = nextIndex;
}
break;
case State.AdvancingLine:
if (current === '*') {
if (next === '/') {
collectingLineStart = 0;
collectingLineEnd = 0;
++nextIndex; // skip the slash
commentRangeEnd = nextIndex;
state = State.Done;
}
else {
// Discard the "*" at the start of a line
if (next === ' ') {
++nextIndex; // Discard the space after the star
}
collectingLineStart = nextIndex;
collectingLineEnd = nextIndex;
state = State.CollectingLine;
}
}
else if (current === '\n') {
// Blank line
lines.push(range.getNewRange(currentIndex, currentIndex));
collectingLineStart = nextIndex;
}
else if (!LineExtractor._whitespaceCharacterRegExp.test(current)) {
// If the star is missing, then start the line here
// Example: "/**\nL1*/"
// (collectingLineStart was the start of this line)
collectingLineEnd = nextIndex;
state = State.CollectingLine;
}
break;
}
}
/**
* Only fill in these if we successfully scanned a comment
*/
parserContext.commentRange = range.getNewRange(commentRangeStart, commentRangeEnd);
parserContext.lines = lines;
return true;
}
}
exports.LineExtractor = LineExtractor;
LineExtractor._whitespaceCharacterRegExp = /^\s$/;
//# sourceMappingURL=LineExtractor.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,121 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParagraphSplitter = void 0;
const nodes_1 = require("../nodes");
/**
* The ParagraphSplitter is a secondary stage that runs after the NodeParser has constructed
* the DocComment. It splits DocParagraph nodes into multiple paragraphs by looking for
* paragraph delimiters. Following CommonMark conventions, paragraphs are delimited by
* one or more blank lines. (These lines end with SoftBreak nodes.) The blank lines are
* not discarded. Instead, they are attached to the preceding paragraph. If the DocParagraph
* starts with blank lines, they are preserved to avoid creating a paragraph containing only
* whitespace.
*/
class ParagraphSplitter {
/**
* Split all paragraphs belonging to the provided subtree.
*/
static splitParagraphs(node) {
if (node instanceof nodes_1.DocSection) {
ParagraphSplitter.splitParagraphsForSection(node);
// (We don't recurse here, since sections cannot contain subsections)
}
else {
for (const childNode of node.getChildNodes()) {
ParagraphSplitter.splitParagraphs(childNode);
}
}
}
/**
* Split all paragraphs belonging to the provided DocSection.
*/
static splitParagraphsForSection(docSection) {
const inputNodes = docSection.nodes;
const outputNodes = [];
for (const oldNode of inputNodes) {
if (oldNode.kind === nodes_1.DocNodeKind.Paragraph) {
ParagraphSplitter._splitParagraph(oldNode, outputNodes);
}
else {
outputNodes.push(oldNode);
}
}
// Replace the inputNodes with the outputNodes
docSection.clearNodes();
docSection.appendNodes(outputNodes);
}
static _splitParagraph(oldParagraph, outputNodes) {
const inputParagraphNodes = oldParagraph.nodes;
let currentParagraph = new nodes_1.DocParagraph({ configuration: oldParagraph.configuration });
outputNodes.push(currentParagraph);
let SplitterState;
(function (SplitterState) {
SplitterState[SplitterState["Start"] = 0] = "Start";
SplitterState[SplitterState["AwaitingTrailer"] = 1] = "AwaitingTrailer";
SplitterState[SplitterState["ReadingTrailer"] = 2] = "ReadingTrailer";
})(SplitterState || (SplitterState = {}));
let state = SplitterState.Start;
let currentIndex = 0;
while (currentIndex < inputParagraphNodes.length) {
// Scan forwards to the end of the line
let isBlankLine = true;
let lineEndIndex = currentIndex; // non-inclusive
do {
const node = inputParagraphNodes[lineEndIndex++];
if (node.kind === nodes_1.DocNodeKind.SoftBreak) {
break;
}
if (isBlankLine) {
if (!this._isWhitespace(node)) {
isBlankLine = false;
}
}
} while (lineEndIndex < inputParagraphNodes.length);
// At this point, the line and SoftBreak will be in inputParagraphNodes.slice(currentIndex, lineEndIndex)
switch (state) {
case SplitterState.Start:
// We're skipping any blank lines that start the first paragraph
if (!isBlankLine) {
state = SplitterState.AwaitingTrailer;
}
break;
case SplitterState.AwaitingTrailer:
// We already saw some content, so now we're looking for a blank line that starts the trailer
// at the end of this paragraph
if (isBlankLine) {
state = SplitterState.ReadingTrailer;
}
break;
case SplitterState.ReadingTrailer:
// We already found the trailer, so now we're looking for a non-blank line that will
// begin a new paragraph
if (!isBlankLine) {
// Start a new paragraph
currentParagraph = new nodes_1.DocParagraph({ configuration: oldParagraph.configuration });
outputNodes.push(currentParagraph);
state = SplitterState.AwaitingTrailer;
}
break;
}
// Append the line onto the current paragraph
for (let i = currentIndex; i < lineEndIndex; ++i) {
currentParagraph.appendNode(inputParagraphNodes[i]);
}
currentIndex = lineEndIndex;
}
}
static _isWhitespace(node) {
switch (node.kind) {
case nodes_1.DocNodeKind.PlainText:
const docPlainText = node;
return ParagraphSplitter._whitespaceRegExp.test(docPlainText.text);
default:
return false;
}
}
}
exports.ParagraphSplitter = ParagraphSplitter;
ParagraphSplitter._whitespaceRegExp = /^\s*$/;
//# sourceMappingURL=ParagraphSplitter.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,35 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParserContext = void 0;
const TextRange_1 = require("./TextRange");
const nodes_1 = require("../nodes");
const ParserMessageLog_1 = require("./ParserMessageLog");
/**
* An internal data structure that tracks all the state being built up by the various
* parser stages.
*/
class ParserContext {
constructor(configuration, sourceRange) {
/**
* The text range starting from the opening `/**` and ending with
* the closing `*\/` delimiter.
*/
this.commentRange = TextRange_1.TextRange.empty;
/**
* The text ranges corresponding to the lines of content inside the comment.
*/
this.lines = [];
/**
* A complete list of all tokens that were extracted from the input lines.
*/
this.tokens = [];
this.configuration = configuration;
this.sourceRange = sourceRange;
this.docComment = new nodes_1.DocComment({ configuration: this.configuration });
this.log = new ParserMessageLog_1.ParserMessageLog();
}
}
exports.ParserContext = ParserContext;
//# sourceMappingURL=ParserContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ParserContext.js","sourceRoot":"","sources":["../../src/parser/ParserContext.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,2CAAwC;AAExC,oCAAsC;AAEtC,yDAAsD;AAEtD;;;GAGG;AACH,MAAa,aAAa;IAqCxB,YAAmB,aAAiC,EAAE,WAAsB;QA1B5E;;;WAGG;QACI,iBAAY,GAAc,qBAAS,CAAC,KAAK,CAAC;QAEjD;;WAEG;QACI,UAAK,GAAgB,EAAE,CAAC;QAE/B;;WAEG;QACI,WAAM,GAAY,EAAE,CAAC;QAa1B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,IAAI,CAAC,UAAU,GAAG,IAAI,kBAAU,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QAExE,IAAI,CAAC,GAAG,GAAG,IAAI,mCAAgB,EAAE,CAAC;IACpC,CAAC;CACF;AA7CD,sCA6CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { TextRange } from './TextRange';\r\nimport type { Token } from './Token';\r\nimport { DocComment } from '../nodes';\r\nimport type { TSDocConfiguration } from '../configuration/TSDocConfiguration';\r\nimport { ParserMessageLog } from './ParserMessageLog';\r\n\r\n/**\r\n * An internal data structure that tracks all the state being built up by the various\r\n * parser stages.\r\n */\r\nexport class ParserContext {\r\n /**\r\n * The configuration that was provided for the TSDocParser.\r\n */\r\n public readonly configuration: TSDocConfiguration;\r\n\r\n /**\r\n * The `sourceRange` indicates the start and end of the original input that was parsed.\r\n */\r\n public readonly sourceRange: TextRange;\r\n\r\n /**\r\n * The text range starting from the opening `/**` and ending with\r\n * the closing `*\\/` delimiter.\r\n */\r\n public commentRange: TextRange = TextRange.empty;\r\n\r\n /**\r\n * The text ranges corresponding to the lines of content inside the comment.\r\n */\r\n public lines: TextRange[] = [];\r\n\r\n /**\r\n * A complete list of all tokens that were extracted from the input lines.\r\n */\r\n public tokens: Token[] = [];\r\n\r\n /**\r\n * The parsed doc comment object. This is the primary output of the parser.\r\n */\r\n public readonly docComment: DocComment;\r\n\r\n /**\r\n * A queryable log that reports warnings and error messages that occurred during parsing.\r\n */\r\n public readonly log: ParserMessageLog;\r\n\r\n public constructor(configuration: TSDocConfiguration, sourceRange: TextRange) {\r\n this.configuration = configuration;\r\n this.sourceRange = sourceRange;\r\n\r\n this.docComment = new DocComment({ configuration: this.configuration });\r\n\r\n this.log = new ParserMessageLog();\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,55 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParserMessage = void 0;
/**
* Represents an error or warning that occurred during parsing.
*/
class ParserMessage {
constructor(parameters) {
this.messageId = parameters.messageId;
this.unformattedText = parameters.messageText;
this.textRange = parameters.textRange;
this.tokenSequence = parameters.tokenSequence;
this.docNode = parameters.docNode;
this._text = undefined;
}
/**
* Generates a line/column prefix. Example with line=2 and column=5
* and message="An error occurred":
* ```
* "(2,5): An error occurred"
* ```
*/
static _formatMessageText(message, range) {
if (!message) {
message = 'An unknown error occurred';
}
if (range.pos !== 0 || range.end !== 0) {
// NOTE: This currently a potentially expensive operation, since TSDoc currently doesn't
// have a full newline analysis for the input buffer.
const location = range.getLocation(range.pos);
if (location.line) {
return `(${location.line},${location.column}): ` + message;
}
}
return message;
}
/**
* The message text.
*/
get text() {
if (this._text === undefined) {
// NOTE: This currently a potentially expensive operation, since TSDoc currently doesn't
// have a full newline analysis for the input buffer.
this._text = ParserMessage._formatMessageText(this.unformattedText, this.textRange);
}
return this._text;
}
toString() {
return this.text;
}
}
exports.ParserMessage = ParserMessage;
//# sourceMappingURL=ParserMessage.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ParserMessage.js","sourceRoot":"","sources":["../../src/parser/ParserMessage.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAkB3D;;GAEG;AACH,MAAa,aAAa;IAmBxB,YAAmB,UAAoC;QACrD,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,WAAW,CAAC;QAC9C,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACK,MAAM,CAAC,kBAAkB,CAAC,OAAe,EAAE,KAAgB;QACjE,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,2BAA2B,CAAC;QACxC,CAAC;QAED,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC;YACvC,wFAAwF;YACxF,qDAAqD;YACrD,MAAM,QAAQ,GAAkB,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC7D,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAClB,OAAO,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC;YAC7D,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACb,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,wFAAwF;YACxF,qDAAqD;YACrD,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACtF,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF;AAlED,sCAkEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { TextRange, ITextLocation } from './TextRange';\r\nimport type { TokenSequence } from './TokenSequence';\r\nimport type { DocNode } from '../nodes/DocNode';\r\nimport type { TSDocMessageId } from './TSDocMessageId';\r\n\r\n/**\r\n * Constructor parameters for {@link ParserMessage}.\r\n */\r\nexport interface IParserMessageParameters {\r\n messageId: TSDocMessageId;\r\n messageText: string;\r\n textRange: TextRange;\r\n tokenSequence?: TokenSequence;\r\n docNode?: DocNode;\r\n}\r\n\r\n/**\r\n * Represents an error or warning that occurred during parsing.\r\n */\r\nexport class ParserMessage {\r\n /**\r\n * A string that uniquely identifies the messages reported by the TSDoc parser.\r\n */\r\n public readonly messageId: TSDocMessageId;\r\n\r\n /**\r\n * The message text without the default prefix that shows line/column information.\r\n */\r\n public readonly unformattedText: string;\r\n\r\n public readonly textRange: TextRange;\r\n\r\n public readonly tokenSequence: TokenSequence | undefined;\r\n\r\n public readonly docNode: DocNode | undefined;\r\n\r\n private _text: string | undefined;\r\n\r\n public constructor(parameters: IParserMessageParameters) {\r\n this.messageId = parameters.messageId;\r\n this.unformattedText = parameters.messageText;\r\n this.textRange = parameters.textRange;\r\n this.tokenSequence = parameters.tokenSequence;\r\n this.docNode = parameters.docNode;\r\n this._text = undefined;\r\n }\r\n\r\n /**\r\n * Generates a line/column prefix. Example with line=2 and column=5\r\n * and message=\"An error occurred\":\r\n * ```\r\n * \"(2,5): An error occurred\"\r\n * ```\r\n */\r\n private static _formatMessageText(message: string, range: TextRange): string {\r\n if (!message) {\r\n message = 'An unknown error occurred';\r\n }\r\n\r\n if (range.pos !== 0 || range.end !== 0) {\r\n // NOTE: This currently a potentially expensive operation, since TSDoc currently doesn't\r\n // have a full newline analysis for the input buffer.\r\n const location: ITextLocation = range.getLocation(range.pos);\r\n if (location.line) {\r\n return `(${location.line},${location.column}): ` + message;\r\n }\r\n }\r\n return message;\r\n }\r\n\r\n /**\r\n * The message text.\r\n */\r\n public get text(): string {\r\n if (this._text === undefined) {\r\n // NOTE: This currently a potentially expensive operation, since TSDoc currently doesn't\r\n // have a full newline analysis for the input buffer.\r\n this._text = ParserMessage._formatMessageText(this.unformattedText, this.textRange);\r\n }\r\n return this._text;\r\n }\r\n\r\n public toString(): string {\r\n return this.text;\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,72 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParserMessageLog = void 0;
const ParserMessage_1 = require("./ParserMessage");
/**
* Used to report errors and warnings that occurred during parsing.
*/
class ParserMessageLog {
constructor() {
this._messages = [];
}
/**
* The unfiltered list of all messages.
*/
get messages() {
return this._messages;
}
/**
* Append a message to the log.
*/
addMessage(parserMessage) {
this._messages.push(parserMessage);
}
/**
* Append a message associated with a TextRange.
*/
addMessageForTextRange(messageId, messageText, textRange) {
this.addMessage(new ParserMessage_1.ParserMessage({
messageId,
messageText,
textRange
}));
}
/**
* Append a message associated with a TokenSequence.
*/
addMessageForTokenSequence(messageId, messageText, tokenSequence, docNode) {
this.addMessage(new ParserMessage_1.ParserMessage({
messageId,
messageText,
textRange: tokenSequence.getContainingTextRange(),
tokenSequence,
docNode
}));
}
/**
* Append a message associated with a TokenSequence.
*/
addMessageForDocErrorText(docErrorText) {
let tokenSequence;
if (docErrorText.textExcerpt) {
// If there is an excerpt directly associated with the DocErrorText, highlight that:
tokenSequence = docErrorText.textExcerpt;
}
else {
// Otherwise we can use the errorLocation, but typically that is meant to give additional
// details, not to indicate the primary location of the problem.
tokenSequence = docErrorText.errorLocation;
}
this.addMessage(new ParserMessage_1.ParserMessage({
messageId: docErrorText.messageId,
messageText: docErrorText.errorMessage,
textRange: tokenSequence.getContainingTextRange(),
tokenSequence: tokenSequence,
docNode: docErrorText
}));
}
}
exports.ParserMessageLog = ParserMessageLog;
//# sourceMappingURL=ParserMessageLog.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ParserMessageLog.js","sourceRoot":"","sources":["../../src/parser/ParserMessageLog.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,mDAAgD;AAOhD;;GAEG;AACH,MAAa,gBAAgB;IAA7B;QACU,cAAS,GAAoB,EAAE,CAAC;IA0E1C,CAAC;IAxEC;;OAEG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;OAEG;IACI,UAAU,CAAC,aAA4B;QAC5C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,sBAAsB,CAAC,SAAyB,EAAE,WAAmB,EAAE,SAAoB;QAChG,IAAI,CAAC,UAAU,CACb,IAAI,6BAAa,CAAC;YAChB,SAAS;YACT,WAAW;YACX,SAAS;SACV,CAAC,CACH,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,0BAA0B,CAC/B,SAAyB,EACzB,WAAmB,EACnB,aAA4B,EAC5B,OAAiB;QAEjB,IAAI,CAAC,UAAU,CACb,IAAI,6BAAa,CAAC;YAChB,SAAS;YACT,WAAW;YACX,SAAS,EAAE,aAAa,CAAC,sBAAsB,EAAE;YACjD,aAAa;YACb,OAAO;SACR,CAAC,CACH,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,yBAAyB,CAAC,YAA0B;QACzD,IAAI,aAA4B,CAAC;QAEjC,IAAI,YAAY,CAAC,WAAW,EAAE,CAAC;YAC7B,oFAAoF;YACpF,aAAa,GAAG,YAAY,CAAC,WAAW,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,yFAAyF;YACzF,gEAAgE;YAChE,aAAa,GAAG,YAAY,CAAC,aAAa,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC,UAAU,CACb,IAAI,6BAAa,CAAC;YAChB,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,WAAW,EAAE,YAAY,CAAC,YAAY;YACtC,SAAS,EAAE,aAAa,CAAC,sBAAsB,EAAE;YACjD,aAAa,EAAE,aAAa;YAC5B,OAAO,EAAE,YAAY;SACtB,CAAC,CACH,CAAC;IACJ,CAAC;CACF;AA3ED,4CA2EC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { ParserMessage } from './ParserMessage';\r\nimport type { TextRange } from './TextRange';\r\nimport type { TokenSequence } from './TokenSequence';\r\nimport type { DocNode } from '../nodes/DocNode';\r\nimport type { DocErrorText } from '../nodes/DocErrorText';\r\nimport type { TSDocMessageId } from './TSDocMessageId';\r\n\r\n/**\r\n * Used to report errors and warnings that occurred during parsing.\r\n */\r\nexport class ParserMessageLog {\r\n private _messages: ParserMessage[] = [];\r\n\r\n /**\r\n * The unfiltered list of all messages.\r\n */\r\n public get messages(): ReadonlyArray<ParserMessage> {\r\n return this._messages;\r\n }\r\n\r\n /**\r\n * Append a message to the log.\r\n */\r\n public addMessage(parserMessage: ParserMessage): void {\r\n this._messages.push(parserMessage);\r\n }\r\n\r\n /**\r\n * Append a message associated with a TextRange.\r\n */\r\n public addMessageForTextRange(messageId: TSDocMessageId, messageText: string, textRange: TextRange): void {\r\n this.addMessage(\r\n new ParserMessage({\r\n messageId,\r\n messageText,\r\n textRange\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Append a message associated with a TokenSequence.\r\n */\r\n public addMessageForTokenSequence(\r\n messageId: TSDocMessageId,\r\n messageText: string,\r\n tokenSequence: TokenSequence,\r\n docNode?: DocNode\r\n ): void {\r\n this.addMessage(\r\n new ParserMessage({\r\n messageId,\r\n messageText,\r\n textRange: tokenSequence.getContainingTextRange(),\r\n tokenSequence,\r\n docNode\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Append a message associated with a TokenSequence.\r\n */\r\n public addMessageForDocErrorText(docErrorText: DocErrorText): void {\r\n let tokenSequence: TokenSequence;\r\n\r\n if (docErrorText.textExcerpt) {\r\n // If there is an excerpt directly associated with the DocErrorText, highlight that:\r\n tokenSequence = docErrorText.textExcerpt;\r\n } else {\r\n // Otherwise we can use the errorLocation, but typically that is meant to give additional\r\n // details, not to indicate the primary location of the problem.\r\n tokenSequence = docErrorText.errorLocation;\r\n }\r\n\r\n this.addMessage(\r\n new ParserMessage({\r\n messageId: docErrorText.messageId,\r\n messageText: docErrorText.errorMessage,\r\n textRange: tokenSequence.getContainingTextRange(),\r\n tokenSequence: tokenSequence,\r\n docNode: docErrorText\r\n })\r\n );\r\n }\r\n}\r\n"]}

View File

@@ -0,0 +1,179 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.StringChecks = void 0;
/**
* Helpers for validating various text string formats.
*/
class StringChecks {
/**
* Tests whether the input string is a valid TSDoc tag name; if not, returns an error message.
* TSDoc tag names start with an at-sign ("@") followed by ASCII letters using
* "camelCase" capitalization.
*/
static explainIfInvalidTSDocTagName(tagName) {
if (tagName[0] !== '@') {
return 'A TSDoc tag name must start with an "@" symbol';
}
if (!StringChecks._tsdocTagNameRegExp.test(tagName)) {
return 'A TSDoc tag name must start with a letter and contain only letters and numbers';
}
return undefined;
}
/**
* Throws an exception if the input string is not a valid TSDoc tag name.
* TSDoc tag names start with an at-sign ("@") followed by ASCII letters using
* "camelCase" capitalization.
*/
static validateTSDocTagName(tagName) {
const explanation = StringChecks.explainIfInvalidTSDocTagName(tagName);
if (explanation) {
throw new Error(explanation);
}
}
/**
* Tests whether the input string is a URL form supported inside an "@link" tag; if not,
* returns an error message.
*/
static explainIfInvalidLinkUrl(url) {
if (url.length === 0) {
return 'The URL cannot be empty';
}
if (!StringChecks._urlSchemeRegExp.test(url)) {
return ('An @link URL must begin with a scheme comprised only of letters and numbers followed by "://".' +
' (For general URLs, use an HTML "<a>" tag instead.)');
}
if (!StringChecks._urlSchemeAfterRegExp.test(url)) {
return 'An @link URL must have at least one character after "://"';
}
return undefined;
}
/**
* Tests whether the input string is a valid HTML element or attribute name.
*/
static explainIfInvalidHtmlName(htmlName) {
if (!StringChecks._htmlNameRegExp.test(htmlName)) {
return 'An HTML name must be an ASCII letter followed by zero or more letters, digits, or hyphens';
}
return undefined;
}
/**
* Throws an exception if the input string is a not valid HTML element or attribute name.
*/
static validateHtmlName(htmlName) {
const explanation = StringChecks.explainIfInvalidHtmlName(htmlName);
if (explanation) {
throw new Error(explanation);
}
}
/**
* Tests whether the input string is a valid NPM package name.
*/
static explainIfInvalidPackageName(packageName) {
if (packageName.length === 0) {
return 'The package name cannot be an empty string';
}
if (!StringChecks._validPackageNameRegExp.test(packageName)) {
return `The package name ${JSON.stringify(packageName)} is not a valid package name`;
}
return undefined;
}
/**
* Tests whether the input string is a valid declaration reference import path.
*/
static explainIfInvalidImportPath(importPath, prefixedByPackageName) {
if (importPath.length > 0) {
if (importPath.indexOf('//') >= 0) {
return 'An import path must not contain "//"';
}
if (importPath[importPath.length - 1] === '/') {
return 'An import path must not end with "/"';
}
if (!prefixedByPackageName) {
if (importPath[0] === '/') {
return 'An import path must not start with "/" unless prefixed by a package name';
}
}
}
return undefined;
}
/**
* Returns true if the input string is a TSDoc system selector.
*/
static isSystemSelector(selector) {
return StringChecks._systemSelectors.has(selector);
}
/**
* Tests whether the input string is a valid ECMAScript identifier.
* A precise check is extremely complicated and highly dependent on the standard version
* and how faithfully the interpreter implements it, so here we use a conservative heuristic.
*/
static explainIfInvalidUnquotedIdentifier(identifier) {
if (identifier.length === 0) {
return 'The identifier cannot be an empty string';
}
if (StringChecks._identifierBadCharRegExp.test(identifier)) {
return 'The identifier cannot non-word characters';
}
if (StringChecks._identifierNumberStartRegExp.test(identifier)) {
return 'The identifier must not start with a number';
}
return undefined;
}
/**
* Tests whether the input string can be used without quotes as a member identifier in a declaration reference.
* If not, it should be enclosed in quotes.
*/
static explainIfInvalidUnquotedMemberIdentifier(identifier) {
const explanation = StringChecks.explainIfInvalidUnquotedIdentifier(identifier);
if (explanation !== undefined) {
return explanation;
}
if (StringChecks.isSystemSelector(identifier)) {
// We do this to avoid confusion about the declaration reference syntax rules.
// For example if someone were to see "MyClass.(static:instance)" it would be unclear which
// side the colon is the selector.
return `The identifier "${identifier}" must be quoted because it is a TSDoc system selector name`;
}
return undefined;
}
}
exports.StringChecks = StringChecks;
StringChecks._tsdocTagNameRegExp = /^@[a-z][a-z0-9]*$/i;
StringChecks._urlSchemeRegExp = /^[a-z][a-z0-9]*\:\/\//i;
StringChecks._urlSchemeAfterRegExp = /^[a-z][a-z0-9]*\:\/\/./i;
// HTML element definitions:
// https://spec.commonmark.org/0.29/#tag-name
// https://www.w3.org/TR/html5/syntax.html#tag-name
// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
//
// We use the CommonMark spec:
// "A tag name consists of an ASCII letter followed by zero or more ASCII letters, digits, or hyphens (-)."
StringChecks._htmlNameRegExp = /^[a-z]+[a-z0-9\-]*$/i;
// Note: In addition to letters, numbers, underscores, and dollar signs, modern ECMAScript
// also allows Unicode categories such as letters, combining marks, digits, and connector punctuation.
// These are mostly supported in all environments except IE11, so if someone wants it, we would accept
// a PR to allow them (although the test surface might be somewhat large).
StringChecks._identifierBadCharRegExp = /[^a-z0-9_$]/i;
// Identifiers most not start with a number.
StringChecks._identifierNumberStartRegExp = /^[0-9]/;
// For detailed notes about NPM package name syntax, see:
// tslint:disable-next-line:max-line-length
// https://github.com/Microsoft/web-build-tools/blob/a417ca25c63aca31dba43a34d39cc9cd529b9c78/libraries/node-core-library/src/PackageName.ts
StringChecks._validPackageNameRegExp = /^(?:@[a-z0-9\-_\.]+\/)?[a-z0-9\-_\.]+$/i;
StringChecks._systemSelectors = new Set([
// For classes:
'instance',
'static',
'constructor',
// For merged declarations:
'class',
'enum',
'function',
'interface',
'namespace',
'type',
'variable'
]);
//# sourceMappingURL=StringChecks.js.map

Some files were not shown because too many files have changed in this diff Show More