Skip to content

Commit ea1cd40

Browse files
authored
docs: minor updates (#14038)
1 parent 433872f commit ea1cd40

File tree

6 files changed

+46
-53
lines changed

6 files changed

+46
-53
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,7 @@ jobs:
4747
run: pnpm run docs:typedoc
4848

4949
- name: 📚 Generate Markdown Docs
50-
run: |
51-
pnpm run docs:jsdoc --path packages/react-router/lib/components.tsx --write
52-
pnpm run docs:jsdoc --path packages/react-router/lib/hooks.tsx --write
53-
pnpm run docs:jsdoc --path packages/react-router/lib/dom/lib.tsx --write
54-
pnpm run docs:jsdoc --path packages/react-router/lib/dom/ssr/components.tsx --write
55-
pnpm run docs:jsdoc --path packages/react-router/lib/dom/ssr/server.tsx --write
56-
pnpm run docs:jsdoc --path packages/react-router/lib/dom-export/hydrated-router.tsx --write
57-
pnpm run docs:jsdoc --path packages/react-router/lib/dom/server.tsx --write
58-
pnpm run docs:jsdoc --path packages/react-router/lib/rsc/browser.tsx --write
59-
pnpm run docs:jsdoc --path packages/react-router/lib/rsc/server.rsc.ts --write
60-
pnpm run docs:jsdoc --path packages/react-router/lib/rsc/server.ssr.tsx --write
61-
pnpm run docs:jsdoc --path packages/react-router/lib/rsc/html-stream/browser.ts --write
50+
run: pnpm run docs:jsdoc --write
6251

6352
- name: 💪 Commit
6453
run: |

docs/api/components/PrefetchPageLinks.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { PrefetchPageLinks } from "react-router";
3939
## Signature
4040

4141
```tsx
42-
function PrefetchPageLinks({ page, ...dataLinkProps }: PageLinkDescriptor)
42+
function PrefetchPageLinks({ page, ...linkProps }: PageLinkDescriptor)
4343
```
4444

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

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

51-
### dataLinkProps
51+
### linkProps
5252

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

docs/api/components/Scripts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ export default function Root() {
4848
## Signature
4949

5050
```tsx
51-
function Scripts(props: ScriptsProps): React.JSX.Element | null
51+
function Scripts(scriptProps: ScriptsProps): React.JSX.Element | null
5252
```
5353

5454
## Props
5555

56-
### props
56+
### scriptProps
5757

58-
Props for the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script)
58+
Additional props to spread onto the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script)
5959
tag, such as `crossOrigin`, `nonce`, etc.
6060

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"clean": "git clean -fdX .",
88
"clean:build": "git clean -fdx -e node_modules .",
99
"clean:integration": "node ./integration/helpers/cleanup.mjs",
10+
"docs": "pnpm run docs:typedoc && pnpm run docs:jsdoc",
1011
"docs:typedoc": "typedoc",
1112
"docs:jsdoc": "node --experimental-strip-types scripts/docs.ts",
1213
"format": "prettier --ignore-path .eslintignore --write .",

