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

348
node_modules/@microsoft/tsdoc-config/CHANGELOG.json generated vendored Normal file
View File

@@ -0,0 +1,348 @@
{
"name": "@microsoft/tsdoc-config",
"entries": [
{
"version": "0.18.0",
"tag": "@microsoft/tsdoc-config_v0.18.0",
"date": "Tue, 11 Nov 2025 00:51:42 GMT",
"comments": {
"minor": [
{
"comment": "Normalize builtin imports."
}
],
"patch": [
{
"comment": "Remove test files and declaration maps from the published package."
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" to `0.16.0`"
}
]
}
},
{
"version": "0.17.1",
"tag": "@microsoft/tsdoc-config_v0.17.1",
"date": "Sat, 23 Nov 2024 00:23:35 GMT",
"comments": {
"patch": [
{
"comment": "Include CHANGELOG.md in published releases again"
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" to `0.15.1`"
}
]
}
},
{
"version": "0.17.0",
"tag": "@microsoft/tsdoc-config_v0.17.0",
"date": "Tue, 28 May 2024 21:34:19 GMT",
"comments": {
"minor": [
{
"comment": "Minor package cleanup."
}
],
"patch": [
{
"comment": "Upgrade dev toolchain (Heft, Webpack, TypeScript)"
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" to `0.15.0`"
}
]
}
},
{
"version": "0.16.2",
"tag": "@microsoft/tsdoc-config_v0.16.2",
"date": "Wed, 14 Sep 2022 02:55:06 GMT",
"comments": {
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.14.1` to `0.14.2`"
}
]
}
},
{
"version": "0.16.1",
"tag": "@microsoft/tsdoc-config_v0.16.1",
"date": "Sat, 09 Apr 2022 02:28:41 GMT",
"comments": {
"patch": [
{
"comment": "Rename the \"master\" branch to \"main.\""
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.14.0` to `0.14.1`"
}
]
}
},
{
"version": "0.16.0",
"tag": "@microsoft/tsdoc-config_v0.16.0",
"date": "Thu, 07 Apr 2022 22:51:07 GMT",
"comments": {
"minor": [
{
"comment": "Add `supportedHtmlElements` and `reportUnsupportedHtmlElements` configuration options"
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.13.2` to `0.14.0`"
}
]
}
},
{
"version": "0.15.2",
"tag": "@microsoft/tsdoc-config_v0.15.2",
"date": "Tue, 20 Apr 2021 04:25:13 GMT",
"comments": {
"patch": [
{
"comment": "Improve reporting of tsdoc-config-unresolved-extends"
},
{
"comment": "Fix some issues with the logic for TSDocConfigFile.hasErrors and TSDocConfigFile.fileNotFound"
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.13.1` to `0.13.2`"
}
]
}
},
{
"version": "0.15.1",
"tag": "@microsoft/tsdoc-config_v0.15.1",
"date": "Mon, 19 Apr 2021 21:22:32 GMT",
"comments": {
"patch": [
{
"comment": "Improve reporting of error messages when loading tsdoc.json"
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.13.0` to `0.13.1`"
}
]
}
},
{
"version": "0.15.0",
"tag": "@microsoft/tsdoc-config_v0.15.0",
"date": "Fri, 16 Apr 2021 23:22:26 GMT",
"comments": {
"minor": [
{
"comment": "Add a new API TSDocConfigFile.loadFromObject()"
}
]
}
},
{
"version": "0.14.0",
"tag": "@microsoft/tsdoc-config_v0.14.0",
"date": "Fri, 22 Jan 2021 18:07:19 GMT",
"comments": {
"minor": [
{
"comment": "Update tsdoc.json schema to add a new field \"noStandardTags\""
},
{
"comment": "TSDocConfigFile.configureParser() now clears any previous state, and it only defines standard tags if \"noStandardTags\" is not true."
},
{
"comment": "Added new API TSDocConfigFile.updateParser() which preserves the previous configuration state"
},
{
"comment": "Add new \"supportForTags\" field to tsdoc.json schema"
},
{
"comment": "Add new APIs: TSDocConfigFile.supportForTags, .clearTagDefinitions(), .addTagDefinition(), .clearSupportForTags(), .setSupportForTag(), .loadFromParser(), .saveFile(), .saveToObject()"
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.12.24` to `0.13.0`"
}
]
}
},
{
"version": "0.13.9",
"tag": "@microsoft/tsdoc-config_v0.13.9",
"date": "Thu, 03 Dec 2020 08:07:55 GMT",
"comments": {
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.12.23` to `0.12.24`"
}
]
}
},
{
"version": "0.13.8",
"tag": "@microsoft/tsdoc-config_v0.13.8",
"date": "Thu, 03 Dec 2020 04:31:52 GMT",
"comments": {
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.12.22` to `0.12.23`"
}
]
}
},
{
"version": "0.13.7",
"tag": "@microsoft/tsdoc-config_v0.13.7",
"date": "Mon, 30 Nov 2020 06:16:21 GMT",
"comments": {
"patch": [
{
"comment": "Update documentation to reference the new website URL"
},
{
"comment": "Upgrade build tools and configuration"
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.12.21` to `0.12.22`"
}
]
}
},
{
"version": "0.13.6",
"tag": "@microsoft/tsdoc-config_v0.13.6",
"date": "Fri, 04 Sep 2020 15:53:27 GMT",
"comments": {
"patch": [
{
"comment": "Update build system"
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.12.20` to `0.12.21`"
}
]
}
},
{
"version": "0.13.5",
"tag": "@microsoft/tsdoc-config_v0.13.5",
"date": "Sun, 19 Jul 2020 01:22:35 GMT",
"comments": {
"patch": [
{
"comment": "Bump ajv dependency to ~6.12.3"
}
]
}
},
{
"version": "0.13.4",
"tag": "@microsoft/tsdoc-config_v0.13.4",
"date": "Wed, 20 May 2020 22:33:27 GMT",
"comments": {
"patch": [
{
"comment": "Fix typo"
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.12.19` to `0.12.20`"
}
]
}
},
{
"version": "0.13.3",
"tag": "@microsoft/tsdoc-config_v0.13.3",
"date": "Fri, 27 Mar 2020 23:14:53 GMT",
"comments": {
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.12.18` to `0.12.19`"
}
]
}
},
{
"version": "0.13.2",
"tag": "@microsoft/tsdoc-config_v0.13.2",
"date": "Sat, 22 Feb 2020 20:44:16 GMT",
"comments": {
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.12.17` to `0.12.18`"
}
]
}
},
{
"version": "0.13.1",
"tag": "@microsoft/tsdoc-config_v0.13.1",
"date": "Sat, 22 Feb 2020 02:55:07 GMT",
"comments": {
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.12.16` to `0.12.17`"
}
]
}
},
{
"version": "0.13.0",
"tag": "@microsoft/tsdoc-config_v0.13.0",
"date": "Tue, 21 Jan 2020 21:26:36 GMT",
"comments": {
"minor": [
{
"comment": "Improve tsdoc.json parser to allow JSON comments"
},
{
"comment": "Add a new API TSDocConfigFile.checkForModifiedFiles() to facilitate caching"
}
]
}
},
{
"version": "0.12.16",
"tag": "@microsoft/tsdoc-config_v0.12.16",
"date": "Tue, 19 Nov 2019 22:01:56 GMT",
"comments": {
"patch": [
{
"comment": "Initial release"
}
],
"dependency": [
{
"comment": "Updating dependency \"@microsoft/tsdoc\" from `0.12.15` to `0.12.16`"
}
]
}
}
]
}

