How to use the @microsoft/tsdoc.TSDocTagSyntaxKind 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
  const customModifierDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
    tagName: '@customModifier',
    syntaxKind: tsdoc.TSDocTagSyntaxKind.ModifierTag
  });
github microsoft / tsdoc / api-demo / src / advancedDemo.ts View on Github external
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
  ]);

  console.log(os.EOL + 'Invoking TSDocParser with custom configuration...' + os.EOL);
  const tsdocParser: tsdoc.TSDocParser = new tsdoc.TSDocParser(customConfiguration);
  const parserContext: tsdoc.ParserContext = tsdocParser.parseRange(foundComment.textRange);
  const docComment: tsdoc.DocComment = parserContext.docComment;

  console.log(os.EOL + colors.green('Parser Log Messages:') + os.EOL);

  if (parserContext.log.messages.length === 0) {
github dotansimha / graphql-code-generator / packages / utils / config-md-generator / src / index.ts View on Github external
})
  .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',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
});
const warningDefinition: tsdoc.TSDocTagDefinition = new tsdoc.TSDocTagDefinition({
  tagName: '@warning',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,
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 / tsdoc / playground / src / SyntaxStyler / DocNodeSyntaxStyler.ts View on Github external
private static _addStylesForTag(
    styles: IStyledRange[],
    excerpt: tsdoc.TokenSequence | undefined,
    tagDefinition: tsdoc.TSDocTagDefinition | undefined,
    options: IAddTokenStylesOptions
  ): void {
    const {
      theme,
      styleTokens
    }: IAddTokenStylesOptions = options;
    if (tagDefinition) {
      switch (tagDefinition.syntaxKind) {
        case tsdoc.TSDocTagSyntaxKind.BlockTag: {
          DocNodeSyntaxStyler._addTokenStyles(
            styles,
            excerpt,
            { theme, styleTokens: [...styleTokens, 'block'] }
          );
          break;
        }

        case tsdoc.TSDocTagSyntaxKind.InlineTag: {
          DocNodeSyntaxStyler._addTokenStyles(
            styles,
            excerpt,
            { theme, styleTokens: [...styleTokens, 'inline'] }
          );
          break;
        }
github dotansimha / graphql-code-generator / packages / utils / config-md-generator / src / index.ts View on Github external
${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',
  syntaxKind: tsdoc.TSDocTagSyntaxKind.BlockTag,
  allowMultiple: false,