docs(core): render links in command descriptions (#30832)

Render links as links in command descriptions
- in the terminal, links are listed as text
- on the docs site, links are rendered as markdown links
This commit is contained in:
Isaac Mann 2025-05-08 13:37:17 -04:00 committed by GitHub
parent 0bf114eb11
commit b6dc0d9e8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 114 additions and 93 deletions

View File

@ -1,11 +1,11 @@
--- ---
title: 'affected - CLI command' title: 'affected - CLI command'
description: 'Run target for affected projects.' description: 'Run target for affected projects. See https://nx.dev/ci/features/affected for more details.'
--- ---
# affected # affected
Run target for affected projects. Run target for affected projects. See [https://nx.dev/ci/features/affected](/ci/features/affected) for more details.
## Usage ## Usage

View File

@ -18,7 +18,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
## Options ## Options
| Option | Type | Description | | Option | Type | Description |
| -------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | -------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--allPrompts`, `--a` | boolean | Show all prompts. (Default: `false`) | | `--allPrompts`, `--a` | boolean | Show all prompts. (Default: `false`) |
| `--appName` | string | The name of the app when using a monorepo with certain stacks. | | `--appName` | string | The name of the app when using a monorepo with certain stacks. |
| `--bundler` | string | Bundler to be used to build the app. | | `--bundler` | string | Bundler to be used to build the app. |
@ -38,7 +38,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
| `--nxCloud`, `--ci` | `github`, `gitlab`, `azure`, `bitbucket-pipelines`, `circleci`, `skip`, `yes` | Which CI provider would you like to use? | | `--nxCloud`, `--ci` | `github`, `gitlab`, `azure`, `bitbucket-pipelines`, `circleci`, `skip`, `yes` | Which CI provider would you like to use? |
| `--packageManager`, `--pm` | `bun`, `npm`, `pnpm`, `yarn` | Package manager to use. (Default: `npm`) | | `--packageManager`, `--pm` | `bun`, `npm`, `pnpm`, `yarn` | Package manager to use. (Default: `npm`) |
| `--prefix` | string | Prefix to use for Angular component and directive selectors. | | `--prefix` | string | Prefix to use for Angular component and directive selectors. |
| `--preset` | string | Customizes the initial content of your workspace. Default presets include: ["apps", "npm", "ts", "web-components", "angular-monorepo", "angular-standalone", "react-monorepo", "react-standalone", "vue-monorepo", "vue-standalone", "nuxt", "nuxt-standalone", "next", "nextjs-standalone", "react-native", "expo", "nest", "express", "react", "vue", "angular", "node-standalone", "node-monorepo", "ts-standalone"]. To build your own see https://nx.dev/extending-nx/recipes/create-preset. | | `--preset` | string | Customizes the initial content of your workspace. Default presets include: ["apps", "npm", "ts", "web-components", "angular-monorepo", "angular-standalone", "react-monorepo", "react-standalone", "vue-monorepo", "vue-standalone", "nuxt", "nuxt-standalone", "next", "nextjs-standalone", "react-native", "expo", "nest", "express", "react", "vue", "angular", "node-standalone", "node-monorepo", "ts-standalone"]. To build your own see [https://nx.dev/extending-nx/recipes/create-preset](/extending-nx/recipes/create-preset). |
| `--routing` | boolean | Add a routing setup for an Angular or React app. (Default: `true`) | | `--routing` | boolean | Add a routing setup for an Angular or React app. (Default: `true`) |
| `--skipGit`, `--g` | boolean | Skip initializing a git repository. (Default: `false`) | | `--skipGit`, `--g` | boolean | Skip initializing a git repository. (Default: `false`) |
| `--ssr` | boolean | Enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering) for the Angular application. | | `--ssr` | boolean | Enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering) for the Angular application. |

View File

@ -5,7 +5,7 @@ description: 'Adds Nx to any type of workspace. It installs nx, creates an nx.js
# init # init
Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check https://nx.dev/recipes/adopting-nx. Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check [https://nx.dev/recipes/adopting-nx](/recipes/adopting-nx).
## Usage ## Usage

View File

@ -18,8 +18,8 @@ Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`
## Options ## Options
| Option | Type | Description | | Option | Type | Description |
| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--help` | boolean | Show help. | | `--help` | boolean | Show help. |
| `--nxCloudUrl` | string | The Nx Cloud URL of the instance you are trying to connect to. If no positional argument is provided, this command will connect to https://cloud.nx.app. | | `--nxCloudUrl` | string | The Nx Cloud URL of the instance you are trying to connect to. If no positional argument is provided, this command will connect to [https://cloud.nx.app](https://cloud.nx.app). |
| `--verbose` | boolean | Prints additional information about the commands (e.g., stack traces). | | `--verbose` | boolean | Prints additional information about the commands (e.g., stack traces). |
| `--version` | boolean | Show version number. | | `--version` | boolean | Show version number. |

View File

@ -3148,7 +3148,7 @@
"itemList": [], "itemList": [],
"isExternal": false, "isExternal": false,
"path": "/nx-api/nx/documents/affected", "path": "/nx-api/nx/documents/affected",
"tags": ["run-tasks"], "tags": ["run-tasks", "affected"],
"originalFilePath": "generated/cli/affected" "originalFilePath": "generated/cli/affected"
}, },
"/nx-api/nx/documents/format-check": { "/nx-api/nx/documents/format-check": {

View File

@ -1590,5 +1590,14 @@
"name": "Prepare applications for deployment via CI", "name": "Prepare applications for deployment via CI",
"path": "/ci/recipes/other/ci-deployment" "path": "/ci/recipes/other/ci-deployment"
} }
],
"affected": [
{
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
"file": "generated/packages/nx/documents/affected",
"id": "affected",
"name": "affected",
"path": "/nx-api/nx/documents/affected"
}
] ]
} }

View File

@ -3126,7 +3126,7 @@
"itemList": [], "itemList": [],
"isExternal": false, "isExternal": false,
"path": "nx/documents/affected", "path": "nx/documents/affected",
"tags": ["run-tasks"], "tags": ["run-tasks", "affected"],
"originalFilePath": "generated/cli/affected" "originalFilePath": "generated/cli/affected"
}, },
{ {

View File

@ -1,11 +1,11 @@
--- ---
title: 'affected - CLI command' title: 'affected - CLI command'
description: 'Run target for affected projects.' description: 'Run target for affected projects. See https://nx.dev/ci/features/affected for more details.'
--- ---
# affected # affected
Run target for affected projects. Run target for affected projects. See [https://nx.dev/ci/features/affected](/ci/features/affected) for more details.
## Usage ## Usage

View File

@ -18,7 +18,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
## Options ## Options
| Option | Type | Description | | Option | Type | Description |
| -------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | -------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--allPrompts`, `--a` | boolean | Show all prompts. (Default: `false`) | | `--allPrompts`, `--a` | boolean | Show all prompts. (Default: `false`) |
| `--appName` | string | The name of the app when using a monorepo with certain stacks. | | `--appName` | string | The name of the app when using a monorepo with certain stacks. |
| `--bundler` | string | Bundler to be used to build the app. | | `--bundler` | string | Bundler to be used to build the app. |
@ -38,7 +38,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
| `--nxCloud`, `--ci` | `github`, `gitlab`, `azure`, `bitbucket-pipelines`, `circleci`, `skip`, `yes` | Which CI provider would you like to use? | | `--nxCloud`, `--ci` | `github`, `gitlab`, `azure`, `bitbucket-pipelines`, `circleci`, `skip`, `yes` | Which CI provider would you like to use? |
| `--packageManager`, `--pm` | `bun`, `npm`, `pnpm`, `yarn` | Package manager to use. (Default: `npm`) | | `--packageManager`, `--pm` | `bun`, `npm`, `pnpm`, `yarn` | Package manager to use. (Default: `npm`) |
| `--prefix` | string | Prefix to use for Angular component and directive selectors. | | `--prefix` | string | Prefix to use for Angular component and directive selectors. |
| `--preset` | string | Customizes the initial content of your workspace. Default presets include: ["apps", "npm", "ts", "web-components", "angular-monorepo", "angular-standalone", "react-monorepo", "react-standalone", "vue-monorepo", "vue-standalone", "nuxt", "nuxt-standalone", "next", "nextjs-standalone", "react-native", "expo", "nest", "express", "react", "vue", "angular", "node-standalone", "node-monorepo", "ts-standalone"]. To build your own see https://nx.dev/extending-nx/recipes/create-preset. | | `--preset` | string | Customizes the initial content of your workspace. Default presets include: ["apps", "npm", "ts", "web-components", "angular-monorepo", "angular-standalone", "react-monorepo", "react-standalone", "vue-monorepo", "vue-standalone", "nuxt", "nuxt-standalone", "next", "nextjs-standalone", "react-native", "expo", "nest", "express", "react", "vue", "angular", "node-standalone", "node-monorepo", "ts-standalone"]. To build your own see [https://nx.dev/extending-nx/recipes/create-preset](/extending-nx/recipes/create-preset). |
| `--routing` | boolean | Add a routing setup for an Angular or React app. (Default: `true`) | | `--routing` | boolean | Add a routing setup for an Angular or React app. (Default: `true`) |
| `--skipGit`, `--g` | boolean | Skip initializing a git repository. (Default: `false`) | | `--skipGit`, `--g` | boolean | Skip initializing a git repository. (Default: `false`) |
| `--ssr` | boolean | Enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering) for the Angular application. | | `--ssr` | boolean | Enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering) for the Angular application. |

