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: