This commit is contained in:
2024-02-07 01:33:07 -05:00
commit c1af19d441
4088 changed files with 1260170 additions and 0 deletions

View File

@ -0,0 +1,44 @@
import { DocNode } from '../nodes/DocNode';
export declare type DocNodeConstructor = new (...args: any[]) => DocNode;
export interface IDocNodeDefinition {
docNodeKind: string;
constructor: DocNodeConstructor;
}
/**
* 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.
*/
export declare class DocNodeManager {
private static readonly _nodeKindRegExp;
private readonly _docNodeDefinitionsByKind;
private readonly _docNodeDefinitionsByConstructor;
/**
* Registers a list of {@link IDocNodeDefinition} objects to be used with the associated
* {@link TSDocConfiguration} object.
*/
registerDocNodes(packageName: string, definitions: ReadonlyArray<IDocNodeDefinition>): void;
/**
* Reports an error if the specified DocNode kind has not been registered.
*/
throwIfNotRegisteredKind(docNodeKind: string): void;
/**
* 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: string, childKinds: ReadonlyArray<string>): void;
/**
* Returns true if the specified DocNode kind has been registered as an allowable child of the specified
* parent DocNode kind.
*/
isAllowedChild(parentKind: string, childKind: string): boolean;
private _getDefinition;
}
//# sourceMappingURL=DocNodeManager.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"DocNodeManager.d.ts","sourceRoot":"","sources":["../../src/configuration/DocNodeManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,oBAAY,kBAAkB,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;AAEjE,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,kBAAkB,CAAC;CACjC;AASD;;;;;;;GAOG;AACH,qBAAa,cAAc;IAIzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAiC;IAExE,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAGtC;IACJ,OAAO,CAAC,QAAQ,CAAC,gCAAgC,CAGe;IAEhE;;;OAGG;IACI,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,CAAC,kBAAkB,CAAC,GAAG,IAAI;IA6ClG;;OAEG;IACI,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAM1D;;;;;;;OAOG;IACI,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI;IAS7F;;;OAGG;IACI,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAKrE,OAAO,CAAC,cAAc;CASvB"}

View File

