How to use the @microsoft/tsdoc.TSDocTagDefinition 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
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
  const customModifierDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
    tagName: '@customModifier',
    syntaxKind: tsdoc.TSDocTagSyntaxKind.ModifierTag
  });

  customConfiguration.addTagDefinitions([
    customInlineDefinition,
    customBlockDefinition,
    customModifierDefinition
  ]);
github microsoft / tsdoc / tsdoc-config / src / TSDocConfigFile.ts View on Github external
this._tsdocSchema = configJson.$schema;
    if (configJson.extends) {
      this._extendsPaths.push(...configJson.extends);
    }

    for (const jsonTagDefinition of configJson.tagDefinitions || []) {
      let syntaxKind: TSDocTagSyntaxKind;
      switch (jsonTagDefinition.syntaxKind) {
        case 'inline': syntaxKind = TSDocTagSyntaxKind.InlineTag; break;
        case 'block': syntaxKind = TSDocTagSyntaxKind.BlockTag; break;
        case 'modifier': syntaxKind = TSDocTagSyntaxKind.ModifierTag; break;
        default:
          // The JSON schema should have caught this error
          throw new Error('Unexpected tag kind');
      }
      this._tagDefinitions.push(new TSDocTagDefinition({
        tagName: jsonTagDefinition.tagName,
        syntaxKind: syntaxKind,
        allowMultiple: jsonTagDefinition.allowMultiple
      }));
    }
  }
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 dotansimha / graphql-code-generator / packages / utils / config-md-generator / src / index.ts View on Github external
.join('\n');

  return output;
}

const nameDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@name',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const typeDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@type',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const descriptionDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@description',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const defaultDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@default',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const warningDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@warning',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});

function parseTSDoc(foundComment: IFoundComment): ConfigComment {
github dotansimha / graphql-code-generator / packages / utils / config-md-generator / src / index.ts View on Github external
${config.description ? config.description + '\n' : ''}
${config.warning ? '> ' + config.warning + '\n' : ''}
${config.examples
  .map(example => {
    return `#### ${example.title ? `Usage Example: ${example.title}` : 'Usage Example'}
${example.description ? `${example.description}\n` : ''}\n${example.code}`;
  })
  .join('\n')}`;
    })
    .join('\n');

  return output;
}

const nameDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@name',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const typeDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@type',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const descriptionDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@description',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const defaultDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@default',
github dotansimha / graphql-code-generator / packages / utils / config-md-generator / src / index.ts View on Github external
const nameDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@name',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const typeDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@type',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const descriptionDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@description',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const defaultDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@default',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const warningDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@warning',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});

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);
github dotansimha / graphql-code-generator / packages / utils / config-md-generator / src / index.ts View on Github external
const typeDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@type',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const descriptionDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@description',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const defaultDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@default',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const warningDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@warning',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});

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(),