Skip to content

Commit ba7a139

Browse files
authored
feat: support fixed language for edit repo (#178)
1 parent 2ec42a3 commit ba7a139

File tree

16 files changed

+743
-733
lines changed

16 files changed

+743
-733
lines changed

.changeset/hungry-suits-play.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@alauda/doom": minor
3+
---
4+
5+
feat: support fixed language for edit repo

docs/en/start.mdx

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sourceSHA: c33b80ecb945eca19b9040fa109dc33441d5a634de9ddd1d2e9247ea469a9569
2+
sourceSHA: 166fda7d9b168a1be0333c3b744b7dffb18ccbd32f7f9c6da426ce4c980b4b8a
33
---
44

55
# Getting Started \{#start}
@@ -72,7 +72,7 @@ Finally, create a `global.d.ts` file with the following content:
7272
/// <reference types="@alauda/doom/runtime" />
7373
```
7474

75-
This allows you to safely use the global components provided by doom in `.mdx` files with type safety.
75+
This allows you to use doom's global components in `.mdx` files with type safety.
7676

7777
## CLI Tool \{#cli}
7878

@@ -85,36 +85,36 @@ Usage: doom [options] [command]
8585
Doctor Doom making docs.
8686
8787
Options:
88-
-V, --version output the version number
89-
-c, --config <config> Specify the path to the config file
90-
-v <version> Specify the version of the documentation, can also be `unversioned` or `unversioned-x.y`
91-
-b, --base <base> Override the base of the documentation
92-
-p, --prefix <prefix> Specify the prefix of the documentation base
93-
-f, --force [boolean] Force to
94-
1. fetch latest reference remotes or scaffolding templates, otherwise use local cache
95-
2. translate ignore hash equality check and original text (default: false)
96-
-i, --ignore [boolean] Ignore internal routes (default: false)
97-
-d, --download [boolean] Display download pdf link on nav bar (default: false)
98-
-e, --export [boolean] Run or build in exporting PDF mode, `apis/**` and `*/apis/**` routes will be ignored automatically (default: false)
99-
-I, --include <language...> Include **only** the specific language(s), `en ru` for example
100-
-E, --exclude <language...> Include all languages except the specific language(s), `ru` for example
101-
-o, --out-dir <path> Override the `outDir` defined in the config file or the default `dist/{base}/{version}`, the resulting path will be `dist/{outDir}/{version}`
102-
-r, --redirect <enum> Whether to redirect to the locale closest to `navigator.language` when the user visits the site, could be `auto`, `never` or `only-default-lang` (default: "only-default-lang")
103-
-R, --edit-repo [boolean|url] Whether to enable or override the `editRepoBaseUrl` config feature, `https://github.com/` prefix could be omitted (default: false)
104-
-a, --algolia [boolean|alauda] Whether to enable or use the alauda (docs.alauda.io) preset for Algolia search (default: false)
105-
-S, --site-url Whether to enable the siteUrl for sitemap generation (default: false)
106-
-n, --no-open Do not open the browser after starting the server
107-
-h, --help display help for command
88+
-V, --version output the version number
89+
-c, --config <config> Specify the path to the config file
90+
-v <version> Specify the version of the documentation, can also be `unversioned` or `unversioned-x.y`
91+
-b, --base <base> Override the base of the documentation
92+
-p, --prefix <prefix> Specify the prefix of the documentation base
93+
-f, --force [boolean] Force to
94+
1. fetch latest reference remotes or scaffolding templates, otherwise use local cache
95+
2. translate ignore hash equality check and original text (default: false)
96+
-i, --ignore [boolean] Ignore internal routes (default: false)
97+
-d, --download [boolean] Display download pdf link on nav bar (default: false)
98+
-e, --export [boolean] Run or build in exporting PDF mode, `apis/**` and `*/apis/**` routes will be ignored automatically (default: false)
99+
-I, --include <language...> Include **only** the specific language(s), `en ru` for example
100+
-E, --exclude <language...> Include all languages except the specific language(s), `ru` for example
101+
-o, --out-dir <path> Override the `outDir` defined in the config file or the default `dist/{base}/{version}`, the resulting path will be `dist/{outDir}/{version}`
102+
-r, --redirect <enum> Whether to redirect to the locale closest to `navigator.language` when the user visits the site, could be `auto`, `never` or `only-default-lang` (default: "only-default-lang")
103+
-R, --edit-repo [boolean|url|lang] Whether to enable or override the `editRepoBaseUrl` config feature, `https://github.com/` prefix could be omitted; if a language code is provided, all other languages will use the same repo but with the language code as sub-path (default: false)
104+
-a, --algolia [boolean|alauda] Whether to enable or use the alauda (docs.alauda.io) preset for Algolia search (default: false)
105+
-S, --site-url Whether to enable the siteUrl for sitemap generation (default: false)
106+
-n, --no-open Do not open the browser after starting the server
107+
-h, --help display help for command
108108

109109
Commands:
110-
dev [options] [root] Start the development server
111-
build [root] Build the documentation
112-
preview|serve [options] [root] Preview the built documentation
113-
new [template] Generate scaffolding from templates
114-
translate [options] [root] Translate the documentation
115-
export [options] [root] Export the documentation as PDF, `apis/**` and `*/apis/**` routes will be ignored automatically
116-
lint [root] Lint the documentation
117-
help [command] display help for command
110+
dev [options] [root] Start the development server
111+
build [root] Build the documentation
112+
preview|serve [options] [root] Preview the built documentation
113+
new [template] Generate scaffolding from templates
114+
translate [options] [root] Translate the documentation
115+
export [options] [root] Export the documentation as PDF, `apis/**` and `*/apis/**` routes will be ignored automatically
116+
lint [options] [root] Lint the documentation
117+
help [command] display help for command
118118
```
119119
120120
For more configuration, please refer to [Configuration](./usage/configuration)
@@ -152,7 +152,7 @@ Run `yarn serve` to preview the built static files. Note that if you used `-b` o
152152

153153
### Using Scaffolding Templates \{#new}
154154

155-
Run `yarn new` to generate projects, modules, or documentation from scaffolding templates.
155+
Run `yarn new` to generate projects, modules, or documentation using scaffolding templates.
156156

157157
### Translating Documentation \{#translate}
158158

@@ -175,24 +175,24 @@ Options:
175175
-h, --help display help for command
176176
```
177177

178-
- The `-g, --glob` parameter is required. You can specify the directories or paths of files to translate, supporting `glob` syntax. Note that the parameter value must be quoted to avoid unexpected behavior from the command line parser. Examples:
178+
- The `-g, --glob` parameter is required. You can specify the directories or files to translate, supporting `glob` syntax. Note that the parameter value must be quoted to avoid unexpected behavior caused by command line parsing. Examples:
179179
1. `yarn translate -g abc xyz` will translate all documents under `<root>/<source>/abc` and `<root>/<source>/xyz` to `<root>/<target>/abc` and `<root>/<target>/xyz` respectively.
180-
2. `yarn translate -g '*'` will translate all document files under `<root>/<source>`.
181-
- The `-C, --copy` parameter is optional. It controls whether to copy local asset files to the target directory when the target file does not exist. The default is `false`, which means changing the asset reference path to the source path. Examples:
182-
- When this parameter is enabled:
180+
2. `yarn translate -g '*'` will translate all documents under `<root>/<source>`.
181+
- The `-C, --copy` parameter is optional. It controls whether to copy local resource files to the target directory when the target file does not exist. The default is `false`, which means changing the resource file reference path to the source path. Examples:
182+
- When enabled:
183183
1. When translating `/<source>/abc.jpg`, it will copy `<root>/public/<source>/abc.jpg` to `<root>/public/<target>/abc.jpg` and modify the reference path in the document to `/<target>/abc.jpg`.
184-
2. For `<root>/<source>/abc.mdx` documents, references like `./assets/xyz.jpg` will copy `<root>/<source>/assets/xyz.jpg` to `<root>/<target>/assets/xyz.jpg`, and the image reference path remains unchanged.
185-
3. For `<root>/<source>/abc.mdx` documents, references like `./assets/<source>/xyz.jpg` will copy `<root>/<source>/assets/<source>/xyz.jpg` to `<root>/<target>/assets/<target>/xyz.jpg` and modify the reference path in the document to `./assets/<target>/xyz.jpg`.
186-
- When this parameter is not enabled:
184+
2. In `<root>/<source>/abc.mdx`, when translating `./assets/xyz.jpg`, it will copy `<root>/<source>/assets/xyz.jpg` to `<root>/<target>/assets/xyz.jpg`, and the image reference path remains unchanged.
185+
3. In `<root>/<source>/abc.mdx`, when translating `./assets/<source>/xyz.jpg`, it will copy `<root>/<source>/assets/<source>/xyz.jpg` to `<root>/<target>/assets/<target>/xyz.jpg` and modify the reference path in the document to `./assets/<target>/xyz.jpg`.
186+
- When not enabled:
187187
1. When translating `/<source>/abc.jpg`, if `<root>/public/<target>/abc.jpg` exists, the reference path in the document will be changed to `/<target>/abc.jpg`; otherwise, the image reference path remains unchanged.
188-
2. For `<root>/<source>/abc.mdx` documents, references like `./assets/<source>/xyz.jpg`, if `<root>/<target>/assets/<target>/xyz.jpg` exists, the reference path will be changed to `./assets/<target>/xyz.jpg`; otherwise, it will be changed to `../<source>/assets/<target>/xyz.jpg`.
188+
2. In `<root>/<source>/abc.mdx`, when translating `./assets/<source>/xyz.jpg`, if `<root>/<target>/assets/<target>/xyz.jpg` exists, the reference path will be changed to `./assets/<target>/xyz.jpg`; otherwise, it will be changed to `../<source>/assets/<target>/xyz.jpg`.
189189

190190
:::warning
191-
Specifically, if you use `-g '*'` for full translation, the file lists of `source` and `target` directories will be compared, and unmatched `target` files except for `internalRoutes` will be automatically deleted.
191+
Specially, if you use `-g '*'` for full translation, the file lists of `source` and `target` directories will be compared, and unmatched `target` files except for `internalRoutes` will be automatically deleted.
192192
:::
193193

194194
:::tip
195-
The translation feature requires the local environment variable `AZURE_OPENAI_API_KEY` to be configured. Please contact your team leader to obtain it.
195+
The translation feature requires configuring the `AZURE_OPENAI_API_KEY` environment variable locally. Please contact your team leader to obtain it.
196196
:::
197197

198198
You can control translation behavior in the document metadata:
@@ -211,7 +211,7 @@ For more configuration, please refer to [Translation Configuration](./usage/conf
211211
### Exporting PDF \{#export}
212212
213213
:::warning
214-
Please run the `yarn build` command before performing the export operation.
214+
Please run the `yarn build` command before exporting.
215215
:::
216216

217217
```sh
@@ -231,15 +231,15 @@ Options:
231231
-h, --help display help for command
232232
```
233233

234-
Run `yarn export` to export the documentation as a PDF file. Note that if you used `-b` or `-p` parameters during build, you need to use the same `-b` and `-p` parameters during export.
234+
Run `yarn export` to export the documentation as PDF files. Note that if you used `-b` or `-p` parameters during build, you need to use the same `-b` and `-p` parameters during export.
235235

236236
The export feature depends on [`playwright`](https://playwright.dev). For CI pipelines, please use `build-harbor.alauda.cn/frontend/playwright-runner:doom` as the base image for dependency installation and documentation build. Locally, you can set the following environment variable to speed up downloads:
237237

238238
```dotenv title=".env.yarn"
239239
PLAYWRIGHT_DOWNLOAD_HOST="https://cdn.npmmirror.com/binaries/playwright"
240240
```
241241

242-
Besides exporting a full-site unified PDF document, `doom` also supports exporting a single PDF file by specifying an entry point. For more configuration, please refer to [Document Export Configuration](./usage/configuration#export)
242+
Besides exporting a complete PDF for the entire site, `doom` also supports exporting a single PDF file for a specified entry. For more configuration, please refer to [Documentation Export Configuration](./usage/configuration#export)
243243

244244
### Documentation Linting \{#lint}
245245

@@ -260,7 +260,7 @@ Options:
260260
-h, --help display help for command
261261
```
262262

263-
`doom lint` is based on [`ESLint`](https://eslint.org/) and [`cspell`](https://cspell.org/). For a better experience in editors, you can install the corresponding plugins [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) / [CSpell](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker), then create the corresponding configuration files:
263+
`doom lint` is based on [`ESLint`](https://eslint.org/) and [`cspell`](https://cspell.org/). For a better experience in your editor, you can install the corresponding plugins [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) / [CSpell](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker), then create the corresponding configuration files:
264264

265265
- `eslint.config.mjs`:
266266

@@ -276,7 +276,7 @@ Options:
276276
export { default } from '@alauda/doom/cspell'
277277
```
278278
279-
We also agree that the `.cspell` folder in the current working directory (`CWD`) is used to store CSpell dictionary files. For example, you can create `.cspell/k8s.txt`:
279+
We also agree that the `.cspell` folder under the current working directory (`CWD`) is used to store CSpell dictionary files. For example, you can create `.cspell/k8s.txt`:
280280
281281
```txt
282282
k8s

docs/zh/start.mdx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -81,36 +81,36 @@ Usage: doom [options] [command]
8181
Doctor Doom making docs.
8282
8383
Options:
84-
-V, --version output the version number
85-
-c, --config <config> Specify the path to the config file
86-
-v <version> Specify the version of the documentation, can also be `unversioned` or `unversioned-x.y`
87-
-b, --base <base> Override the base of the documentation
88-
-p, --prefix <prefix> Specify the prefix of the documentation base
89-
-f, --force [boolean] Force to
90-
1. fetch latest reference remotes or scaffolding templates, otherwise use local cache
91-
2. translate ignore hash equality check and original text (default: false)
92-
-i, --ignore [boolean] Ignore internal routes (default: false)
93-
-d, --download [boolean] Display download pdf link on nav bar (default: false)
94-
-e, --export [boolean] Run or build in exporting PDF mode, `apis/**` and `*/apis/**` routes will be ignored automatically (default: false)
95-
-I, --include <language...> Include **only** the specific language(s), `en ru` for example
96-
-E, --exclude <language...> Include all languages except the specific language(s), `ru` for example
97-
-o, --out-dir <path> Override the `outDir` defined in the config file or the default `dist/{base}/{version}`, the resulting path will be `dist/{outDir}/{version}`
98-
-r, --redirect <enum> Whether to redirect to the locale closest to `navigator.language` when the user visits the site, could be `auto`, `never` or `only-default-lang` (default: "only-default-lang")
99-
-R, --edit-repo [boolean|url] Whether to enable or override the `editRepoBaseUrl` config feature, `https://github.com/` prefix could be omitted (default: false)
100-
-a, --algolia [boolean|alauda] Whether to enable or use the alauda (docs.alauda.io) preset for Algolia search (default: false)
101-
-S, --site-url Whether to enable the siteUrl for sitemap generation (default: false)
102-
-n, --no-open Do not open the browser after starting the server
103-
-h, --help display help for command
84+
-V, --version output the version number
85+
-c, --config <config> Specify the path to the config file
86+
-v <version> Specify the version of the documentation, can also be `unversioned` or `unversioned-x.y`
87+
-b, --base <base> Override the base of the documentation
88+
-p, --prefix <prefix> Specify the prefix of the documentation base
89+
-f, --force [boolean] Force to
90+
1. fetch latest reference remotes or scaffolding templates, otherwise use local cache
91+
2. translate ignore hash equality check and original text (default: false)
92+
-i, --ignore [boolean] Ignore internal routes (default: false)
93+
-d, --download [boolean] Display download pdf link on nav bar (default: false)
94+
-e, --export [boolean] Run or build in exporting PDF mode, `apis/**` and `*/apis/**` routes will be ignored automatically (default: false)
95+
-I, --include <language...> Include **only** the specific language(s), `en ru` for example
96+
-E, --exclude <language...> Include all languages except the specific language(s), `ru` for example
97+
-o, --out-dir <path> Override the `outDir` defined in the config file or the default `dist/{base}/{version}`, the resulting path will be `dist/{outDir}/{version}`
98+
-r, --redirect <enum> Whether to redirect to the locale closest to `navigator.language` when the user visits the site, could be `auto`, `never` or `only-default-lang` (default: "only-default-lang")
99+
-R, --edit-repo [boolean|url|lang] Whether to enable or override the `editRepoBaseUrl` config feature, `https://github.com/` prefix could be omitted; if a language code is provided, all other languages will use the same repo but with the language code as sub-path (default: false)
100+
-a, --algolia [boolean|alauda] Whether to enable or use the alauda (docs.alauda.io) preset for Algolia search (default: false)
101+
-S, --site-url Whether to enable the siteUrl for sitemap generation (default: false)
102+
-n, --no-open Do not open the browser after starting the server
103+
-h, --help display help for command
104104

105105
Commands:
106-
dev [options] [root] Start the development server
107-
build [root] Build the documentation
108-
preview|serve [options] [root] Preview the built documentation
109-
new [template] Generate scaffolding from templates
110-
translate [options] [root] Translate the documentation
111-
export [options] [root] Export the documentation as PDF, `apis/**` and `*/apis/**` routes will be ignored automatically
112-
lint [root] Lint the documentation
113-
help [command] display help for command
106+
dev [options] [root] Start the development server
107+
build [root] Build the documentation
108+
preview|serve [options] [root] Preview the built documentation
109+
new [template] Generate scaffolding from templates
110+
translate [options] [root] Translate the documentation
111+
export [options] [root] Export the documentation as PDF, `apis/**` and `*/apis/**` routes will be ignored automatically
112+
lint [options] [root] Lint the documentation
113+
help [command] display help for command
114114
```
115115
116116
更多配置请参考[配置](./usage/configuration)

doom.config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ reference:
2525
path: docs/zh/usage/configuration.md#reference
2626
sidebar:
2727
collapsed: false
28-
editRepoBaseUrl: alauda/doom/tree/main/docs
28+
editRepoBaseUrl: alauda/doom/blob/main/docs
2929
algolia:
3030
appId: USO7A9NBAD
3131
apiKey: 44896d7bbb41e9c1e807699d1dbb7cee

0 commit comments

Comments
 (0)