@ -0,0 +1,96 @@
import { StringChecks } from '../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.
*/
var DocNodeManager = /** @class */ (function () {
function DocNodeManager() {
this._docNodeDefinitionsByKind = new Map();
this._docNodeDefinitionsByConstructor = new Map();
}
/**
* Registers a list of {@link IDocNodeDefinition} objects to be used with the associated
* {@link TSDocConfiguration} object.
*/
DocNodeManager.prototype.registerDocNodes = function (packageName, definitions) {
var packageNameError = StringChecks.explainIfInvalidPackageName(packageName);
if (packageNameError) {
throw new Error('Invalid NPM package name: ' + packageNameError);
}
for (var _i = 0, definitions_1 = definitions; _i < definitions_1.length; _i++) {
var definition = definitions_1[_i];
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");
}
var 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));
}
var newDefinition = {
docNodeKind: definition.docNodeKind,
constructor: definition.constructor,
packageName: 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.
*/
DocNodeManager.prototype.throwIfNotRegisteredKind = function (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.
*/
DocNodeManager.prototype.registerAllowableChildren = function (parentKind, childKinds) {
var parentDefinition = this._getDefinition(parentKind);
for (var _i = 0, childKinds_1 = childKinds; _i < childKinds_1.length; _i++) {
var childKind = childKinds_1[_i];
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.
*/
DocNodeManager.prototype.isAllowedChild = function (parentKind, childKind) {
var parentDefinition = this._getDefinition(parentKind);
return parentDefinition.allowedChildKinds.has(childKind);
};
DocNodeManager.prototype._getDefinition = function (docNodeKind) {
var definition = this._docNodeDefinitionsByKind.get(docNodeKind);
if (definition === undefined) {
throw new Error("The DocNode kind \"" + docNodeKind + "\" was not registered with this TSDocConfiguration");
}
return definition;
};
// Matches an ASCII TypeScript-style identifier.
//
// Example: "_myIdentifier99"
DocNodeManager._nodeKindRegExp = /^[_a-z][_a-z0-9]*$/i;
return DocNodeManager;
}());
export { DocNodeManager };
//# sourceMappingURL=DocNodeManager.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,133 @@
import { TSDocTagDefinition } from './TSDocTagDefinition';
import { TSDocValidationConfiguration } from './TSDocValidationConfiguration';
import { DocNodeManager } from './DocNodeManager';
import { TSDocMessageId } from '../parser/TSDocMessageId';
/**
* Configuration for the TSDocParser.
*/
export declare class TSDocConfiguration {
private readonly _tagDefinitions;
private readonly _tagDefinitionsByName;
private readonly _supportedTagDefinitions;
private readonly _validation;
private readonly _docNodeManager;
private readonly _supportedHtmlElements;
constructor();
/**
* 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?: boolean): void;
/**
* The TSDoc tags that are defined in this configuration.
*
* @remarks
* The subset of "supported" tags is tracked by {@link TSDocConfiguration.supportedTagDefinitions}.
*/
get tagDefinitions(): ReadonlyArray<TSDocTagDefinition>;
/**
* 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(): ReadonlyArray<TSDocTagDefinition>;
/**
* Enable/disable validation checks performed by the parser.
*/
get validation(): TSDocValidationConfiguration;
/**
* The HTML element names that are supported in this configuration. Used in conjunction with the `reportUnsupportedHtmlElements` setting.
*/
get supportedHtmlElements(): string[];
/**
* Register custom DocNode subclasses.
*/
get docNodeManager(): DocNodeManager;
/**
* Return the tag that was defined with the specified name, or undefined
* if not found.
*/
tryGetTagDefinition(tagName: string): TSDocTagDefinition | undefined;
/**
* Return the tag that was defined with the specified name, or undefined
* if not found.
*/
tryGetTagDefinitionWithUpperCase(alreadyUpperCaseTagName: string): TSDocTagDefinition | undefined;
/**
* 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: TSDocTagDefinition): void;
/**
* 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: ReadonlyArray<TSDocTagDefinition>, supported?: boolean | undefined): void;
/**
* Returns true if the tag is supported in this configuration.
*/
isTagSupported(tagDefinition: TSDocTagDefinition): boolean;
/**
* 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: TSDocTagDefinition, supported: boolean): void;
/**
* 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: ReadonlyArray<TSDocTagDefinition>, supported: boolean): void;
/**
* Assigns the `supportedHtmlElements` property, replacing any previous elements.
* This operation sets {@link TSDocValidationConfiguration.reportUnsupportedHtmlElements} to `true`.
*/
setSupportedHtmlElements(htmlTags: string[]): void;
/**
* Returns true if the html element is supported in this configuration.
*/
isHtmlElementSupported(htmlTag: string): boolean;
/**
* 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: TSDocMessageId | string): boolean;
/**
* 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(): ReadonlyArray<TSDocMessageId>;
private _requireTagToBeDefined;
}
//# sourceMappingURL=TSDocConfiguration.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"TSDocConfiguration.d.ts","sourceRoot":"","sources":["../../src/configuration/TSDocConfiguration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,cAAc,EAA6C,MAAM,0BAA0B,CAAC;AAErG;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuB;IACvD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAkC;IACxE,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA0B;IACnE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+B;IAC3D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAc;;IAgBrD;;;;OAIG;IACI,KAAK,CAAC,cAAc,GAAE,OAAe,GAAG,IAAI;IAenD;;;;;OAKG;IACH,IAAW,cAAc,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAE7D;IAED;;;;;;;OAOG;IACH,IAAW,uBAAuB,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAEtE;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,4BAA4B,CAEpD;IAED;;OAEG;IACH,IAAW,qBAAqB,IAAI,MAAM,EAAE,CAE3C;IAED;;OAEG;IACH,IAAW,cAAc,IAAI,cAAc,CAE1C;IAED;;;OAGG;IACI,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAI3E;;;OAGG;IACI,gCAAgC,CAAC,uBAAuB,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIxG;;;;;;;OAOG;IACI,gBAAgB,CAAC,aAAa,EAAE,kBAAkB,GAAG,IAAI;IAiBhE;;;;;;OAMG;IACI,iBAAiB,CACtB,cAAc,EAAE,aAAa,CAAC,kBAAkB,CAAC,EACjD,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAC9B,IAAI;IAUP;;OAEG;IACI,cAAc,CAAC,aAAa,EAAE,kBAAkB,GAAG,OAAO;IAKjE;;;;;;;;;;OAUG;IACI,gBAAgB,CAAC,aAAa,EAAE,kBAAkB,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;IAWpF;;;;;;;;OAQG;IACI,iBAAiB,CAAC,cAAc,EAAE,aAAa,CAAC,kBAAkB,CAAC,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;IAMrG;;;OAGG;IACI,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;IAQzD;;OAEG;IACI,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIvD;;;;;;;;OAQG;IACI,gBAAgB,CAAC,SAAS,EAAE,cAAc,GAAG,MAAM,GAAG,OAAO;IAIpE;;;;;;;OAOG;IACH,IAAW,kBAAkB,IAAI,aAAa,CAAC,cAAc,CAAC,CAE7D;IAED,OAAO,CAAC,sBAAsB;CAW/B"}

View File

@ -0,0 +1,248 @@
import { StandardTags } from '../details/StandardTags';
import { TSDocValidationConfiguration } from './TSDocValidationConfiguration';
import { DocNodeManager } from './DocNodeManager';
import { BuiltInDocNodes } from '../nodes/BuiltInDocNodes';
import { allTsdocMessageIds, allTsdocMessageIdsSet } from '../parser/TSDocMessageId';
/**
* Configuration for the TSDocParser.
*/
var TSDocConfiguration = /** @class */ (function () {
function TSDocConfiguration() {
this._tagDefinitions = [];
this._tagDefinitionsByName = new Map();
this._supportedTagDefinitions = new Set();
this._validation = new TSDocValidationConfiguration();
this._docNodeManager = new DocNodeManager();
this._supportedHtmlElements = new Set();
this.clear(false);
// Register the built-in node kinds
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.
*/
TSDocConfiguration.prototype.clear = function (noStandardTags) {
if (noStandardTags === void 0) { 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.allDefinitions);
}
};
Object.defineProperty(TSDocConfiguration.prototype, "tagDefinitions", {
/**
* The TSDoc tags that are defined in this configuration.
*
* @remarks
* The subset of "supported" tags is tracked by {@link TSDocConfiguration.supportedTagDefinitions}.
*/
get: function () {
return this._tagDefinitions;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TSDocConfiguration.prototype, "supportedTagDefinitions", {
/**
* 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: function () {
var _this = this;
return this.tagDefinitions.filter(function (x) { return _this.isTagSupported(x); });
},
enumerable: false,
configurable: true
});
Object.defineProperty(TSDocConfiguration.prototype, "validation", {
/**
* Enable/disable validation checks performed by the parser.
*/
get: function () {
return this._validation;
},
enumerable: false,
configurable: true
});
Object.defineProperty(TSDocConfiguration.prototype, "supportedHtmlElements", {
/**
* The HTML element names that are supported in this configuration. Used in conjunction with the `reportUnsupportedHtmlElements` setting.
*/
get: function () {
return Array.from(this._supportedHtmlElements.values());
},
enumerable: false,
configurable: true
});
Object.defineProperty(TSDocConfiguration.prototype, "docNodeManager", {
/**
* Register custom DocNode subclasses.
*/
get: function () {
return this._docNodeManager;
},
enumerable: false,
configurable: true
});
/**
* Return the tag that was defined with the specified name, or undefined
* if not found.
*/
TSDocConfiguration.prototype.tryGetTagDefinition = function (tagName) {
return this._tagDefinitionsByName.get(tagName.toUpperCase());
};
/**
* Return the tag that was defined with the specified name, or undefined
* if not found.
*/
TSDocConfiguration.prototype.tryGetTagDefinitionWithUpperCase = function (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.
*/
TSDocConfiguration.prototype.addTagDefinition = function (tagDefinition) {
var 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
*/
TSDocConfiguration.prototype.addTagDefinitions = function (tagDefinitions, supported) {
for (var _i = 0, tagDefinitions_1 = tagDefinitions; _i < tagDefinitions_1.length; _i++) {
var tagDefinition = tagDefinitions_1[_i];
this.addTagDefinition(tagDefinition);
if (supported !== undefined) {
this.setSupportForTag(tagDefinition, supported);
}
}
};
/**
* Returns true if the tag is supported in this configuration.
*/
TSDocConfiguration.prototype.isTagSupported = function (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.
*/
TSDocConfiguration.prototype.setSupportForTag = function (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.
*/
TSDocConfiguration.prototype.setSupportForTags = function (tagDefinitions, supported) {
for (var _i = 0, tagDefinitions_2 = tagDefinitions; _i < tagDefinitions_2.length; _i++) {
var tagDefinition = tagDefinitions_2[_i];
this.setSupportForTag(tagDefinition, supported);
}
};
/**
* Assigns the `supportedHtmlElements` property, replacing any previous elements.
* This operation sets {@link TSDocValidationConfiguration.reportUnsupportedHtmlElements} to `true`.
*/
TSDocConfiguration.prototype.setSupportedHtmlElements = function (htmlTags) {
this._supportedHtmlElements.clear();
this._validation.reportUnsupportedHtmlElements = true;
for (var _i = 0, htmlTags_1 = htmlTags; _i < htmlTags_1.length; _i++) {
var htmlTag = htmlTags_1[_i];
this._supportedHtmlElements.add(htmlTag);
}
};
/**
* Returns true if the html element is supported in this configuration.
*/
TSDocConfiguration.prototype.isHtmlElementSupported = function (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.
*/
TSDocConfiguration.prototype.isKnownMessageId = function (messageId) {
return allTsdocMessageIdsSet.has(messageId);
};
Object.defineProperty(TSDocConfiguration.prototype, "allTsdocMessageIds", {
/**
* 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: function () {
return allTsdocMessageIds;
},
enumerable: false,
configurable: true
});
TSDocConfiguration.prototype._requireTagToBeDefined = function (tagDefinition) {
var matching = this._tagDefinitionsByName.get(tagDefinition.tagNameWithUpperCase);
if (matching) {
if (matching === tagDefinition) {
return;
}
}
throw new Error('The specified TSDocTagDefinition is not defined for this TSDocConfiguration');
};
return TSDocConfiguration;
}());
export { TSDocConfiguration };
//# sourceMappingURL=TSDocConfiguration.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,69 @@
import { Standardization } from '../details/Standardization';
/**
* Determines the type of syntax for a TSDocTagDefinition
*/
export declare enum TSDocTagSyntaxKind {
/**
* The tag is intended to be an inline tag. For example: `{@link}`.
*/
InlineTag = 0,
/**
* The tag is intended to be a block tag that starts a new documentation
* section. For example: `@remarks`
*/
BlockTag = 1,
/**
* The tag is intended to be a modifier tag whose presence indicates
* an aspect of the associated API item. For example: `@internal`
*/
ModifierTag = 2
}
/**
* Constructor parameters for {@link TSDocTagDefinition}
*/
export interface ITSDocTagDefinitionParameters {
tagName: string;
syntaxKind: TSDocTagSyntaxKind;
allowMultiple?: boolean;
}
/**
* @internal
*/
export interface ITSDocTagDefinitionInternalParameters extends ITSDocTagDefinitionParameters {
standardization: Standardization;
}
/**
* Defines a TSDoc tag that will be understood by the TSDocParser.
*/
export declare class TSDocTagDefinition {
/**
* The TSDoc tag name. TSDoc tag names start with an at-sign (`@`) followed
* by ASCII letters using "camelCase" capitalization.
*/
readonly tagName: string;
/**
* The TSDoc tag name in all capitals, which is used for performing
* case-insensitive comparisons or lookups.
*/
readonly tagNameWithUpperCase: string;
/**
* Specifies the expected syntax for this tag.
*/
readonly syntaxKind: TSDocTagSyntaxKind;
/**
* Indicates the level of support expected from documentation tools that implement
* the standard.
*/
readonly standardization: Standardization;
/**
* If true, then this TSDoc tag may appear multiple times in a doc comment.
* By default, a tag may only appear once.
*/
readonly allowMultiple: boolean;
constructor(parameters: ITSDocTagDefinitionParameters);
/**
* Throws an exception if `tagName` is not a valid TSDoc tag name.
*/
static validateTSDocTagName(tagName: string): void;
}
//# sourceMappingURL=TSDocTagDefinition.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"TSDocTagDefinition.d.ts","sourceRoot":"","sources":["../../src/configuration/TSDocTagDefinition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;GAEG;AACH,oBAAY,kBAAkB;IAC5B;;OAEG;IACH,SAAS,IAAA;IAET;;;OAGG;IACH,QAAQ,IAAA;IAER;;;OAGG;IACH,WAAW,IAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,kBAAkB,CAAC;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,qCAAsC,SAAQ,6BAA6B;IAC1F,eAAe,EAAE,eAAe,CAAC;CAClC;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAC7B;;;OAGG;IACH,SAAgB,OAAO,EAAE,MAAM,CAAC;IAEhC;;;OAGG;IACH,SAAgB,oBAAoB,EAAE,MAAM,CAAC;IAE7C;;OAEG;IACH,SAAgB,UAAU,EAAE,kBAAkB,CAAC;IAE/C;;;OAGG;IACH,SAAgB,eAAe,EAAE,eAAe,CAAC;IAEjD;;;OAGG;IACH,SAAgB,aAAa,EAAE,OAAO,CAAC;gBAEpB,UAAU,EAAE,6BAA6B;IAU5D;;OAEG;WACW,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAG1D"}

View File

@ -0,0 +1,45 @@
import { StringChecks } from '../parser/StringChecks';
import { Standardization } from '../details/Standardization';
/**
* Determines the type of syntax for a TSDocTagDefinition
*/
export 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 || (TSDocTagSyntaxKind = {}));
/**
* Defines a TSDoc tag that will be understood by the TSDocParser.
*/
var TSDocTagDefinition = /** @class */ (function () {
function TSDocTagDefinition(parameters) {
StringChecks.validateTSDocTagName(parameters.tagName);
this.tagName = parameters.tagName;
this.tagNameWithUpperCase = parameters.tagName.toUpperCase();
this.syntaxKind = parameters.syntaxKind;
this.standardization =
parameters.standardization || Standardization.None;
this.allowMultiple = !!parameters.allowMultiple;
}
/**
* Throws an exception if `tagName` is not a valid TSDoc tag name.
*/
TSDocTagDefinition.validateTSDocTagName = function (tagName) {
StringChecks.validateTSDocTagName(tagName);
};
return TSDocTagDefinition;
}());
export { TSDocTagDefinition };
//# sourceMappingURL=TSDocTagDefinition.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"TSDocTagDefinition.js","sourceRoot":"","sources":["../../src/configuration/TSDocTagDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAN,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,qEAAS,CAAA;IAET;;;OAGG;IACH,mEAAQ,CAAA;IAER;;;OAGG;IACH,yEAAW,CAAA;AACb,CAAC,EAjBW,kBAAkB,KAAlB,kBAAkB,QAiB7B;AAkBD;;GAEG;AACH;IA8BE,4BAAmB,UAAyC;QAC1D,YAAY,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,eAAe,CAAC,IAAI,CAAC;QAChG,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC;IAClD,CAAC;IAED;;OAEG;IACW,uCAAoB,GAAlC,UAAmC,OAAe;QAChD,YAAY,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IACH,yBAAC;AAAD,CAAC,AA9CD,IA8CC","sourcesContent":["import { 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,43 @@
/**
* Part of the {@link TSDocConfiguration} object.
*/
export declare class TSDocValidationConfiguration {
/**
* 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`
*/
ignoreUndefinedTags: boolean;
/**
* 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`
*/
reportUnsupportedTags: boolean;
/**
* Set `reportUnsupportedHtmlElements` to true to issue a warning for HTML elements which
* are not defined in your TSDoc configuration's `supportedHtmlElements` field.
*
* @defaultValue `false`
*/
reportUnsupportedHtmlElements: boolean;
}
//# sourceMappingURL=TSDocValidationConfiguration.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"TSDocValidationConfiguration.d.ts","sourceRoot":"","sources":["../../src/configuration/TSDocValidationConfiguration.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,4BAA4B;IACvC;;;;;;;;;;OAUG;IACI,mBAAmB,EAAE,OAAO,CAAS;IAE5C;;;;;;;;;;;;;;;;OAgBG;IACI,qBAAqB,EAAE,OAAO,CAAS;IAE9C;;;;;OAKG;IACI,6BAA6B,EAAE,OAAO,CAAS;CACvD"}

View File

@ -0,0 +1,47 @@
/**
* Part of the {@link TSDocConfiguration} object.
*/
var TSDocValidationConfiguration = /** @class */ (function () {
function TSDocValidationConfiguration() {
/**
* 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;
}
return TSDocValidationConfiguration;
}());
export { TSDocValidationConfiguration };
//# sourceMappingURL=TSDocValidationConfiguration.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"TSDocValidationConfiguration.js","sourceRoot":"","sources":["../../src/configuration/TSDocValidationConfiguration.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;IAAA;QACE;;;;;;;;;;WAUG;QACI,wBAAmB,GAAY,KAAK,CAAC;QAE5C;;;;;;;;;;;;;;;;WAgBG;QACI,0BAAqB,GAAY,KAAK,CAAC;QAE9C;;;;;WAKG;QACI,kCAA6B,GAAY,KAAK,CAAC;IACxD,CAAC;IAAD,mCAAC;AAAD,CAAC,AAxCD,IAwCC","sourcesContent":["/**\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"]}