154
node_modules/@microsoft/tsdoc-config/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,154 @@
# Change Log - @microsoft/tsdoc-config
This log was last generated on Tue, 11 Nov 2025 00:51:42 GMT and should not be manually modified.
## 0.18.0
Tue, 11 Nov 2025 00:51:42 GMT
### Minor changes
- Normalize builtin imports.
### Patches
- Remove test files and declaration maps from the published package.
## 0.17.1
Sat, 23 Nov 2024 00:23:35 GMT
### Patches
- Include CHANGELOG.md in published releases again
## 0.17.0
Tue, 28 May 2024 21:34:19 GMT
### Minor changes
- Minor package cleanup.
### Patches
- Upgrade dev toolchain (Heft, Webpack, TypeScript)
## 0.16.2
Wed, 14 Sep 2022 02:55:06 GMT
_Version update only_
## 0.16.1
Sat, 09 Apr 2022 02:28:41 GMT
### Patches
- Rename the "master" branch to "main."
## 0.16.0
Thu, 07 Apr 2022 22:51:07 GMT
### Minor changes
- Add `supportedHtmlElements` and `reportUnsupportedHtmlElements` configuration options
## 0.15.2
Tue, 20 Apr 2021 04:25:13 GMT
### Patches
- Improve reporting of tsdoc-config-unresolved-extends
- Fix some issues with the logic for TSDocConfigFile.hasErrors and TSDocConfigFile.fileNotFound
## 0.15.1
Mon, 19 Apr 2021 21:22:32 GMT
### Patches
- Improve reporting of error messages when loading tsdoc.json
## 0.15.0
Fri, 16 Apr 2021 23:22:26 GMT
### Minor changes
- Add a new API TSDocConfigFile.loadFromObject()
## 0.14.0
Fri, 22 Jan 2021 18:07:19 GMT
### Minor changes
- Update tsdoc.json schema to add a new field "noStandardTags"
- TSDocConfigFile.configureParser() now clears any previous state, and it only defines standard tags if "noStandardTags" is not true.
- Added new API TSDocConfigFile.updateParser() which preserves the previous configuration state
- Add new "supportForTags" field to tsdoc.json schema
- Add new APIs: TSDocConfigFile.supportForTags, .clearTagDefinitions(), .addTagDefinition(), .clearSupportForTags(), .setSupportForTag(), .loadFromParser(), .saveFile(), .saveToObject()
## 0.13.9
Thu, 03 Dec 2020 08:07:55 GMT
_Version update only_
## 0.13.8
Thu, 03 Dec 2020 04:31:52 GMT
_Version update only_
## 0.13.7
Mon, 30 Nov 2020 06:16:21 GMT
### Patches
- Update documentation to reference the new website URL
- Upgrade build tools and configuration
## 0.13.6
Fri, 04 Sep 2020 15:53:27 GMT
### Patches
- Update build system
## 0.13.5
Sun, 19 Jul 2020 01:22:35 GMT
### Patches
- Bump ajv dependency to ~6.12.3
## 0.13.4
Wed, 20 May 2020 22:33:27 GMT
### Patches
- Fix typo
## 0.13.3
Fri, 27 Mar 2020 23:14:53 GMT
_Version update only_
## 0.13.2
Sat, 22 Feb 2020 20:44:16 GMT
_Version update only_
## 0.13.1
Sat, 22 Feb 2020 02:55:07 GMT
_Version update only_
## 0.13.0
Tue, 21 Jan 2020 21:26:36 GMT
### Minor changes
- Improve tsdoc.json parser to allow JSON comments
- Add a new API TSDocConfigFile.checkForModifiedFiles() to facilitate caching
## 0.12.16
Tue, 19 Nov 2019 22:01:56 GMT
### Patches
- Initial release

22
node_modules/@microsoft/tsdoc-config/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
Copyright (c) Microsoft Corporation. All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

85
node_modules/@microsoft/tsdoc-config/README.md generated vendored Normal file
View File

@@ -0,0 +1,85 @@
# @microsoft/tsdoc-config
**TSDoc** is a proposal to standardize the doc comments used in [TypeScript](http://www.typescriptlang.org/)
source files. The main package [`@microsoft/tsdoc`](https://www.npmjs.com/package/@microsoft/tsdoc) implements
the TSDoc parser. The `@microsoft/tsdoc-config` package is an optional add-on for loading the **tsdoc.json**
file format that enables users to define custom TSDoc tags. (This functionality was moved to its own package
because it requires external dependencies such as NodeJS and `ajv`, whereas the main package is fully self-contained.)
For more information about TSDoc, please visit the project website:
https://tsdoc.org
## Creating config files
The **tsdoc.json** file is optional. When used, it is expected to be found in the same folder as
the **tsconfig.json** file for a project. The loader looks for it by walking upwards in the directory tree
until it finds a folder containing **tsconfig.json** or **package.json**, and then it attempts to load
**tsdoc.json** from that location.
The **tsdoc.json** file conforms to the [tsdoc.schema.json](
https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json) JSON schema. It defines tags using
similar fields as the
[TSDocTagDefinition](https://github.com/microsoft/tsdoc/blob/main/tsdoc/src/configuration/TSDocTagDefinition.ts)
API used by `TSDocParser` from `@microsoft/tsdoc`.
Here's a simple example:
**tsdoc.json**
```js
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"tagDefinitions": [
{
"tagName": "@myTag",
"syntaxKind": "modifier"
}
]
}
```
If you want to define custom tags in one place and share them across multiple projects, the `extends` field specifies
a list of paths that will be mixed in with the current file:
**tsdoc.json**
```js
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"extends": [
"my-package/dist/tsdoc-base.json",
"./path/to/local/file/tsdoc-local.json"
]
}
```
> NOTE: The `extends` paths are resolved using NodeJS module resolution, so local paths must begin with `./` to avoid
> being interpreted as an NPM package name.
## API Usage
The code sample below illustrates how to invoke the `@microsoft/tsdoc-config` API to load a
**tsdoc.json** file:
```ts
import * as path from 'path';
import { TSDocParser, TSDocConfiguration } from '@microsoft/tsdoc';
import { TSDocConfigFile } from '@microsoft/tsdoc-config';
// Sample source file to be parsed
const mySourceFile: string = 'my-project/src/example.ts';
// Load the nearest config file, for example `my-project/tsdoc.json`
const tsdocConfigFile: TSDocConfigFile = TSDocConfigFile.loadForFolder(path.dirname(mySourceFile));
if (tsdocConfigFile.hasErrors) {
// Report any errors
console.log(tsdocConfigFile.getErrorSummary());
}
// Use the TSDocConfigFile to configure the parser
const tsdocConfiguration: TSDocConfiguration = new TSDocConfiguration();
tsdocConfigFile.configureParser(tsdocConfiguration);
const tsdocParser: TSDocParser = new TSDocParser(tsdocConfiguration);
```

View File

@@ -0,0 +1,216 @@
import { TSDocTagDefinition, type TSDocConfiguration, ParserMessageLog, type ITSDocTagDefinitionParameters } from '@microsoft/tsdoc';
/**
* Represents an individual `tsdoc.json` file.
*
* @public
*/
export declare class TSDocConfigFile {
static readonly FILENAME: string;
static readonly CURRENT_SCHEMA_URL: string;
/**
* A queryable log that reports warnings and error messages that occurred during parsing.
*/
readonly log: ParserMessageLog;
private readonly _extendsFiles;
private _filePath;
private _fileNotFound;
private _fileMTime;
private _hasErrors;
private _tsdocSchema;
private readonly _extendsPaths;
private _noStandardTags;
private readonly _tagDefinitions;
private readonly _tagDefinitionNames;
private readonly _supportForTags;
private _supportedHtmlElements;
private _reportUnsupportedHtmlElements;
private constructor();
/**
* Other config files that this file extends from.
*/
get extendsFiles(): ReadonlyArray<TSDocConfigFile>;
/**
* The full path of the file that was attempted to load, or an empty string if the configuration was
* loaded from a source that is not a file.
*/
get filePath(): string;
/**
* If true, then the TSDocConfigFile object contains an empty state, because the `tsdoc.json` file
* was not found by the loader.
*
* @remarks
* A missing "tsdoc.json" file is not considered an error. It simply means that the defaults will be used.
*/
get fileNotFound(): boolean;
/**
* If true, then at least one error was encountered while loading this file or one of its "extends" files.
*
* @remarks
* You can use {@link TSDocConfigFile.getErrorSummary} to report these errors.
*
* The individual messages can be retrieved from the {@link TSDocConfigFile.log} property of each `TSDocConfigFile`
* object (including the {@link TSDocConfigFile.extendsFiles} tree).
*/
get hasErrors(): boolean;
/**
* The `$schema` field from the `tsdoc.json` file.
*/
get tsdocSchema(): string;
/**
* The `extends` field from the `tsdoc.json` file. For the parsed file contents,
* use the `extendsFiles` property instead.
*/
get extendsPaths(): ReadonlyArray<string>;
/**
* By default, the config file loader will predefine all of the standardized TSDoc tags. To disable this and
* start with a completely empty configuration, set `noStandardTags` to true.
*
* @remarks
* If a config file uses `"extends"` to include settings from base config files, then its setting will
* override any settings from the base config files. If `"noStandardTags"` is not specified, then this
* property will be `undefined`. The config files are applied in the order they are processed (a depth-first
* traversal of the `"extends"` references), and files processed later can override earlier files.
* If no config file specifies `noStandardTags` then the default value is `false`.
*/
get noStandardTags(): boolean | undefined;
set noStandardTags(value: boolean | undefined);
get tagDefinitions(): ReadonlyArray<TSDocTagDefinition>;
get supportForTags(): ReadonlyMap<string, boolean>;
get supportedHtmlElements(): ReadonlyArray<string> | undefined;
get reportUnsupportedHtmlElements(): boolean | undefined;
set reportUnsupportedHtmlElements(value: boolean | undefined);
/**
* Removes all items from the `tagDefinitions` array.
*/
clearTagDefinitions(): void;
/**
* Adds a new item to the `tagDefinitions` array.
*/
addTagDefinition(parameters: ITSDocTagDefinitionParameters): void;
private _addTagDefinitionForLoad;
/**
* Adds a new item to the `supportedHtmlElements` array.
*/
addSupportedHtmlElement(htmlElement: string): void;
/**
* Removes the explicit list of allowed html elements.
*/
clearSupportedHtmlElements(): void;
/**
* Removes all entries from the "supportForTags" map.
*/
clearSupportForTags(): void;
/**
* Sets an entry in the "supportForTags" map.
*/
setSupportForTag(tagName: string, supported: boolean): void;
/**
* This can be used for cache eviction. It returns true if the modification timestamp has changed for
* any of the files that were read when loading this `TSDocConfigFile`, which indicates that the file should be
* reloaded. It does not consider cases where `TSDocConfigFile.fileNotFound` was `true`.
*
* @remarks
* This can be used for cache eviction. An example eviction strategy might be like this:
*
* - call `checkForModifiedFiles()` once per second, and reload the configuration if it returns true
*
* - otherwise, reload the configuration when it is more than 10 seconds old (to handle less common cases such
* as creation of a missing file, or creation of a file at an earlier location in the search path).
*/
checkForModifiedFiles(): boolean;
/**
* Checks the last modification time for `TSDocConfigFile.filePath` and returns `true` if it has changed
* since the file was loaded. If the file is missing, this returns `false`. If the timestamp cannot be read,
* then this returns `true`.
*/
private _checkForModifiedFile;
private _reportError;
private _loadJsonObject;
private _loadWithExtends;
/**
* For the given folder, look for the relevant tsdoc.json file (if any), and return its path.
*
* @param folderPath - the path to a folder where the search should start
* @returns the (possibly relative) path to tsdoc.json, or an empty string if not found
*/
static findConfigPathForFolder(folderPath: string): string;
/**
* Calls `TSDocConfigFile.findConfigPathForFolder()` to find the relevant tsdoc.json config file, if one exists.
* Then calls `TSDocConfigFile.findConfigPathForFolder()` to return the loaded result.
*
* @remarks
* This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
* for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
* or {@link TSDocConfigFile.getErrorSummary}.
*
* @param folderPath - the path to a folder where the search should start
*/
static loadForFolder(folderPath: string): TSDocConfigFile;
/**
* Loads the specified tsdoc.json and any base files that it refers to using the "extends" option.
*
* @remarks
* This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
* for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
* or {@link TSDocConfigFile.getErrorSummary}.
*
* @param tsdocJsonFilePath - the path to the tsdoc.json config file
*/
static loadFile(tsdocJsonFilePath: string): TSDocConfigFile;
/**
* Loads the object state from a JSON-serializable object as produced by {@link TSDocConfigFile.saveToObject}.
*
* @remarks
* The serialized object has the same structure as `tsdoc.json`; however the `"extends"` field is not allowed.
*
* This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
* for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
* or {@link TSDocConfigFile.getErrorSummary}.
*/
static loadFromObject(jsonObject: unknown): TSDocConfigFile;
/**
* Initializes a TSDocConfigFile object using the state from the provided `TSDocConfiguration` object.
*
* @remarks
* This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
* for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
* or {@link TSDocConfigFile.getErrorSummary}.
*/
static loadFromParser(configuration: TSDocConfiguration): TSDocConfigFile;
/**
* Writes the config file content to a JSON file with the specified file path.
*/
saveFile(jsonFilePath: string): void;
/**
* Writes the object state into a JSON-serializable object.
*/
saveToObject(): unknown;
private static _serializeTagDefinition;
/**
* Returns a report of any errors that occurred while attempting to load this file or any files
* referenced via the "extends" field.
*
* @remarks
* Use {@link TSDocConfigFile.hasErrors} to determine whether any errors occurred.
*/
getErrorSummary(): string;
/**
* Applies the settings from this config file to a TSDoc parser configuration.
* Any `extendsFile` settings will also applied.
*
* @remarks
* Additional validation is performed during this operation. The caller is expected to check for errors
* using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log}, or {@link TSDocConfigFile.getErrorSummary}.
*/
configureParser(configuration: TSDocConfiguration): void;
/**
* This is the same as {@link configureParser}, but it preserves any previous state.
*
* @remarks
* Additional validation is performed during this operation. The caller is expected to check for errors
* using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log}, or {@link TSDocConfigFile.getErrorSummary}.
*/
updateParser(configuration: TSDocConfiguration): void;
private _getNoStandardTagsWithExtends;
}
//# sourceMappingURL=TSDocConfigFile.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TSDocConfigFile.d.ts","sourceRoot":"","sources":["../src/TSDocConfigFile.ts"],"names":[],"mappings":"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"}

View File

@@ -0,0 +1,701 @@
"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;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TSDocConfigFile = void 0;
const fs = __importStar(require("node:fs"));
const path = __importStar(require("node:path"));
const resolve = __importStar(require("resolve"));
const ajv_1 = __importDefault(require("ajv"));
const jju = __importStar(require("jju"));
const tsdoc_1 = require("@microsoft/tsdoc");
const ajv = new ajv_1.default({ verbose: true });
function initializeSchemaValidator() {
const jsonSchemaPath = resolve.sync('@microsoft/tsdoc/schemas/tsdoc.schema.json', {
basedir: __dirname
});
const jsonSchemaContent = fs.readFileSync(jsonSchemaPath).toString();
const jsonSchema = jju.parse(jsonSchemaContent, { mode: 'cjson' });
return ajv.compile(jsonSchema);
}
// Warning: AJV has a fairly strange API. Each time this function is called, the function object's
// properties get overwritten with the results of the latest validation. Thus we need to be careful
// to read the properties before a subsequent call may occur.
const tsdocSchemaValidator = initializeSchemaValidator();
/**
* Represents an individual `tsdoc.json` file.
*
* @public
*/
class TSDocConfigFile {
constructor() {
this.log = new tsdoc_1.ParserMessageLog();
this._extendsFiles = [];
this._filePath = '';
this._fileNotFound = false;
this._hasErrors = false;
this._fileMTime = 0;
this._tsdocSchema = '';
this._extendsPaths = [];
this._noStandardTags = undefined;
this._tagDefinitions = [];
this._tagDefinitionNames = new Set();
this._supportForTags = new Map();
}
/**
* Other config files that this file extends from.
*/
get extendsFiles() {
return this._extendsFiles;
}
/**
* The full path of the file that was attempted to load, or an empty string if the configuration was
* loaded from a source that is not a file.
*/
get filePath() {
return this._filePath;
}
/**
* If true, then the TSDocConfigFile object contains an empty state, because the `tsdoc.json` file
* was not found by the loader.
*
* @remarks
* A missing "tsdoc.json" file is not considered an error. It simply means that the defaults will be used.
*/
get fileNotFound() {
return this._fileNotFound;
}
/**
* If true, then at least one error was encountered while loading this file or one of its "extends" files.
*
* @remarks
* You can use {@link TSDocConfigFile.getErrorSummary} to report these errors.
*
* The individual messages can be retrieved from the {@link TSDocConfigFile.log} property of each `TSDocConfigFile`
* object (including the {@link TSDocConfigFile.extendsFiles} tree).
*/
get hasErrors() {
return this._hasErrors;
}
/**
* The `$schema` field from the `tsdoc.json` file.
*/
get tsdocSchema() {
return this._tsdocSchema;
}
/**
* The `extends` field from the `tsdoc.json` file. For the parsed file contents,
* use the `extendsFiles` property instead.
*/
get extendsPaths() {
return this._extendsPaths;
}
/**
* By default, the config file loader will predefine all of the standardized TSDoc tags. To disable this and
* start with a completely empty configuration, set `noStandardTags` to true.
*
* @remarks
* If a config file uses `"extends"` to include settings from base config files, then its setting will
* override any settings from the base config files. If `"noStandardTags"` is not specified, then this
* property will be `undefined`. The config files are applied in the order they are processed (a depth-first
* traversal of the `"extends"` references), and files processed later can override earlier files.
* If no config file specifies `noStandardTags` then the default value is `false`.
*/
get noStandardTags() {
return this._noStandardTags;
}
set noStandardTags(value) {
this._noStandardTags = value;
}
get tagDefinitions() {
return this._tagDefinitions;
}
get supportForTags() {
return this._supportForTags;
}
get supportedHtmlElements() {
return this._supportedHtmlElements && Array.from(this._supportedHtmlElements);
}
get reportUnsupportedHtmlElements() {
return this._reportUnsupportedHtmlElements;
}
set reportUnsupportedHtmlElements(value) {
this._reportUnsupportedHtmlElements = value;
}
/**
* Removes all items from the `tagDefinitions` array.
*/
clearTagDefinitions() {
this._tagDefinitions.length = 0;
this._tagDefinitionNames.clear();
}
/**
* Adds a new item to the `tagDefinitions` array.
*/
addTagDefinition(parameters) {
// This validates the tag name
const tagDefinition = new tsdoc_1.TSDocTagDefinition(parameters);
if (this._tagDefinitionNames.has(tagDefinition.tagNameWithUpperCase)) {
throw new Error(`A tag definition was already added with the tag name "${parameters.tagName}"`);
}
this._tagDefinitionNames.add(tagDefinition.tagName);
this._tagDefinitions.push(tagDefinition);
}
// Similar to addTagDefinition() but reports errors using _reportError()
_addTagDefinitionForLoad(parameters) {
let tagDefinition;
try {
// This validates the tag name
tagDefinition = new tsdoc_1.TSDocTagDefinition(parameters);
}
catch (error) {
this._reportError({
messageId: tsdoc_1.TSDocMessageId.ConfigFileInvalidTagName,
messageText: error.message,
textRange: tsdoc_1.TextRange.empty
});
return;
}
if (this._tagDefinitionNames.has(tagDefinition.tagNameWithUpperCase)) {
this._reportError({
messageId: tsdoc_1.TSDocMessageId.ConfigFileDuplicateTagName,
messageText: `The "tagDefinitions" field specifies more than one tag with the name "${parameters.tagName}"`,
textRange: tsdoc_1.TextRange.empty
});
}
this._tagDefinitionNames.add(tagDefinition.tagNameWithUpperCase);
this._tagDefinitions.push(tagDefinition);
}
/**
* Adds a new item to the `supportedHtmlElements` array.
*/
addSupportedHtmlElement(htmlElement) {
if (!this._supportedHtmlElements) {
this._supportedHtmlElements = new Set();
}
this._supportedHtmlElements.add(htmlElement);
}
/**
* Removes the explicit list of allowed html elements.
*/
clearSupportedHtmlElements() {
this._supportedHtmlElements = undefined;
}
/**
* Removes all entries from the "supportForTags" map.
*/
clearSupportForTags() {
this._supportForTags.clear();
}
/**
* Sets an entry in the "supportForTags" map.
*/
setSupportForTag(tagName, supported) {
tsdoc_1.TSDocTagDefinition.validateTSDocTagName(tagName);
this._supportForTags.set(tagName, supported);
}
/**
* This can be used for cache eviction. It returns true if the modification timestamp has changed for
* any of the files that were read when loading this `TSDocConfigFile`, which indicates that the file should be
* reloaded. It does not consider cases where `TSDocConfigFile.fileNotFound` was `true`.
*
* @remarks
* This can be used for cache eviction. An example eviction strategy might be like this:
*
* - call `checkForModifiedFiles()` once per second, and reload the configuration if it returns true
*
* - otherwise, reload the configuration when it is more than 10 seconds old (to handle less common cases such
* as creation of a missing file, or creation of a file at an earlier location in the search path).
*/
checkForModifiedFiles() {
if (this._checkForModifiedFile()) {
return true;
}
for (const extendsFile of this.extendsFiles) {
if (extendsFile.checkForModifiedFiles()) {
return true;
}
}
return false;
}
/**
* Checks the last modification time for `TSDocConfigFile.filePath` and returns `true` if it has changed
* since the file was loaded. If the file is missing, this returns `false`. If the timestamp cannot be read,
* then this returns `true`.
*/
_checkForModifiedFile() {
if (this._fileNotFound || !this._filePath) {
return false;
}
try {
const mtimeMs = fs.statSync(this._filePath).mtimeMs;
return mtimeMs !== this._fileMTime;
}
catch (error) {
return true;
}
}
_reportError(parserMessageParameters) {
this.log.addMessage(new tsdoc_1.ParserMessage(parserMessageParameters));
this._hasErrors = true;
}
_loadJsonObject(configJson) {
if (configJson.$schema !== TSDocConfigFile.CURRENT_SCHEMA_URL) {
this._reportError({
messageId: tsdoc_1.TSDocMessageId.ConfigFileUnsupportedSchema,
messageText: `Unsupported JSON "$schema" value; expecting "${TSDocConfigFile.CURRENT_SCHEMA_URL}"`,
textRange: tsdoc_1.TextRange.empty
});
return;
}
const success = tsdocSchemaValidator(configJson);
if (!success) {
const description = ajv.errorsText(tsdocSchemaValidator.errors);
this._reportError({
messageId: tsdoc_1.TSDocMessageId.ConfigFileSchemaError,
messageText: 'Error loading config file: ' + description,
textRange: tsdoc_1.TextRange.empty
});
return;
}
this._tsdocSchema = configJson.$schema;
if (configJson.extends) {
this._extendsPaths.push(...configJson.extends);
}
this.noStandardTags = configJson.noStandardTags;
for (const jsonTagDefinition of configJson.tagDefinitions || []) {
let syntaxKind;
switch (jsonTagDefinition.syntaxKind) {
case 'inline':
syntaxKind = tsdoc_1.TSDocTagSyntaxKind.InlineTag;
break;
case 'block':
syntaxKind = tsdoc_1.TSDocTagSyntaxKind.BlockTag;
break;
case 'modifier':
syntaxKind = tsdoc_1.TSDocTagSyntaxKind.ModifierTag;
break;
default:
// The JSON schema should have caught this error
throw new Error('Unexpected tag kind');
}
this._addTagDefinitionForLoad({
tagName: jsonTagDefinition.tagName,
syntaxKind: syntaxKind,
allowMultiple: jsonTagDefinition.allowMultiple
});
}
if (configJson.supportedHtmlElements) {
this._supportedHtmlElements = new Set();
for (const htmlElement of configJson.supportedHtmlElements) {
this.addSupportedHtmlElement(htmlElement);
}
}
this._reportUnsupportedHtmlElements = configJson.reportUnsupportedHtmlElements;
if (configJson.supportForTags) {
for (const tagName of Object.keys(configJson.supportForTags)) {
const supported = configJson.supportForTags[tagName];
this._supportForTags.set(tagName, supported);
}
}
}
_loadWithExtends(configFilePath, referencingConfigFile, alreadyVisitedPaths) {
// In case an exception is thrown, start by assuming that the file was not found; we'll revise
// this later upon success
this._fileNotFound = true;
if (!configFilePath) {
this._reportError({
messageId: tsdoc_1.TSDocMessageId.ConfigFileNotFound,
messageText: 'File not found',
textRange: tsdoc_1.TextRange.empty
});
return;
}
this._filePath = path.resolve(configFilePath);
if (!fs.existsSync(this._filePath)) {
this._reportError({
messageId: tsdoc_1.TSDocMessageId.ConfigFileNotFound,
messageText: 'File not found',
textRange: tsdoc_1.TextRange.empty
});
return;
}
const configJsonContent = fs.readFileSync(this._filePath).toString();
this._fileMTime = fs.statSync(this._filePath).mtimeMs;
this._fileNotFound = false;
const hashKey = fs.realpathSync(this._filePath);
if (referencingConfigFile && alreadyVisitedPaths.has(hashKey)) {
this._reportError({
messageId: tsdoc_1.TSDocMessageId.ConfigFileCyclicExtends,
messageText: `Circular reference encountered for "extends" field of "${referencingConfigFile.filePath}"`,
textRange: tsdoc_1.TextRange.empty
});
return;
}
alreadyVisitedPaths.add(hashKey);
let configJson;
try {
configJson = jju.parse(configJsonContent, { mode: 'cjson' });
}
catch (e) {
this._reportError({
messageId: tsdoc_1.TSDocMessageId.ConfigInvalidJson,
messageText: 'Error parsing JSON input: ' + e.message,
textRange: tsdoc_1.TextRange.empty
});
return;
}
this._loadJsonObject(configJson);
const configFileFolder = path.dirname(this.filePath);
for (const extendsField of this.extendsPaths) {
let resolvedExtendsPath;
try {
resolvedExtendsPath = resolve.sync(extendsField, { basedir: configFileFolder });
}
catch (e) {
this._reportError({
messageId: tsdoc_1.TSDocMessageId.ConfigFileUnresolvedExtends,
messageText: `Unable to resolve "extends" reference to "${extendsField}": ` + e.message,
textRange: tsdoc_1.TextRange.empty
});
return;
}
const baseConfigFile = new TSDocConfigFile();
baseConfigFile._loadWithExtends(resolvedExtendsPath, this, alreadyVisitedPaths);
if (baseConfigFile.fileNotFound) {
this._reportError({
messageId: tsdoc_1.TSDocMessageId.ConfigFileUnresolvedExtends,
messageText: `Unable to resolve "extends" reference to "${extendsField}"`,
textRange: tsdoc_1.TextRange.empty
});
}
this._extendsFiles.push(baseConfigFile);
if (baseConfigFile.hasErrors) {
this._hasErrors = true;
}
}
}
/**
* For the given folder, look for the relevant tsdoc.json file (if any), and return its path.
*
* @param folderPath - the path to a folder where the search should start
* @returns the (possibly relative) path to tsdoc.json, or an empty string if not found
*/
static findConfigPathForFolder(folderPath) {
if (folderPath) {
let foundFolder = folderPath;
for (;;) {
const tsconfigJsonPath = path.join(foundFolder, 'tsconfig.json');
if (fs.existsSync(tsconfigJsonPath)) {
// Stop when we reach a folder containing tsconfig.json
return path.join(foundFolder, TSDocConfigFile.FILENAME);
}
const packageJsonPath = path.join(foundFolder, 'package.json');
if (fs.existsSync(packageJsonPath)) {
// Stop when we reach a folder containing package.json; this avoids crawling out of the current package
return path.join(foundFolder, TSDocConfigFile.FILENAME);
}
const previousFolder = foundFolder;
foundFolder = path.dirname(foundFolder);
if (!foundFolder || foundFolder === previousFolder) {
// Give up if we reach the filesystem root directory
break;
}
}
}
return '';
}
/**
* Calls `TSDocConfigFile.findConfigPathForFolder()` to find the relevant tsdoc.json config file, if one exists.
* Then calls `TSDocConfigFile.findConfigPathForFolder()` to return the loaded result.
*
* @remarks
* This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
* for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
* or {@link TSDocConfigFile.getErrorSummary}.
*
* @param folderPath - the path to a folder where the search should start
*/
static loadForFolder(folderPath) {
const rootConfigPath = TSDocConfigFile.findConfigPathForFolder(folderPath);
return TSDocConfigFile.loadFile(rootConfigPath);
}
/**
* Loads the specified tsdoc.json and any base files that it refers to using the "extends" option.
*
* @remarks
* This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
* for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
* or {@link TSDocConfigFile.getErrorSummary}.
*
* @param tsdocJsonFilePath - the path to the tsdoc.json config file
*/
static loadFile(tsdocJsonFilePath) {
const configFile = new TSDocConfigFile();
const alreadyVisitedPaths = new Set();
configFile._loadWithExtends(tsdocJsonFilePath, undefined, alreadyVisitedPaths);
return configFile;
}
/**
* Loads the object state from a JSON-serializable object as produced by {@link TSDocConfigFile.saveToObject}.
*
* @remarks
* The serialized object has the same structure as `tsdoc.json`; however the `"extends"` field is not allowed.
*
* This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
* for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
* or {@link TSDocConfigFile.getErrorSummary}.
*/
static loadFromObject(jsonObject) {
const configFile = new TSDocConfigFile();
configFile._loadJsonObject(jsonObject);
if (configFile.extendsPaths.length > 0) {
throw new Error('The "extends" field cannot be used with TSDocConfigFile.loadFromObject()');
}
return configFile;
}
/**
* Initializes a TSDocConfigFile object using the state from the provided `TSDocConfiguration` object.
*
* @remarks
* This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
* for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
* or {@link TSDocConfigFile.getErrorSummary}.
*/
static loadFromParser(configuration) {
const configFile = new TSDocConfigFile();
// The standard tags will be mixed together with custom definitions,
// so set noStandardTags=true to avoid defining them twice.
configFile.noStandardTags = true;
for (const tagDefinition of configuration.tagDefinitions) {
configFile.addTagDefinition({
syntaxKind: tagDefinition.syntaxKind,
tagName: tagDefinition.tagName,
allowMultiple: tagDefinition.allowMultiple
});
}
for (const tagDefinition of configuration.supportedTagDefinitions) {
configFile.setSupportForTag(tagDefinition.tagName, true);
}
for (const htmlElement of configuration.supportedHtmlElements) {
configFile.addSupportedHtmlElement(htmlElement);
}
configFile.reportUnsupportedHtmlElements = configuration.validation.reportUnsupportedHtmlElements;
return configFile;
}
/**
* Writes the config file content to a JSON file with the specified file path.
*/
saveFile(jsonFilePath) {
const jsonObject = this.saveToObject();
const jsonContent = JSON.stringify(jsonObject, undefined, 2);
fs.writeFileSync(jsonFilePath, jsonContent);
}
/**
* Writes the object state into a JSON-serializable object.
*/
saveToObject() {
const configJson = {
$schema: TSDocConfigFile.CURRENT_SCHEMA_URL
};
if (this.noStandardTags !== undefined) {
configJson.noStandardTags = this.noStandardTags;
}
if (this.tagDefinitions.length > 0) {
configJson.tagDefinitions = [];
for (const tagDefinition of this.tagDefinitions) {
configJson.tagDefinitions.push(TSDocConfigFile._serializeTagDefinition(tagDefinition));
}
}
if (this.supportForTags.size > 0) {
configJson.supportForTags = {};
this.supportForTags.forEach((supported, tagName) => {
configJson.supportForTags[tagName] = supported;
});
}
if (this.supportedHtmlElements) {
configJson.supportedHtmlElements = [...this.supportedHtmlElements];
}
if (this._reportUnsupportedHtmlElements !== undefined) {
configJson.reportUnsupportedHtmlElements = this._reportUnsupportedHtmlElements;
}
return configJson;
}
static _serializeTagDefinition(tagDefinition) {
let syntaxKind;
switch (tagDefinition.syntaxKind) {
case tsdoc_1.TSDocTagSyntaxKind.InlineTag:
syntaxKind = 'inline';
break;
case tsdoc_1.TSDocTagSyntaxKind.BlockTag:
syntaxKind = 'block';
break;
case tsdoc_1.TSDocTagSyntaxKind.ModifierTag:
syntaxKind = 'modifier';
break;
default:
throw new Error('Unimplemented TSDocTagSyntaxKind');
}
const tagConfigJson = {
tagName: tagDefinition.tagName,
syntaxKind
};
if (tagDefinition.allowMultiple) {
tagConfigJson.allowMultiple = true;
}
return tagConfigJson;
}
/**
* Returns a report of any errors that occurred while attempting to load this file or any files
* referenced via the "extends" field.
*
* @remarks
* Use {@link TSDocConfigFile.hasErrors} to determine whether any errors occurred.
*/
getErrorSummary() {
if (!this._hasErrors) {
return 'No errors.';
}
let result = '';
if (this.log.messages.length > 0) {
const errorNoun = this.log.messages.length > 1 ? 'Errors' : 'Error';
if (this.filePath) {
result += `${errorNoun} encountered for ${this.filePath}:\n`;
}
else {
result += `${errorNoun} encountered when loading TSDoc configuration:\n`;
}
for (const message of this.log.messages) {
result += ` ${message.text}\n`;
}
}
for (const extendsFile of this.extendsFiles) {
if (extendsFile.hasErrors) {
if (result !== '') {
result += '\n';
}
result += extendsFile.getErrorSummary();
}
}
return result;
}
/**
* Applies the settings from this config file to a TSDoc parser configuration.
* Any `extendsFile` settings will also applied.
*
* @remarks
* Additional validation is performed during this operation. The caller is expected to check for errors
* using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log}, or {@link TSDocConfigFile.getErrorSummary}.
*/
configureParser(configuration) {
if (this._getNoStandardTagsWithExtends()) {
// Do not define standard tags
configuration.clear(true);
}
else {
// Define standard tags (the default behavior)
configuration.clear(false);
}
this.updateParser(configuration);
}
/**
* This is the same as {@link configureParser}, but it preserves any previous state.
*
* @remarks
* Additional validation is performed during this operation. The caller is expected to check for errors
* using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log}, or {@link TSDocConfigFile.getErrorSummary}.
*/
updateParser(configuration) {
// First apply the base config files
for (const extendsFile of this.extendsFiles) {
extendsFile.updateParser(configuration);
}
// Then apply this one
for (const tagDefinition of this.tagDefinitions) {
configuration.addTagDefinition(tagDefinition);
}
this.supportForTags.forEach((supported, tagName) => {
const tagDefinition = configuration.tryGetTagDefinition(tagName);
if (tagDefinition) {
// Note that setSupportForTag() automatically enables configuration.validation.reportUnsupportedTags
configuration.setSupportForTag(tagDefinition, supported);
}
else {
// Note that this validation may depend partially on the preexisting state of the TSDocConfiguration
// object, so it cannot be performed during the TSConfigFile.loadFile() stage.
this._reportError({
messageId: tsdoc_1.TSDocMessageId.ConfigFileUndefinedTag,
messageText: `The "supportForTags" field refers to an undefined tag ${JSON.stringify(tagName)}.`,
textRange: tsdoc_1.TextRange.empty
});
}
});
if (this.supportedHtmlElements) {
configuration.setSupportedHtmlElements([...this.supportedHtmlElements]);
}
if (this._reportUnsupportedHtmlElements === false) {
configuration.validation.reportUnsupportedHtmlElements = false;
}
else if (this._reportUnsupportedHtmlElements === true) {
configuration.validation.reportUnsupportedHtmlElements = true;
}
}
_getNoStandardTagsWithExtends() {
if (this.noStandardTags !== undefined) {
return this.noStandardTags;
}
// This config file does not specify "noStandardTags", so consider any base files referenced using "extends"
let result = undefined;
for (const extendsFile of this.extendsFiles) {
const extendedValue = extendsFile._getNoStandardTagsWithExtends();
if (extendedValue !== undefined) {
result = extendedValue;
}
}
if (result === undefined) {
// If no config file specifies noStandardTags, then it defaults to false
result = false;
}
return result;
}
}
exports.TSDocConfigFile = TSDocConfigFile;
TSDocConfigFile.FILENAME = 'tsdoc.json';
TSDocConfigFile.CURRENT_SCHEMA_URL = 'https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json';
//# sourceMappingURL=TSDocConfigFile.js.map

File diff suppressed because one or more lines are too long

2
node_modules/@microsoft/tsdoc-config/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { TSDocConfigFile } from './TSDocConfigFile';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}

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

@@ -0,0 +1,8 @@
"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.TSDocConfigFile = void 0;
var TSDocConfigFile_1 = require("./TSDocConfigFile");
Object.defineProperty(exports, "TSDocConfigFile", { enumerable: true, get: function () { return TSDocConfigFile_1.TSDocConfigFile; } });
//# 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,qDAAoD;AAA3C,kHAAA,eAAe,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 { TSDocConfigFile } from './TSDocConfigFile';\r\n"]}

42
node_modules/@microsoft/tsdoc-config/package.json generated vendored Normal file
View File

@@ -0,0 +1,42 @@
{
"name": "@microsoft/tsdoc-config",
"version": "0.18.0",
"description": "A loader for the tsdoc.json file",
"keywords": [
"TypeScript",
"documentation",
"doc",
"comments",
"JSDoc",
"parser",
"standard"
],
"repository": {
"type": "git",
"url": "https://github.com/microsoft/tsdoc",
"directory": "tsdoc-config"
},
"homepage": "https://tsdoc.org/",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"license": "MIT",
"dependencies": {
"ajv": "~8.12.0",
"jju": "~1.4.0",
"resolve": "~1.22.2",
"@microsoft/tsdoc": "0.16.0"
},
"devDependencies": {
"@rushstack/heft": "1.1.1",
"@types/jju": "1.4.2",
"@types/resolve": "1.20.2",
"eslint": "~9.25.1",
"tsdoc-build-rig": "1.0.0"
},
"scripts": {
"build": "heft test --clean",
"watch": "heft test --clean --watch",
"_phase:build": "heft run --only build -- --clean",
"_phase:test": "heft run --only test -- --clean"
}
}