Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,7 @@ jobs:
run: pnpm run docs:typedoc

- name: 📚 Generate Markdown Docs
run: |
pnpm run docs:jsdoc --path packages/react-router/lib/components.tsx --write
pnpm run docs:jsdoc --path packages/react-router/lib/hooks.tsx --write
pnpm run docs:jsdoc --path packages/react-router/lib/dom/lib.tsx --write
pnpm run docs:jsdoc --path packages/react-router/lib/dom/ssr/components.tsx --write
pnpm run docs:jsdoc --path packages/react-router/lib/dom/ssr/server.tsx --write
pnpm run docs:jsdoc --path packages/react-router/lib/dom-export/hydrated-router.tsx --write
pnpm run docs:jsdoc --path packages/react-router/lib/dom/server.tsx --write
pnpm run docs:jsdoc --path packages/react-router/lib/rsc/browser.tsx --write
pnpm run docs:jsdoc --path packages/react-router/lib/rsc/server.rsc.ts --write
pnpm run docs:jsdoc --path packages/react-router/lib/rsc/server.ssr.tsx --write
pnpm run docs:jsdoc --path packages/react-router/lib/rsc/html-stream/browser.ts --write
run: pnpm run docs:jsdoc --write
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can now just run this for all files - only the ones marked @public get written out


- name: 💪 Commit
run: |
Expand Down
8 changes: 4 additions & 4 deletions docs/api/components/PrefetchPageLinks.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { PrefetchPageLinks } from "react-router";
## Signature

```tsx
function PrefetchPageLinks({ page, ...dataLinkProps }: PageLinkDescriptor)
function PrefetchPageLinks({ page, ...linkProps }: PageLinkDescriptor)
```

## Props
Expand All @@ -48,8 +48,8 @@ function PrefetchPageLinks({ page, ...dataLinkProps }: PageLinkDescriptor)

The absolute path of the page to prefetch, e.g. `/absolute/path`.

### dataLinkProps
### linkProps

Additional props to pass to the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link)
tag, such as `crossOrigin`, `integrity`, `rel`, etc.
Additional props to spread onto the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link)
tags, such as `crossOrigin`, `integrity`, `rel`, etc.
Comment on lines +53 to +54
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hopefully his helps clarify that it's just a bag of props to spread onto link


6 changes: 3 additions & 3 deletions docs/api/components/Scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ export default function Root() {
## Signature

```tsx
function Scripts(props: ScriptsProps): React.JSX.Element | null
function Scripts(scriptProps: ScriptsProps): React.JSX.Element | null
```

## Props

### props
### scriptProps

Props for the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script)
Additional props to spread onto the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here for the <Script> props

tag, such as `crossOrigin`, `nonce`, etc.

27 changes: 11 additions & 16 deletions packages/react-router/lib/dom/ssr/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,12 @@ export function Links(): React.JSX.Element {
* @mode framework
* @param props Props
* @param props.page The absolute path of the page to prefetch, e.g. `/absolute/path`.
* @param props.dataLinkProps Additional props to pass to the
* @param props.linkProps Additional props to spread onto the
* [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link)
* tag, such as `crossOrigin`, `integrity`, `rel`, etc.
* tags, such as `crossOrigin`, `integrity`, `rel`, etc.
* @returns A collection of React elements for `<link>` tags
*/
export function PrefetchPageLinks({
page,
...dataLinkProps
}: PageLinkDescriptor) {
export function PrefetchPageLinks({ page, ...linkProps }: PageLinkDescriptor) {
let { router } = useDataRouterContext();
let matches = React.useMemo(
() => matchRoutes(router.routes, page, router.basename),
Expand All @@ -314,9 +311,7 @@ export function PrefetchPageLinks({
return null;
}

return (
<PrefetchPageLinksImpl page={page} matches={matches} {...dataLinkProps} />
);
return <PrefetchPageLinksImpl page={page} matches={matches} {...linkProps} />;
}

function useKeyedPrefetchLinks(matches: AgnosticDataRouteMatch[]) {
Expand Down Expand Up @@ -685,12 +680,12 @@ export type ScriptsProps = Omit<
* @public
* @category Components
* @mode framework
* @param props Props for the
* @param scriptProps Additional props to spread onto the
* [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script)
* tag, such as `crossOrigin`, `nonce`, etc.
* @returns A collection of React elements for `<script>` tags
*/
export function Scripts(props: ScriptsProps): React.JSX.Element | null {
export function Scripts(scriptProps: ScriptsProps): React.JSX.Element | null {
let {
manifest,
serverHandoffString,
Expand Down Expand Up @@ -822,13 +817,13 @@ import(${JSON.stringify(manifest.entry.module)});`;
return (
<>
<script
{...props}
{...scriptProps}
suppressHydrationWarning
dangerouslySetInnerHTML={createHtml(contextScript)}
type={undefined}
/>
<script
{...props}
{...scriptProps}
suppressHydrationWarning
dangerouslySetInnerHTML={createHtml(routeModulesScript)}
type="module"
Expand Down Expand Up @@ -878,15 +873,15 @@ import(${JSON.stringify(manifest.entry.module)});`;
<link
rel="modulepreload"
href={manifest.url}
crossOrigin={props.crossOrigin}
crossOrigin={scriptProps.crossOrigin}
integrity={sri[manifest.url]}
suppressHydrationWarning
/>
) : null}
<link
rel="modulepreload"
href={manifest.entry.module}
crossOrigin={props.crossOrigin}
crossOrigin={scriptProps.crossOrigin}
integrity={sri[manifest.entry.module]}
suppressHydrationWarning
/>
Expand All @@ -895,7 +890,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
key={path}
rel="modulepreload"
href={path}
crossOrigin={props.crossOrigin}
crossOrigin={scriptProps.crossOrigin}
integrity={sri[path]}
suppressHydrationWarning
/>
Expand Down
44 changes: 26 additions & 18 deletions scripts/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,39 @@ const { values: args } = util.parseArgs({
type: "string",
short: "o",
},
help: {
type: "boolean",
short: "h",
},
},
allowPositionals: true,
});

if (!args.path) {
console.error(
"Usage: docs.ts --path <filepath-or-glob> [--api <api1,api2,...>] [--write] [--output <output-dir>]",
if (args.help) {
console.log("\n");
console.log(
"Usage: docs.ts [--path <filepath-or-glob>] [--api <api1,api2,...>] [--write] [--output <output-dir>]",
);
console.log(
' --path, -p File path or glob pattern to parse (default "packages/**/*.{ts,tsx}")',
);
console.error(" --path, -p File path or glob pattern to parse");
console.error(
console.log(
" --api, -a Comma-separated list of specific APIs to generate",
);
console.error(" --write, -w Write markdown files to output directory");
console.error(" --output, -o Output directory (default: docs/api)");
console.log(" --write, -w Write markdown files to output directory");
console.log(" --output, -o Output directory (default: docs/api)");
process.exit(0);
}

// Resolve file paths using glob patterns
let pathGlob = args.path || "packages/**/*.{ts,tsx}";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer require --path now that we have critical mass - just default to everything

const filePaths = fg.sync(pathGlob, {
onlyFiles: true,
ignore: ["**/node_modules/**", "**/__tests__/**", "**/dist/**"],
});

if (filePaths.length === 0) {
console.error(`No files found matching pattern: ${pathGlob}`);
process.exit(1);
}

Expand All @@ -140,17 +159,6 @@ const outputDir = args.output || "docs/api";
const repoApiLookup = buildRepoDocsLinks(outputDir);
const typedocLookup = buildTypedocLinks(outputDir);

// Resolve file paths using glob patterns
const filePaths = fg.sync(args.path, {
onlyFiles: true,
ignore: ["**/node_modules/**", "**/__tests__/**", "**/dist/**"],
});

if (filePaths.length === 0) {
console.error(`No files found matching pattern: ${args.path}`);
process.exit(1);
}

run();

// Generate markdown documentation for all matching files
Expand Down