packages/react-router/lib/dom/ssr/components.tsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,12 @@ export function Links(): React.JSX.Element {
295295
* @mode framework
296296
* @param props Props
297297
* @param props.page The absolute path of the page to prefetch, e.g. `/absolute/path`.
298-
* @param props.dataLinkProps Additional props to pass to the
298+
* @param props.linkProps Additional props to spread onto the
299299
* [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link)
300-
* tag, such as `crossOrigin`, `integrity`, `rel`, etc.
300+
* tags, such as `crossOrigin`, `integrity`, `rel`, etc.
301301
* @returns A collection of React elements for `<link>` tags
302302
*/
303-
export function PrefetchPageLinks({
304-
page,
305-
...dataLinkProps
306-
}: PageLinkDescriptor) {
303+
export function PrefetchPageLinks({ page, ...linkProps }: PageLinkDescriptor) {
307304
let { router } = useDataRouterContext();
308305
let matches = React.useMemo(
309306
() => matchRoutes(router.routes, page, router.basename),
@@ -314,9 +311,7 @@ export function PrefetchPageLinks({
314311
return null;
315312
}
316313

317-
return (
318-
<PrefetchPageLinksImpl page={page} matches={matches} {...dataLinkProps} />
319-
);
314+
return <PrefetchPageLinksImpl page={page} matches={matches} {...linkProps} />;
320315
}
321316

322317
function useKeyedPrefetchLinks(matches: AgnosticDataRouteMatch[]) {
@@ -685,12 +680,12 @@ export type ScriptsProps = Omit<
685680
* @public
686681
* @category Components
687682
* @mode framework
688-
* @param props Props for the
683+
* @param scriptProps Additional props to spread onto the
689684
* [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script)
690685
* tag, such as `crossOrigin`, `nonce`, etc.
691686
* @returns A collection of React elements for `<script>` tags
692687
*/
693-
export function Scripts(props: ScriptsProps): React.JSX.Element | null {
688+
export function Scripts(scriptProps: ScriptsProps): React.JSX.Element | null {
694689
let {
695690
manifest,
696691
serverHandoffString,
@@ -822,13 +817,13 @@ import(${JSON.stringify(manifest.entry.module)});`;
822817
return (
823818
<>
824819
<script
825-
{...props}
820+
{...scriptProps}
826821
suppressHydrationWarning
827822
dangerouslySetInnerHTML={createHtml(contextScript)}
828823
type={undefined}
829824
/>
830825
<script
831-
{...props}
826+
{...scriptProps}
832827
suppressHydrationWarning
833828
dangerouslySetInnerHTML={createHtml(routeModulesScript)}
834829
type="module"
@@ -878,15 +873,15 @@ import(${JSON.stringify(manifest.entry.module)});`;
878873
<link
879874
rel="modulepreload"
880875
href={manifest.url}
881-
crossOrigin={props.crossOrigin}
876+
crossOrigin={scriptProps.crossOrigin}
882877
integrity={sri[manifest.url]}
883878
suppressHydrationWarning
884879
/>
885880
) : null}
886881
<link
887882
rel="modulepreload"
888883
href={manifest.entry.module}
889-
crossOrigin={props.crossOrigin}
884+
crossOrigin={scriptProps.crossOrigin}
890885
integrity={sri[manifest.entry.module]}
891886
suppressHydrationWarning
892887
/>
@@ -895,7 +890,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
895890
key={path}
896891
rel="modulepreload"
897892
href={path}
898-
crossOrigin={props.crossOrigin}
893+
crossOrigin={scriptProps.crossOrigin}
899894
integrity={sri[path]}
900895
suppressHydrationWarning
901896
/>

scripts/docs.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,39 @@ const { values: args } = util.parseArgs({
110110
type: "string",
111111
short: "o",
112112
},
113+
help: {
114+
type: "boolean",
115+
short: "h",
116+
},
113117
},
114118
allowPositionals: true,
115119
});
116120

117-
if (!args.path) {
118-
console.error(
119-
"Usage: docs.ts --path <filepath-or-glob> [--api <api1,api2,...>] [--write] [--output <output-dir>]",
121+
if (args.help) {
122+
console.log("\n");
123+
console.log(
124+
"Usage: docs.ts [--path <filepath-or-glob>] [--api <api1,api2,...>] [--write] [--output <output-dir>]",
125+
);
126+
console.log(
127+
' --path, -p File path or glob pattern to parse (default "packages/**/*.{ts,tsx}")',
120128
);
121-
console.error(" --path, -p File path or glob pattern to parse");
122-
console.error(
129+
console.log(
123130
" --api, -a Comma-separated list of specific APIs to generate",
124131
);
125-
console.error(" --write, -w Write markdown files to output directory");
126-
console.error(" --output, -o Output directory (default: docs/api)");
132+
console.log(" --write, -w Write markdown files to output directory");
133+
console.log(" --output, -o Output directory (default: docs/api)");
134+
process.exit(0);
135+
}
136+
137+
// Resolve file paths using glob patterns
138+
let pathGlob = args.path || "packages/**/*.{ts,tsx}";
139+
const filePaths = fg.sync(pathGlob, {
140+
onlyFiles: true,
141+
ignore: ["**/node_modules/**", "**/__tests__/**", "**/dist/**"],
142+
});
143+
144+
if (filePaths.length === 0) {
145+
console.error(`No files found matching pattern: ${pathGlob}`);
127146
process.exit(1);
128147
}
129148

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

143-
// Resolve file paths using glob patterns
144-
const filePaths = fg.sync(args.path, {
145-
onlyFiles: true,
146-
ignore: ["**/node_modules/**", "**/__tests__/**", "**/dist/**"],
147-
});
148-
149-
if (filePaths.length === 0) {
150-
console.error(`No files found matching pattern: ${args.path}`);
151-
process.exit(1);
152-
}
153-
154162
run();
155163

156164
// Generate markdown documentation for all matching files

0 commit comments

Comments
 (0)