How to use the @microsoft/tsdoc.TSDocConfiguration function in @microsoft/tsdoc

To help you get started, we’ve selected a few @microsoft/tsdoc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / tsdoc / api-demo / src / advancedDemo.ts View on Github external
function parseTSDoc(foundComment: IFoundComment): void {
  console.log(os.EOL + colors.green('Comment to be parsed:') + os.EOL);
  console.log(colors.gray('<<<<<<'));
  console.log(foundComment.textRange.toString());
  console.log(colors.gray('>>>>>>'));

  const customConfiguration: tsdoc.TSDocConfiguration = new tsdoc.TSDocConfiguration();

  const customInlineDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
    tagName: '@customInline',
    syntaxKind: tsdoc.TSDocTagSyntaxKind.InlineTag,
    allowMultiple: true
  });

  // NOTE: Defining this causes a new DocBlock to be created under docComment.customBlocks.
  // Otherwise, a simple DocBlockTag would appear inline in the @remarks section.
  const customBlockDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
    tagName: '@customBlock',
    syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag
  });

  // NOTE: Defining this causes @customModifier to be removed from its section,
  // and added to the docComment.modifierTagSet
github microsoft / tsdoc / eslint-plugin / src / index.ts View on Github external
create: (context: eslint.Rule.RuleContext) => {
        const tsdocConfiguration: TSDocConfiguration = new TSDocConfiguration();

        // Create a lax configuration that allows every standard tag regardless of standardization group
        tsdocConfiguration.setSupportForTags(StandardTags.allDefinitions, true);

        // Also add the three AEDoc tags
        tsdocConfiguration.addTagDefinitions([
          new TSDocTagDefinition({
            tagName: '@betaDocumentation',
            syntaxKind: TSDocTagSyntaxKind.ModifierTag
          }),
          new TSDocTagDefinition({
            tagName: '@internalRemarks',
            syntaxKind: TSDocTagSyntaxKind.BlockTag
          }),
          new TSDocTagDefinition({
            tagName: '@preapproved',
github microsoft / tsdoc / eslint-plugin / src / index.ts View on Github external
import {
  TSDocParser,
  TextRange,
  TSDocConfiguration,
  StandardTags,
  TSDocTagDefinition,
  TSDocTagSyntaxKind,
  ParserContext
} from "@microsoft/tsdoc";
import * as eslint from "eslint";
import * as ESTree from "estree";

const messageIds: {[x: string]: string} = {};

const defaultTSDocConfiguration: TSDocConfiguration = new TSDocConfiguration()
defaultTSDocConfiguration.allTsdocMessageIds.forEach((messageId: string) => {
  messageIds[messageId] = `${messageId}: {{ unformattedText }}`;
});

interface IPlugin {
  rules: {[x: string]: eslint.Rule.RuleModule};
}

const plugin: IPlugin = {
  rules: {
    // NOTE: The actual ESLint rule name will be "tsdoc/syntax".  It is calculated by deleting "eslint-plugin-"
    // from the NPM package name, and then appending this string.
    "syntax": {
      meta: {
        messages: messageIds,
        type: "problem",
github dotansimha / graphql-code-generator / packages / utils / config-md-generator / src / index.ts View on Github external
function parseTSDoc(foundComment: IFoundComment): ConfigComment {
  const customConfiguration: tsdoc.TSDocConfiguration = new tsdoc.TSDocConfiguration();

  customConfiguration.addTagDefinitions([nameDefinition, typeDefinition, descriptionDefinition, warningDefinition, defaultDefinition]);

  const tsdocParser: tsdoc.TSDocParser = new tsdoc.TSDocParser(customConfiguration);
  const parserContext: tsdoc.ParserContext = tsdocParser.parseRange(foundComment.textRange);
  const docComment: tsdoc.DocComment = parserContext.docComment;

  return {
    name: getTagValue(nameDefinition, docComment).trim(),
    type: (getTagValue(typeDefinition, docComment) || '').trim(),
    description: getTagValue(descriptionDefinition, docComment, false) || '',
    defaultValue: (getTagValue(defaultDefinition, docComment) || '').trim(),
    warning: getTagValue(warningDefinition, docComment, false) || '',
    examples: extractExamples(docComment),
  };
}
github microsoft / tsdoc / playground / src / PlaygroundView.tsx View on Github external
private _reparseTimer_onTick(): void {
    if (!this._reparseNeeded) {
      return;
    }
    this._reparseNeeded = false;
    try {
      const inputText: string = this.state.inputText;
      const configuration: tsdoc.TSDocConfiguration = new tsdoc.TSDocConfiguration();
      configuration.addTagDefinition(new tsdoc.TSDocTagDefinition({
        tagName: '@sampleCustomBlockTag',
        syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag
      }));
      const tsdocParser: tsdoc.TSDocParser = new tsdoc.TSDocParser(configuration);
      const parserContext: tsdoc.ParserContext = tsdocParser.parseString(inputText);

      this.setState({
        parserContext: parserContext,
        parserFailureText: undefined
      });
    } catch (error) {
      this.setState({
        parserContext: undefined,
        parserFailureText: 'Unhandled exception: ' + error.message
      });
github microsoft / rushstack / apps / api-extractor-model / src / aedoc / AedocDefinitions.ts View on Github external
public static get tsdocConfiguration(): TSDocConfiguration {
    if (!AedocDefinitions._tsdocConfiguration) {
      const configuration: TSDocConfiguration = new TSDocConfiguration();
      configuration.addTagDefinitions([
        AedocDefinitions.betaDocumentation,
        AedocDefinitions.internalRemarks,
        AedocDefinitions.preapprovedTag
      ], true);

      configuration.setSupportForTags(
        [
          StandardTags.alpha,
          StandardTags.beta,
          StandardTags.defaultValue,
          StandardTags.deprecated,
          StandardTags.eventProperty,
          StandardTags.example,
          StandardTags.inheritDoc,
          StandardTags.internal,
github microsoft / rushstack / apps / api-documenter / src / nodes / CustomDocNodeKind.ts View on Github external
public static get configuration(): TSDocConfiguration {
    if (CustomDocNodes._configuration === undefined) {
      const configuration: TSDocConfiguration = new TSDocConfiguration();

      configuration.docNodeManager.registerDocNodes('@micrososft/api-documenter', [
        { docNodeKind: CustomDocNodeKind.EmphasisSpan, constructor: DocEmphasisSpan },
        { docNodeKind: CustomDocNodeKind.Heading, constructor: DocHeading },
        { docNodeKind: CustomDocNodeKind.NoteBox, constructor: DocNoteBox },
        { docNodeKind: CustomDocNodeKind.Table, constructor: DocTable },
        { docNodeKind: CustomDocNodeKind.TableCell, constructor: DocTableCell },
        { docNodeKind: CustomDocNodeKind.TableRow, constructor: DocTableRow }
      ]);

      configuration.docNodeManager.registerAllowableChildren(CustomDocNodeKind.EmphasisSpan, [
        DocNodeKind.PlainText,
        DocNodeKind.SoftBreak
      ]);

      configuration.docNodeManager.registerAllowableChildren(DocNodeKind.Section, [