View File

@ -5,7 +5,7 @@ description: 'Adds Nx to any type of workspace. It installs nx, creates an nx.js
# init # init
Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check https://nx.dev/recipes/adopting-nx. Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check [https://nx.dev/recipes/adopting-nx](/recipes/adopting-nx).
## Usage ## Usage

View File

@ -18,8 +18,8 @@ Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`
## Options ## Options
| Option | Type | Description | | Option | Type | Description |
| -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--help` | boolean | Show help. | | `--help` | boolean | Show help. |
| `--nxCloudUrl` | string | The Nx Cloud URL of the instance you are trying to connect to. If no positional argument is provided, this command will connect to https://cloud.nx.app. | | `--nxCloudUrl` | string | The Nx Cloud URL of the instance you are trying to connect to. If no positional argument is provided, this command will connect to [https://cloud.nx.app](https://cloud.nx.app). |
| `--verbose` | boolean | Prints additional information about the commands (e.g., stack traces). | | `--verbose` | boolean | Prints additional information about the commands (e.g., stack traces). |
| `--version` | boolean | Show version number. | | `--version` | boolean | Show version number. |

View File

@ -2216,7 +2216,7 @@
}, },
{ {
"name": "affected", "name": "affected",
"tags": ["run-tasks"], "tags": ["run-tasks", "affected"],
"id": "affected", "id": "affected",
"file": "generated/cli/affected" "file": "generated/cli/affected"
}, },

View File

@ -14,7 +14,8 @@ import {
export const yargsAffectedCommand: CommandModule = { export const yargsAffectedCommand: CommandModule = {
command: 'affected', command: 'affected',
describe: 'Run target for affected projects.', describe:
'Run target for affected projects. See https://nx.dev/ci/features/affected for more details.',
builder: (yargs) => builder: (yargs) =>
linkToNxDevAndExamples( linkToNxDevAndExamples(
withAffectedOptions( withAffectedOptions(

View File

@ -131,19 +131,30 @@ export async function formatWithPrettier(filePath: string, content: string) {
return format(content, options); return format(content, options);
} }
export function wrapLinks(content: string): string {
const urlRegex = /(https?:\/\/)[^\s]+[a-zA-Z][a-zA-Z]/g;
const links = content.match(urlRegex) || [];
for (const link of links) {
const wrappedLink = `[${link}](${link.replace('https://nx.dev', '')})`;
content = content.replace(link, wrappedLink);
}
return content;
}
export function formatDescription( export function formatDescription(
description: string, description: string,
deprecated: boolean | string deprecated: boolean | string
) { ) {
const updatedDescription = wrapLinks(description);
if (!deprecated) { if (!deprecated) {
return description; return updatedDescription;
} }
if (!description) { if (!description) {
return `${bold('Deprecated:')} ${deprecated}`; return `${bold('Deprecated:')} ${deprecated}`;
} }
return deprecated === true return deprecated === true
? `${bold('Deprecated:')} ${description}` ? `${bold('Deprecated:')} ${updatedDescription}`
: mdLines(`${bold('Deprecated:')} ${deprecated}`, description); : mdLines(`${bold('Deprecated:')} ${deprecated}`, updatedDescription);
} }
export function getCommands(command: any) { export function getCommands(command: any) {