Skip to content

docs(api/hooks): auto-generate docs for DOM-related hooks #13987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

MichaelDeBoey
Copy link
Member

Follow-up of #13963

I'm happy to revert 8301479 if you want it to be automatically done by the GitHub Workflow instead

Copy link

changeset-bot bot commented Jul 13, 2025

⚠️ No Changeset found

Latest commit: 8301479

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -295,7 +296,9 @@ function writeMarkdownFile(
}

// Create the filename (e.g., useHref.md)
const filename = `${comment.name}.md`;
const filename = `${
comment.unstable ? comment.name.replace("unstable_", "") : comment.name
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for usePrompt docs

@@ -313,7 +316,10 @@ function generateMarkdownForComment(comment: SimplifiedComment): string {

// Title with frontmatter
markdown += `---\n`;
markdown += `title: ${comment.name}\n`;
markdown += `title: ${
comment.unstable ? comment.name.replace("unstable_", "") : comment.name
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for usePrompt docs

Comment on lines +414 to +416
let name = unstable
? comment.tags.find((t) => t.type === "name")?.string
: comment.ctx.name;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for usePrompt docs

Comment on lines +454 to +457
let signature = getSignature(comment.code).replace(
unstable ? comment.ctx.name : "",
unstable ? name : ""
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for usePrompt docs

@@ -42,13 +53,12 @@ function SomeComponent() {
## Signature

```tsx
useFetcher(options): FetcherWithComponents
useFetcher<T = any>({ key, }: {})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something seems off in the getSignature code when there are comments in the types 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bummer - but we shouldn't need to inline document them anymore since we're now doing it at the @params tag

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make these updates too 👍

@@ -29,19 +40,16 @@ function SomeComponent() {
## Signature

```tsx
useFormAction(action, __namedParameters): string
useFormAction()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@@ -52,46 +64,3 @@ useSearchParams([["tab", "1"]]);
useSearchParams(new URLSearchParams("?tab=1"));
```

## SetSearchParams Function
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"SetSearchParams function" & "Notes" aren't really additional examples, so we probably need to think about a generic way to still include these parts?

CC/ @brookslybrand @brophdawg11

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In these cases, when we want to inject content below the Example we can just skip the @example tag and inline the example manually and any additional subheadings directly in the main Summary. That allows us to include an example and then more stuff below it:

/**
 * Returns a tuple of the current URL's [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
 * and a function to update them. Setting the search params causes a navigation.
 * 
 * ```tsx      👈  Manual inline example allowing us to put more long form content after
 * import { useSearchParams } from "react-router";
 *
 * export function SomeComponent() {
 *   const [searchParams, setSearchParams] = useSearchParams();
 *   // ...
 * }
 * ```
 *
 * ### SetSearchParams Function
 * ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change in my branch btw

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at my changes in #13985, I changed the logic to not put a code block around the example if @example already contained ```
This was needed to get the note out of useRevalidator's example code block (see #13985 (comment))

I could just put the rest of the text in the example as well and already include the code block

@brophdawg11
Copy link
Contributor

Thanks! I had started on parts of this file too and began working on handling unstable APIs in the script so I'll copy the new JSDocs from this PR into my branch and get that PR'd up. The components (notably those using forwardRef) are requiring some additional logic and JSDoc patterns that I'm working on ironing out.

@brophdawg11
Copy link
Contributor

Superseded by #14002

@MichaelDeBoey MichaelDeBoey deleted the auto-generate-docs-for-DOM-related-hooks branch July 16, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants