Skip to content

Commit 189cf9e

Browse files
authored
feat: better integration with editor (#96)
1 parent 1ef813d commit 189cf9e

File tree

17 files changed

+350
-99
lines changed

17 files changed

+350
-99
lines changed

.changeset/wicked-beds-teach.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: better integration with editor

.cspell/devops.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
katanomi
2+
tekton
3+
tektonchains
4+
tektonconfigs
5+
tektonhubs
6+
tektoninstallersets
7+
tektonpipelines
8+
tektonresults
9+
tektontriggers

.cspell/k8s.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
openshiftpipelinesascodes

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ jobs:
3636
run: yarn --immutable
3737

3838
- name: Build and Lint
39-
run: yarn run-p build docs lint typecov
39+
run: |
40+
yarn build
41+
yarn run-p docs lint typecov
4042
env:
4143
PARSER_NO_WATCH: true
4244
RAW_TERMS_URL: ${{ secrets.RAW_TERMS_URL }}

.github/workflows/pkg-pr-new.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ jobs:
3232
run: yarn build
3333

3434
- name: Publish
35-
run: yarn dlx pkg-pr-new publish --compact
35+
run: yarn dlx pkg-pr-new publish --compact --packageManager=yarn

cspell.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '@alauda/doom/cspell'

docs/en/start.mdx

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sourceSHA: c3feb38cb30b2f92c125dfa6af05ca6f5e9a23fd299bbbd39f4726159b7d7079
2+
sourceSHA: b7fe69a866c3e8893f7eddf6720d3366865e8e03b58658225bdd926ad71d6c87
33
---
44

55
# Getting Started \{#start}
@@ -12,7 +12,7 @@ First, you can create a new directory with the following command:
1212
mkdir my-docs && cd my-docs
1313
```
1414

15-
Run `npm init -y` to initialize a project. You can install doom using npm, yarn, or pnpm:
15+
Run `npm init -y` to initialize a project. You can use npm, yarn, or pnpm to install doom:
1616

1717
<PackageManagerTabs command="install -D @alauda/doom typescript" />
1818

@@ -24,7 +24,7 @@ mkdir docs/en && echo '# Hello World' > docs/en/index.md
2424
mkdir docs/zh && echo '# 你好世界' > docs/zh/index.md
2525
```
2626

27-
Add the following scripts to your `package.json`:
27+
Add the following scripts to `package.json`:
2828

2929
```json
3030
{
@@ -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 safely use the global components provided by doom with type safety in `.mdx` files.
7676

7777
## CLI Tool \{#cli}
7878

@@ -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 command line parsing. Examples:
178+
- The `-g, --glob` parameter is required and 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 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 documents 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:
180+
2. `yarn translate -g '*'` will translate all document files under `<root>/<source>`.
181+
- The `-C, --copy` parameter is optional. It determines 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:
182182
- When this parameter is enabled:
183-
1. When translating `/<source>/abc.jpg`, `<root>/public/<source>/abc.jpg` will be copied to `<root>/public/<target>/abc.jpg`, and the reference path in the document will be changed to `/<target>/abc.jpg`.
184-
2. In `<root>/<source>/abc.mdx`, the `./assets/xyz.jpg` reference 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`, the `./assets/<source>/xyz.jpg` reference will copy `<root>/<source>/assets/<source>/xyz.jpg` to `<root>/<target>/assets/<target>/xyz.jpg`, and the reference path in the document will be changed to `./assets/<target>/xyz.jpg`.
183+
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 referencing `./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. For `<root>/<source>/abc.mdx` documents referencing `./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`.
186186
- When this parameter is 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. In `<root>/<source>/abc.mdx`, if `<root>/<target>/assets/<target>/xyz.jpg` exists, the reference path `./assets/<source>/xyz.jpg` will be changed to `./assets/<target>/xyz.jpg`; otherwise, it will be changed to `../<source>/assets/<target>/xyz.jpg`.
188+
2. For `<root>/<source>/abc.mdx` documents referencing `./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 the `source` and `target` directories will be compared, and unmatched `target` files except for `internalRoutes` will be automatically deleted.
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.
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 exporting.
214+
Please run `yarn build` before executing the export operation.
215215
:::
216216

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

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.
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.
235235

236-
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 building. Locally, you can set the following environment variable to speed up downloads:
236+
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"
@@ -256,4 +256,27 @@ Options:
256256
-h, --help display help for command
257257
```
258258

259+
`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:
260+
261+
- `eslint.config.mjs`:
262+
263+
```js
264+
import doom from '@alauda/doom/eslint'
265+
266+
export default await doom(new URL('docs', import.meta.url))
267+
```
268+
269+
- `cspell.config.mjs`:
270+
271+
```js
272+
export { default } from '@alauda/doom/cspell'
273+
```
274+
275+
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`:
276+
277+
```txt
278+
k8s
279+
kubernetes
280+
```
281+
259282
For more configuration, please refer to [Lint Configuration](./usage/configuration#lint)

docs/zh/start.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,27 @@ Options:
254254
-h, --help display help for command
255255
```
256256

257+
`doom lint` 基于 [`ESLint`](https://eslint.org/)[`cspell`](https://cspell.org/),如果希望在编辑器中拥有更好的体验,可以安装相应的插件 [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) / [CSpell](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker),然后创建相应的配置文件:
258+
259+
- `eslint.config.mjs`:
260+
261+
```js
262+
import doom from '@alauda/doom/eslint'
263+
264+
export default await doom(new URL('docs', import.meta.url))
265+
```
266+
267+
- `cspell.config.mjs`:
268+
269+
```js
270+
export { default } from '@alauda/doom/cspell'
271+
```
272+
273+
同时我们约定当前工作目录(`CWD`)下 `.cspell` 文件夹用于存放 CSpell 的字典文件,例如你可以创建 `.cspell/k8s.txt`
274+
275+
```txt
276+
k8s
277+
kubernetes
278+
```
279+
257280
更多配置请参考[文档检查配置](./usage/configuration#lint)

doom.config.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ reference:
2626
sidebar:
2727
collapsed: false
2828
editRepoBaseUrl: alauda/doom/tree/main/docs
29-
lint:
30-
cspellOptions:
31-
cspell:
32-
words:
33-
- katanomi
3429
algolia:
3530
appId: USO7A9NBAD
3631
apiKey: 44896d7bbb41e9c1e807699d1dbb7cee

eslint.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ import { importX } from 'eslint-plugin-import-x'
77
import * as reactHooks from 'eslint-plugin-react-hooks'
88
import { config, configs } from 'typescript-eslint'
99

10+
import doom from '@alauda/doom/eslint'
11+
1012
export default config(
1113
{
12-
ignores: ['.yarn', 'dist', 'lib', 'node_modules', 'test', 'pyodide'],
14+
ignores: ['pyodide'],
1315
},
16+
...(await doom(new URL('docs', import.meta.url))),
1417
eslint.configs.recommended,
1518
importX.flatConfigs.recommended,
1619
importX.flatConfigs.typescript,
@@ -37,6 +40,12 @@ export default config(
3740
],
3841
},
3942
},
43+
{
44+
files: ['**/*.mdx'],
45+
rules: {
46+
'react-hooks/rules-of-hooks': 'off',
47+
},
48+
},
4049
{
4150
settings: {
4251
'import-x/resolver-next': createTypeScriptImportResolver(),

0 commit comments

Comments
 (0)