Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/weak-apricots-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/doom": minor
---

feat: add new `lint` command
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ jobs:
run: yarn run-p build docs lint typecov
env:
PARSER_NO_WATCH: true
RAW_TERMS_URL: ${{ secrets.RAW_TERMS_URL }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.type-coverage
.yarn/*
!.yarn/patches
!.yarn/plugins
Expand Down
6 changes: 3 additions & 3 deletions docs/en/start.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sourceSHA: b375fe90bc3c10daf2cf1af94d73c48daa4fd307ee7d1aad87947d4fe7b6eb1f
sourceSHA: abdacac359849f6bc46d4b115a537545544edd8d5bee65fe8732cd3cea8ec8e9
---

# Start \{#start}
Expand Down Expand Up @@ -116,7 +116,7 @@ Commands:

### Start Development Service \{#dev}

Run `yarn dev` to start the development service, and the browser will open the documentation homepage automatically.
Run `yarn dev` to start the development service, and the browser will automatically open the documentation homepage.

```sh
doom dev -h
Expand Down Expand Up @@ -188,7 +188,7 @@ In particular, when using `-g '*'` for full translation, the file lists of the `
:::

:::tip
The translation function must have the local environment variable `AZURE_OPENAI_API_KEY` configured. Please contact your team leader for this information.
The translation function requires the local environment variable `AZURE_OPENAI_API_KEY` to be configured. Please contact your team leader for this information.
:::

Metadata can be used in the document to control translation behavior:
Expand Down
9 changes: 8 additions & 1 deletion docs/en/usage/configuration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Configure `doom` documentation tool
weight: 1
sourceSHA: 8c04921d3d667333d5dd810c99aa189cd38774116eb48bf9425944810e400344
sourceSHA: e06d0647311a571bc2a3584ed125b83d6f6ab016738b27879f59aa32984fdd92
---

# Configuration {#configuration}
Expand Down Expand Up @@ -209,3 +209,10 @@ The final output should only include the results from the last step, and previou
```yaml
editRepoBaseUrl: alauda/doom/tree/main/docs # The prefix https://github.com/ can be omitted; it only takes effect when the `-R, --edit-repo` command line flag is enabled.
```

## Document Linting Configuration {#lint}

```yaml
lint:
cspellOptions: # optional, cspell configuration options, refer to https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-eslint-plugin#options
```
2 changes: 1 addition & 1 deletion docs/en/usage/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: >-
After completing the project development, we can deploy the project to the ACP
platform.
weight: 8
sourceSHA: b8be77fb7d7f9a2fb5fc34de8b0423df711c0220a02acad1c602f6cb2d3ab36a
sourceSHA: 3bb40af83c43ea6f891a330af703b5cb17133d17970dea35cde1a796e5b7b246
---

# Deployment
Expand Down
2 changes: 1 addition & 1 deletion docs/en/usage/reference.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
weight: 7
sourceSHA: 55d1c3e5a0991772e572dba8f769e80a1b6e32e84abcd3514caaf0028872f785
sourceSHA: ebb89470ba5bca9d172ff55b57b112b9a0376eec28cc74cdd7c8248f3772de44
---

# Referencing Documents
Expand Down
23 changes: 23 additions & 0 deletions docs/zh/start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ Commands:
help [command] display help for command
```

更多配置请参考[配置](./usage/configuration)

### 启动开发服务 \{#dev}

执行 `yarn dev` 启动开发服务,浏览器会自动打开文档首页
Expand Down Expand Up @@ -197,6 +199,8 @@ i18n:
title: DevOps 连接器
```

更多配置请参考[翻译配置](./usage/configuration#translate)

### 导出 PDF \{#export}

:::warning
Expand Down Expand Up @@ -228,3 +232,22 @@ Options:
```dotenv title=".env.yarn"
PLAYWRIGHT_DOWNLOAD_HOST="https://cdn.npmmirror.com/binaries/playwright"
```

### 文档检查 \{#lint}

```sh
doom lint -h

# output
Usage: doom lint [options] [root]

Lint the documentation

Arguments:
root Root directory of the documentation

Options:
-h, --help display help for command
```

更多配置请参考[文档检查配置](./usage/configuration#lint)
7 changes: 7 additions & 0 deletions docs/zh/usage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,10 @@ translate:
```yaml
editRepoBaseUrl: alauda/doom/tree/main/docs # https://github.com/ 前缀可以省略,仅当启用 `-R, --edit-repo` 命令行标志符时生效
```

## 文档检查配置 \{#lint}

```yaml
lint:
cspellOptions: # 可选,cspell 配置项,参考 https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-eslint-plugin#options
```
8 changes: 8 additions & 0 deletions doom.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ reference:
sidebar:
collapsed: false
editRepoBaseUrl: alauda/doom/tree/main/docs
lint:
cspellOptions:
cspell:
words:
- artifactcleanupruns
- katanomi
- testplans
- testmodules
18 changes: 9 additions & 9 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,28 @@ export default config(
eslint.configs.recommended,
importX.flatConfigs.recommended,
importX.flatConfigs.typescript,
configs.eslintRecommended,
...configs.strictTypeChecked,
{
files: ['**/*.{ts,tsx}'],
extends: [configs.eslintRecommended, configs.strictTypeChecked],
languageOptions: {
parserOptions: {
projectService: true,
},
},
settings: {
'import-x/resolver-next': [createTypeScriptImportResolver()],
},
rules: {
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/restrict-template-expressions': [
'error',
{ allowNumber: true },
],
},
},
{
settings: {
'import-x/resolver-next': createTypeScriptImportResolver(),
},
rules: {
'import-x/default': 'off',
'import-x/first': 'error',
'import-x/newline-after-import': 'error',
Expand Down Expand Up @@ -64,8 +68,4 @@ export default config(
'prefer-const': ['error', { destructuring: 'all' }],
},
},
{
files: ['**/*.js'],
...configs.disableTypeChecked,
},
)
15 changes: 15 additions & 0 deletions fixture-docs/doom.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,18 @@ internalRoutes:
- '*/internal/*.mdx'
- '*/concepts/**'
editRepoBaseUrl: alauda/doom/tree/main/fixture-docs
lint:
cspellOptions:
cspell:
words:
- gatewayview
- netrelationship
- openshiftpipelinesascodes
- tekton
- tektonchains
- tektonconfigs
- tektonhubs
- tektoninstallersets
- tektonpipelines
- tektonresults
- tektontriggers
22 changes: 15 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"fixture": "yarn dev fixture-docs",
"format": "prettier --write .",
"lint": "run-p 'lint:*'",
"lint:doom": "yarn doom lint",
"lint:es": "eslint . --cache",
"lint:tsc": "tsc -b",
"prepare": "simple-git-hooks && patch-package && yarn-berry-deduplicate || exit 0",
Expand All @@ -56,19 +57,25 @@
"version": "changeset version && yarn --no-immutable"
},
"dependencies": {
"@cspell/eslint-plugin": "^9.0.1",
"@eslint-react/eslint-plugin": "^1.49.0",
"@inquirer/prompts": "^7.5.1",
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
"@playwright/browser-chromium": "^1.52.0",
"@rsbuild/plugin-yaml": "^1.0.2",
"@rspress/core": "1.43.13",
"@shikijs/transformers": "^3.4.0",
"@rspress/core": "1.44.0",
"@shikijs/transformers": "^3.4.2",
"chokidar": "^4.0.3",
"cli-progress": "^3.12.0",
"clsx": "^2.1.1",
"commander": "^13.1.0",
"ejs": "^3.1.10",
"es-toolkit": "^1.37.2",
"eslint": "^9.26.0",
"eslint-plugin-mdx": "^3.4.2",
"html-tag-names": "^2.1.0",
"mdast-util-mdx": "^2.0.1",
"mdast-util-mdx-jsx": "^2.1.4",
"mermaid": "^11.6.0",
"openai": "^5.0.0-beta.0",
"openapi-types": "^12.1.3",
Expand All @@ -82,18 +89,21 @@
"remark-directive": "^2.0.1",
"remark-frontmatter": "^4.0.1",
"remark-gfm": "^3.0.1",
"shiki": "^3.4.0",
"remark-mdx": "^2.3.0",
"remark-stringify": "^10.0.3",
"shiki": "^3.4.2",
"simple-git": "^3.27.0",
"swagger2openapi": "^7.0.8",
"tinyglobby": "^0.2.13",
"type-fest": "^4.41.0",
"typescript-eslint": "^8.32.1",
"x-fetch": "^0.2.6",
"yaml": "^2.7.1",
"yaml": "^2.8.0",
"yoctocolors": "^2.1.1"
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.1",
"@changesets/cli": "^2.29.3",
"@changesets/cli": "^2.29.4",
"@eslint/js": "^9.26.0",
"@swc-node/register": "^1.10.10",
"@swc/core": "1.11.24",
Expand All @@ -107,7 +117,6 @@
"@types/swagger2openapi": "^7.0.4",
"@unts/patch-package": "^8.1.1",
"clean-pkg-json": "^1.3.0",
"eslint": "^9.26.0",
"eslint-import-resolver-typescript": "^4.3.4",
"eslint-plugin-import-x": "^4.11.1",
"nano-staged": "^0.8.0",
Expand All @@ -118,7 +127,6 @@
"simple-git-hooks": "^2.13.0",
"type-coverage": "^2.29.7",
"typescript": "^5.8.3",
"typescript-eslint": "^8.32.0",
"yarn-berry-deduplicate": "^6.1.3"
},
"publishConfig": {
Expand Down
16 changes: 16 additions & 0 deletions src/cli/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import fs from 'node:fs/promises'

import { glob } from 'tinyglobby'
import { xfetch } from 'x-fetch'
import { parse } from 'yaml'

import { FALSY_VALUES } from '../shared/index.js'
import type { NormalizedTermItem } from '../terms.js'

export const parseBoolean = (value: string) =>
!!value && !FALSY_VALUES.has(value)
Expand Down Expand Up @@ -48,3 +51,16 @@ export const defaultGitHubUrl = (url: string) =>
/^https?:\/\//.test(url)
? url
: `https://github.com/${url.replace(/^(\/*github.com)?\/+/i, '')}`

const parseTerms_ = async () => {
const terms = await xfetch(
process.env.RAW_TERMS_URL ||
'https://gitlab-ce.alauda.cn/alauda-public/product-doc-guide/-/raw/main/terms.yaml',
{ type: 'text' },
)
return parse(terms) as NormalizedTermItem[]
}

let parsedTermsCache: Promise<NormalizedTermItem[]> | undefined

export const parseTerms = () => (parsedTermsCache ??= parseTerms_())
2 changes: 2 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { setNodeEnv } from '../utils/index.js'
import { CWD, DEFAULT_CONFIGS, I18N_FILE, SITES_FILE } from './constants.js'
import { exportCommand } from './export.js'
import { parseBoolean } from './helpers.js'
import { lintCommand } from './lint.js'
import { loadConfig } from './load-config.js'
import { newCommand } from './new.js'
import { translateCommand } from './translate.js'
Expand Down Expand Up @@ -253,6 +254,7 @@ program
program.addCommand(newCommand)
program.addCommand(translateCommand)
program.addCommand(exportCommand)
program.addCommand(lintCommand)

program.parseAsync().catch((err: unknown) => {
if (err instanceof Error && err.name === 'ExitPromptError') {
Expand Down
Loading