79553500

Date: 2025-04-03 16:28:36
Score: 1
Natty:
Report link

Combining the findings from Hacking TSDoc support into Storybook and How to filter JSDoc in Storybook Autodocs gives us a global solution within storybook's preview.js|jsx|ts|tsx:

// preview.ts
import {
  Component,
  extractComponentDescription as baseExtractComponentDescription,
} from 'storybook/internal/docs-tools';

const extractComponentDescription = (component: Component): string => {
  const description = baseExtractComponentDescription(component);
  const noParamsDescription = description.replace(/@param.+/gm, '');

  return noParamsDescription;
};

export const parameters = {
  docs: {
    extractComponentDescription,
  },
}

Note that we are overriding the extractComponentDescription function from the storybook shared utility docs-tools. Based on this note in the storybook addon docs (also mentioned in Hacking TSDoc support) providing a custom docs.extractComponentDescription parameter is supported.

The relevant docs-tools functions can be found here:

extractComponentDescription

getDocgenDescription

hasDocgen

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: kryp71c