@tsdoc-test-reporter/core
TypeScript icon, indicating that this package has built-in type declarations

0.0.32 • Public • Published

@tsdoc-test-reporter/core

@tsdoc-test-reporter/core contains the main logic for parsing comment tags from a TypeScript file. It requires a TypeScript SourceFile and the TSDocParser from @microsoft/tsdoc.

Installing

npm install @tsdoc-test-reporter/core

Testing

pnpm nx test core

Minimal required setup

Below is a the minimal required setup to be able to parse a source file. You will need to load the source files yourself similar to the example.

import { TSDocParser } from '@microsoft/tsdoc';

import { CompilerOptions, createProgram, ScriptTarget, SourceFile } from 'typescript';

const program = createProgram(['myFileName.ts'], { target: ScriptTarget.Latest });

const sourceFile = program.getSourceFile('myFileName.ts');

const { testBlockDocComments } = new CommentTagParser({
	sourceFile,
	tsDocParser: new TSDocParser(),
});

Custom tags

Example for parsing test files where you have custom TSDoc tags.

import {
	TSDocConfiguration,
	TSDocParser,
	TSDocTagDefinition,
	TSDocTagSyntaxKind,
} from '@microsoft/tsdoc';

import { CompilerOptions, createProgram, ScriptTarget, SourceFile } from 'typescript';

const program = createProgram(['myFileName.ts'], { target: ScriptTarget.Latest });

const sourceFile = program.getSourceFile('myFileName.ts');

const config = new TSDocConfiguration();
const customBlockDefinition = new TSDocTagDefinition({
	tagName: '@custom',
	syntaxKind: TSDocTagSyntaxKind.BlockTag,
});
config.addTagDefinition(customBlockDefinition);

const { testBlockDocComments } = new CommentTagParser<'@custom'>({
	sourceFile,
	tsDocParser: new TSDocParser(config),
});

Readme

Keywords

none

Package Sidebar

Install

npm i @tsdoc-test-reporter/core

Weekly Downloads

7

Version

0.0.32

License

none

Unpacked Size

202 kB

Total Files

143

Last publish

Collaborators

  • jesperorb