Repository: storybook
Issue: Accessing @decorator tags in component JSDoc comments
Labels: feature request,addon: docs

**Is your feature request related to a problem? Please describe**

tl;dr; I was using SB 6.0 and recently upgraded to SB 6.4. I used to have something working, and now __docgenInfo doesn't contain the data I need. Looking for a pointer to how to get it back!

---

I'm maintaining a design system. We're using Storybook for documentation reasons. One of the ideas we had was to extend the feature of addon docs that shows JSDoc comments on docs pages. If there is e.g. an `@status deprecated` tag on the component we'd show a red deprecated label on the component's doc page. There was also `@status stable`, `@status development`, `@status review`.

This feature was working in SB6.0 with the following decorator. Essentially, look at `__docgenInfo.description`, do a regex match, and set `__docgenInfo.status` if one is present.

```tsx
// statusDocsDecorator.tsx
import React from "react";
import { useContext } from "react";
import { addParameters } from '@storybook/react';
import { DocsContext, DocsPage } from '@storybook/addon-docs';
import { StatusBadge, ComponentStatus } from "../src/atoms/StatusBadge/StatusBadge";

/**
 * Decorator to display a component's status in its docspage.
 */
export default addParameters({
  docs: {
    page: () => {
      const context = useContext(DocsContext);

      // This is a bit hacky; ideally parsing the status could be done when the babel loader
      // initally generates __docgenInfo
      let status = context.parameters.component.__docgenInfo.status as ComponentStatus;
      if (!context.parameters.component.__docgenInfo.status) {
        const description: string = context.parameters.component.__docgenInfo.description ?? "";
        const statusMatch = description.match(/@status\s+(.*)/);

        status = statusMatch?.[1] as ComponentStatus;
        if (status) {
          context.parameters.component.__docgenInfo.description = description.replace(statusMatch?.[0]!, `\nComponent status: ${status}`)
          context.parameters.component.__docgenInfo.status = status;
        }
      }

      return (
        <>
          {status && <StatusBadge status={status} />}
          <DocsPage />
        </>
      );
    },
  },
});
```

An example of a story:

```tsx
/**
 * Component for [Bulma's Container](https://bulma.io/documentation/layout/container/).
 * @status deprecated
 */
export const Container: React.FC<Props> = ({ children, className, Element = "div" }) => {
  return (
    <Element className={classNames("container", "tl-container", className)}>
      {children}
    </Element>
  )
}
```

I upgraded to SB6.4 and now it appears that `__docgenInfo.description` now never contains any `@` JSDoc tags. 

I have looked through the sources of `addon-docs`, `react-docgen`, `babel-plugin-react-docgen` but I can't track down where the comment is actually parsed from the story source...

**Describe the solution you'd like**

A pointer to where/ when this was changed, or a way to access the raw JSDoc comment again.

**Describe alternatives you've considered**
To not do this ;)

**Are you able to assist to bring the feature to reality?**
Sure if I know where to look....

**Additional context**
Thanks!