A loader for the tsdoc.json file
npm install @microsoft/tsdoc-config@microsoft/tsdoc implements
@microsoft/tsdoc-config package is an optional add-on for loading the tsdoc.json
ajv, whereas the main package is fully self-contained.)
TSDocParser from @microsoft/tsdoc.
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);
``