@alauda/doom 2.5.4 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/api.d.ts +2 -0
- package/lib/cli/api.js +147 -0
- package/lib/cli/helpers.d.ts +1 -7
- package/lib/cli/helpers.js +4 -41
- package/lib/cli/index.js +2 -0
- package/lib/cli/translate-agent.d.ts +81 -0
- package/lib/cli/translate-agent.js +450 -0
- package/lib/cli/translate-check.d.ts +17 -0
- package/lib/cli/translate-check.js +67 -0
- package/lib/cli/translate-checker.d.ts +58 -0
- package/lib/cli/translate-checker.js +112 -0
- package/lib/cli/translate-judge.d.ts +119 -0
- package/lib/cli/translate-judge.js +224 -0
- package/lib/cli/translate-limits.d.ts +43 -0
- package/lib/cli/translate-limits.js +55 -0
- package/lib/cli/translate-mask.d.ts +144 -0
- package/lib/cli/translate-mask.js +617 -0
- package/lib/cli/translate-models.d.ts +127 -0
- package/lib/cli/translate-models.js +189 -0
- package/lib/cli/translate-scratch.d.ts +142 -0
- package/lib/cli/translate-scratch.js +187 -0
- package/lib/cli/translate-terms.d.ts +22 -0
- package/lib/cli/translate-terms.js +33 -0
- package/lib/cli/translate.d.ts +15 -10
- package/lib/cli/translate.js +228 -185
- package/lib/eslint.js +22 -3
- package/lib/plugins/api/index.js +1 -1
- package/lib/plugins/api/types.d.ts +36 -1
- package/lib/plugins/global/components.d.ts +16 -0
- package/lib/plugins/global/components.js +16 -1
- package/lib/remark-lint/index.d.ts +20 -0
- package/lib/remark-lint/index.js +40 -0
- package/lib/remark-lint/no-unmatched-anchor.d.ts +10 -0
- package/lib/remark-lint/no-unmatched-anchor.js +19 -2
- package/lib/remark-lint/no-unopened-frontmatter.d.ts +2 -0
- package/lib/remark-lint/no-unopened-frontmatter.js +70 -0
- package/lib/remark-lint/no-unparsed-emphasis.d.ts +2 -0
- package/lib/remark-lint/no-unparsed-emphasis.js +53 -0
- package/lib/remark-lint/no-unresolved-api-ref.d.ts +40 -0
- package/lib/remark-lint/no-unresolved-api-ref.js +194 -0
- package/lib/remark-lint/rule-sets.d.ts +73 -0
- package/lib/remark-lint/rule-sets.js +114 -0
- package/lib/remark-lint/syntax-plugins.d.ts +32 -0
- package/lib/remark-lint/syntax-plugins.js +46 -0
- package/lib/remark-lint/translation-parity/component-multiset.d.ts +17 -0
- package/lib/remark-lint/translation-parity/component-multiset.js +35 -0
- package/lib/remark-lint/translation-parity/echoed-source.d.ts +2 -0
- package/lib/remark-lint/translation-parity/echoed-source.js +37 -0
- package/lib/remark-lint/translation-parity/frontmatter-preservation.d.ts +2 -0
- package/lib/remark-lint/translation-parity/frontmatter-preservation.js +36 -0
- package/lib/remark-lint/translation-parity/heading-sequence.d.ts +12 -0
- package/lib/remark-lint/translation-parity/heading-sequence.js +25 -0
- package/lib/remark-lint/translation-parity/index.d.ts +24 -0
- package/lib/remark-lint/translation-parity/index.js +24 -0
- package/lib/remark-lint/translation-parity/jsx-attribute-parity.d.ts +14 -0
- package/lib/remark-lint/translation-parity/jsx-attribute-parity.js +47 -0
- package/lib/remark-lint/translation-parity/length-ratio.d.ts +2 -0
- package/lib/remark-lint/translation-parity/length-ratio.js +49 -0
- package/lib/remark-lint/translation-parity/link-isomorphism.d.ts +34 -0
- package/lib/remark-lint/translation-parity/link-isomorphism.js +81 -0
- package/lib/remark-lint/translation-parity/shared.d.ts +110 -0
- package/lib/remark-lint/translation-parity/shared.js +286 -0
- package/lib/remark-lint/translation-parity/terminology-adherence.d.ts +2 -0
- package/lib/remark-lint/translation-parity/terminology-adherence.js +67 -0
- package/lib/remark-lint/translation-parity/up-to-date.d.ts +11 -0
- package/lib/remark-lint/translation-parity/up-to-date.js +21 -0
- package/lib/remark-lint/translation-parity/url-residue.d.ts +3 -0
- package/lib/remark-lint/translation-parity/url-residue.js +67 -0
- package/lib/remarkrc.d.ts +1 -1
- package/lib/remarkrc.js +7 -34
- package/lib/runtime/api-paths.d.ts +20 -0
- package/lib/runtime/api-paths.js +29 -0
- package/lib/runtime/components/K8sAPI.d.ts +14 -1
- package/lib/runtime/components/K8sAPI.js +49 -10
- package/lib/runtime/components/K8sCrd.d.ts +1 -1
- package/lib/runtime/components/K8sPermissionTable.js +10 -5
- package/lib/runtime/components/OpenAPIPath.js +19 -2
- package/lib/runtime/components/_HeadingTitle.js +24 -6
- package/lib/runtime/components/_K8sAPIEndpoints.d.ts +8 -1
- package/lib/runtime/components/_K8sAPIEndpoints.js +27 -9
- package/lib/runtime/components/_K8sAPISchema.d.ts +9 -1
- package/lib/runtime/components/_K8sAPISchema.js +24 -6
- package/lib/runtime/components/_translation-policy.d.ts +23 -0
- package/lib/runtime/components/_translation-policy.js +32 -0
- package/lib/runtime/hooks/useTranslation.d.ts +1 -1
- package/lib/runtime/translation.d.ts +68 -0
- package/lib/runtime/translation.js +51 -0
- package/lib/runtime/utils.d.ts +24 -2
- package/lib/runtime/utils.js +87 -5
- package/lib/shared/constants.d.ts +9 -0
- package/lib/shared/constants.js +14 -0
- package/lib/types.d.ts +70 -0
- package/lib/utils/helpers.js +8 -2
- package/package.json +3 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which JSX attributes carry prose that must reach the translation model.
|
|
3
|
+
*
|
|
4
|
+
* Everything that is **not** listed here is masked before a document is handed
|
|
5
|
+
* to the model (see `cli/translate-mask.ts`). The default is deliberate, and
|
|
6
|
+
* the failure modes are asymmetric:
|
|
7
|
+
*
|
|
8
|
+
* - over-masking leaves a label in the source language — visible and harmless;
|
|
9
|
+
* - under-masking lets an identifier (`Term name`, `K8sAPI name`, an `href`, an
|
|
10
|
+
* anchor id) be rewritten — silent, and the page breaks.
|
|
11
|
+
*
|
|
12
|
+
* So a component that nobody has classified yet lands on the safe side, and the
|
|
13
|
+
* list below is the only thing that has to be maintained when a component grows
|
|
14
|
+
* a prose-bearing prop.
|
|
15
|
+
*
|
|
16
|
+
* This lives beside the component definitions on purpose: the components are
|
|
17
|
+
* doom's own, so one declaration here is correct for every repository that
|
|
18
|
+
* consumes doom — no per-repository allowlist.
|
|
19
|
+
*
|
|
20
|
+
* Keys are JSX element names as they appear in the document (`Term`, `img`, …).
|
|
21
|
+
*/
|
|
22
|
+
export declare const TRANSLATABLE_JSX_ATTRS: Readonly<Record<string, readonly string[] | undefined>>;
|
|
23
|
+
export declare const isTranslatableJsxAttr: (elementName: string | null | undefined, attrName: string) => boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which JSX attributes carry prose that must reach the translation model.
|
|
3
|
+
*
|
|
4
|
+
* Everything that is **not** listed here is masked before a document is handed
|
|
5
|
+
* to the model (see `cli/translate-mask.ts`). The default is deliberate, and
|
|
6
|
+
* the failure modes are asymmetric:
|
|
7
|
+
*
|
|
8
|
+
* - over-masking leaves a label in the source language — visible and harmless;
|
|
9
|
+
* - under-masking lets an identifier (`Term name`, `K8sAPI name`, an `href`, an
|
|
10
|
+
* anchor id) be rewritten — silent, and the page breaks.
|
|
11
|
+
*
|
|
12
|
+
* So a component that nobody has classified yet lands on the safe side, and the
|
|
13
|
+
* list below is the only thing that has to be maintained when a component grows
|
|
14
|
+
* a prose-bearing prop.
|
|
15
|
+
*
|
|
16
|
+
* This lives beside the component definitions on purpose: the components are
|
|
17
|
+
* doom's own, so one declaration here is correct for every repository that
|
|
18
|
+
* consumes doom — no per-repository allowlist.
|
|
19
|
+
*
|
|
20
|
+
* Keys are JSX element names as they appear in the document (`Term`, `img`, …).
|
|
21
|
+
*/
|
|
22
|
+
export const TRANSLATABLE_JSX_ATTRS = {
|
|
23
|
+
// "Current behavior", "DR pair requirements" — a rendered callout heading.
|
|
24
|
+
Directive: ['title'],
|
|
25
|
+
// The link text, passed as a prop rather than as children.
|
|
26
|
+
ExternalSiteLink: ['children'],
|
|
27
|
+
// "Web Console", "MySQL" — a rendered tab label.
|
|
28
|
+
Tab: ['label'],
|
|
29
|
+
// Alternative text is prose read by screen readers.
|
|
30
|
+
img: ['alt'],
|
|
31
|
+
};
|
|
32
|
+
export const isTranslatableJsxAttr = (elementName, attrName) => !!elementName && !!TRANSLATABLE_JSX_ATTRS[elementName]?.includes(attrName);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Language } from '../../shared/index.js';
|
|
2
2
|
export declare const useLang: () => Language;
|
|
3
|
-
export declare const useTranslation: () => (key: "function" | "name" | "description" | "delete" | "toc" | "create" | "update" | "password" | "close" | "collapse_all" | "expand_all" | "crd_no_schema" | "action" | "view" | "chinese" | "english" | "chinese_bad_cases" | "english_bad_cases" | "download_pdf" | "view_docs_as_pdf" | "ai_assistant" | "exclamation" | "semicolon" | "period" | "colon" | "user_login" | "user_login_tip1" | "user_login_tip2" | "customer_portal_global" | "customer_portal_china" | "account_id" | "username" | "captcha" | "login" | "current_field" | "field_required" | "ERR_INTERNET_DISCONNECTED" | "AccountDisabledError" | "CaptchaError" | "LoginError" | "NetworkError" | "TenantError" | "TenantNotFoundError" | "logout" | "hi_there" | "ai_assistant_tip" | "ai_assistant_placeholder" | "max_chars_exceeded_tip" | "
|
|
3
|
+
export declare const useTranslation: () => (key: "function" | "name" | "description" | "delete" | "type" | "parameters" | "required" | "toc" | "create" | "update" | "password" | "thinking" | "close" | "collapse_all" | "expand_all" | "crd_no_schema" | "action" | "view" | "chinese" | "english" | "property" | "specification" | "api_endpoints" | "available_api_endpoints" | "http_method" | "http_responses" | "http_code" | "response_body" | "query_parameters" | "body_parameters" | "parameter" | "common_parameters" | "request_body" | "response" | "chinese_bad_cases" | "english_bad_cases" | "download_pdf" | "view_docs_as_pdf" | "ai_assistant" | "exclamation" | "semicolon" | "period" | "colon" | "user_login" | "user_login_tip1" | "user_login_tip2" | "customer_portal_global" | "customer_portal_china" | "account_id" | "username" | "captcha" | "login" | "current_field" | "field_required" | "ERR_INTERNET_DISCONNECTED" | "AccountDisabledError" | "CaptchaError" | "LoginError" | "NetworkError" | "TenantError" | "TenantNotFoundError" | "logout" | "hi_there" | "ai_assistant_tip" | "ai_assistant_placeholder" | "max_chars_exceeded_tip" | "thinking_process" | "referenced_doc_links" | "view_more_related_docs" | "view_less_related_docs" | "new_chat" | "show_more" | "show_less" | "products" | "all_product_documentation" | "explore_doc_all_products") => string;
|
|
@@ -12,6 +12,23 @@ declare const en: {
|
|
|
12
12
|
chinese: string;
|
|
13
13
|
english: string;
|
|
14
14
|
description: string;
|
|
15
|
+
type: string;
|
|
16
|
+
required: string;
|
|
17
|
+
property: string;
|
|
18
|
+
specification: string;
|
|
19
|
+
api_endpoints: string;
|
|
20
|
+
available_api_endpoints: string;
|
|
21
|
+
http_method: string;
|
|
22
|
+
http_responses: string;
|
|
23
|
+
http_code: string;
|
|
24
|
+
response_body: string;
|
|
25
|
+
query_parameters: string;
|
|
26
|
+
body_parameters: string;
|
|
27
|
+
parameter: string;
|
|
28
|
+
parameters: string;
|
|
29
|
+
common_parameters: string;
|
|
30
|
+
request_body: string;
|
|
31
|
+
response: string;
|
|
15
32
|
chinese_bad_cases: string;
|
|
16
33
|
english_bad_cases: string;
|
|
17
34
|
download_pdf: string;
|
|
@@ -75,6 +92,23 @@ export declare const TRANSLATIONS: {
|
|
|
75
92
|
chinese: string;
|
|
76
93
|
english: string;
|
|
77
94
|
description: string;
|
|
95
|
+
type: string;
|
|
96
|
+
required: string;
|
|
97
|
+
property: string;
|
|
98
|
+
specification: string;
|
|
99
|
+
api_endpoints: string;
|
|
100
|
+
available_api_endpoints: string;
|
|
101
|
+
http_method: string;
|
|
102
|
+
http_responses: string;
|
|
103
|
+
http_code: string;
|
|
104
|
+
response_body: string;
|
|
105
|
+
query_parameters: string;
|
|
106
|
+
body_parameters: string;
|
|
107
|
+
parameter: string;
|
|
108
|
+
parameters: string;
|
|
109
|
+
common_parameters: string;
|
|
110
|
+
request_body: string;
|
|
111
|
+
response: string;
|
|
78
112
|
chinese_bad_cases: string;
|
|
79
113
|
english_bad_cases: string;
|
|
80
114
|
download_pdf: string;
|
|
@@ -136,6 +170,23 @@ export declare const TRANSLATIONS: {
|
|
|
136
170
|
chinese: string;
|
|
137
171
|
english: string;
|
|
138
172
|
description: string;
|
|
173
|
+
type: string;
|
|
174
|
+
required: string;
|
|
175
|
+
property: string;
|
|
176
|
+
specification: string;
|
|
177
|
+
api_endpoints: string;
|
|
178
|
+
available_api_endpoints: string;
|
|
179
|
+
http_method: string;
|
|
180
|
+
http_responses: string;
|
|
181
|
+
http_code: string;
|
|
182
|
+
response_body: string;
|
|
183
|
+
query_parameters: string;
|
|
184
|
+
body_parameters: string;
|
|
185
|
+
parameter: string;
|
|
186
|
+
parameters: string;
|
|
187
|
+
common_parameters: string;
|
|
188
|
+
request_body: string;
|
|
189
|
+
response: string;
|
|
139
190
|
chinese_bad_cases: string;
|
|
140
191
|
english_bad_cases: string;
|
|
141
192
|
download_pdf: string;
|
|
@@ -197,6 +248,23 @@ export declare const TRANSLATIONS: {
|
|
|
197
248
|
chinese: string;
|
|
198
249
|
english: string;
|
|
199
250
|
description: string;
|
|
251
|
+
type: string;
|
|
252
|
+
required: string;
|
|
253
|
+
property: string;
|
|
254
|
+
specification: string;
|
|
255
|
+
api_endpoints: string;
|
|
256
|
+
available_api_endpoints: string;
|
|
257
|
+
http_method: string;
|
|
258
|
+
http_responses: string;
|
|
259
|
+
http_code: string;
|
|
260
|
+
response_body: string;
|
|
261
|
+
query_parameters: string;
|
|
262
|
+
body_parameters: string;
|
|
263
|
+
parameter: string;
|
|
264
|
+
parameters: string;
|
|
265
|
+
common_parameters: string;
|
|
266
|
+
request_body: string;
|
|
267
|
+
response: string;
|
|
200
268
|
chinese_bad_cases: string;
|
|
201
269
|
english_bad_cases: string;
|
|
202
270
|
download_pdf: string;
|
|
@@ -12,6 +12,23 @@ const en = {
|
|
|
12
12
|
chinese: 'Chinese',
|
|
13
13
|
english: 'English',
|
|
14
14
|
description: 'Description',
|
|
15
|
+
type: 'Type',
|
|
16
|
+
required: 'Required',
|
|
17
|
+
property: 'Property',
|
|
18
|
+
specification: 'Specification',
|
|
19
|
+
api_endpoints: 'API Endpoints',
|
|
20
|
+
available_api_endpoints: 'The following API endpoints are available:',
|
|
21
|
+
http_method: 'HTTP method',
|
|
22
|
+
http_responses: 'HTTP responses',
|
|
23
|
+
http_code: 'HTTP code',
|
|
24
|
+
response_body: 'Response body',
|
|
25
|
+
query_parameters: 'Query parameters',
|
|
26
|
+
body_parameters: 'Body parameters',
|
|
27
|
+
parameter: 'Parameter',
|
|
28
|
+
parameters: 'Parameters',
|
|
29
|
+
common_parameters: 'Common Parameters',
|
|
30
|
+
request_body: 'Request Body',
|
|
31
|
+
response: 'Response',
|
|
15
32
|
chinese_bad_cases: 'Chinese Bad Cases',
|
|
16
33
|
english_bad_cases: 'English Bad Cases',
|
|
17
34
|
download_pdf: 'Download PDF',
|
|
@@ -73,6 +90,23 @@ const zh = {
|
|
|
73
90
|
chinese: '中文',
|
|
74
91
|
english: '英文',
|
|
75
92
|
description: '描述',
|
|
93
|
+
type: '类型',
|
|
94
|
+
required: '必填',
|
|
95
|
+
property: '属性',
|
|
96
|
+
specification: '规格',
|
|
97
|
+
api_endpoints: 'API 端点',
|
|
98
|
+
available_api_endpoints: '可用的 API 端点如下:',
|
|
99
|
+
http_method: 'HTTP 方法',
|
|
100
|
+
http_responses: 'HTTP 响应',
|
|
101
|
+
http_code: 'HTTP 状态码',
|
|
102
|
+
response_body: '响应体',
|
|
103
|
+
query_parameters: '查询参数',
|
|
104
|
+
body_parameters: '请求体参数',
|
|
105
|
+
parameter: '参数',
|
|
106
|
+
parameters: '参数',
|
|
107
|
+
common_parameters: '公共参数',
|
|
108
|
+
request_body: '请求体',
|
|
109
|
+
response: '响应',
|
|
76
110
|
chinese_bad_cases: '中文反例',
|
|
77
111
|
english_bad_cases: '英文反例',
|
|
78
112
|
download_pdf: '下载 PDF',
|
|
@@ -134,6 +168,23 @@ const ru = {
|
|
|
134
168
|
chinese: 'Китайский',
|
|
135
169
|
english: 'Английский',
|
|
136
170
|
description: 'Описание',
|
|
171
|
+
type: 'Тип',
|
|
172
|
+
required: 'Обязательно',
|
|
173
|
+
property: 'Свойство',
|
|
174
|
+
specification: 'Спецификация',
|
|
175
|
+
api_endpoints: 'API конечные точки',
|
|
176
|
+
available_api_endpoints: 'Доступны следующие API конечные точки:',
|
|
177
|
+
http_method: 'HTTP метод',
|
|
178
|
+
http_responses: 'HTTP ответы',
|
|
179
|
+
http_code: 'HTTP код',
|
|
180
|
+
response_body: 'Тело ответа',
|
|
181
|
+
query_parameters: 'Параметры запроса',
|
|
182
|
+
body_parameters: 'Параметры тела',
|
|
183
|
+
parameter: 'Параметр',
|
|
184
|
+
parameters: 'Параметры',
|
|
185
|
+
common_parameters: 'Общие параметры',
|
|
186
|
+
request_body: 'Тело запроса',
|
|
187
|
+
response: 'Ответ',
|
|
137
188
|
chinese_bad_cases: 'Примеры ошибок на китайском',
|
|
138
189
|
english_bad_cases: 'Примеры ошибок на английском',
|
|
139
190
|
download_pdf: 'Скачать PDF',
|
package/lib/runtime/utils.d.ts
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
2
2
|
export declare const modelName: (ref: string) => string;
|
|
3
3
|
export declare const resolveRef: <T extends object = OpenAPIV3_1.SchemaObject>(openapi: OpenAPIV3_1.Document, ref: string) => T | undefined;
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export type ReferenceValue = string | {
|
|
5
|
+
href: string;
|
|
6
|
+
routePath?: string | false;
|
|
6
7
|
};
|
|
8
|
+
export declare const COMMON_REFS: Record<string, string>;
|
|
7
9
|
export declare const omitRoutePathRefs: (routePath: string) => {
|
|
8
10
|
[k: string]: string;
|
|
9
11
|
};
|
|
12
|
+
export type CrdVersionStrategy = 'preferred' | 'storage' | 'first';
|
|
13
|
+
interface CrdVersionLike {
|
|
14
|
+
name: string;
|
|
15
|
+
served?: boolean;
|
|
16
|
+
storage?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Pick the CRD version a doc should render by default.
|
|
20
|
+
*
|
|
21
|
+
* - `preferred` (default): the version `kubectl` would resolve to — the
|
|
22
|
+
* highest-priority version whose `served` is not `false`. This is what an
|
|
23
|
+
* operator actually talks to, and it never renders a version the API server
|
|
24
|
+
* rejects.
|
|
25
|
+
* - `storage`: the version persisted in etcd (`storage: true`). An
|
|
26
|
+
* implementation detail, offered only as an explicit opt-in.
|
|
27
|
+
* - `first`: the legacy behavior — literally `spec.versions[0]`, i.e. whatever
|
|
28
|
+
* order the manifest happened to list.
|
|
29
|
+
*/
|
|
30
|
+
export declare const selectCrdVersionName: (versions: CrdVersionLike[] | undefined, strategy?: CrdVersionStrategy) => string | undefined;
|
|
10
31
|
export declare const CJK_PATTERN: RegExp;
|
|
11
32
|
export declare const handleCJKWhitespaces: (text?: string) => string;
|
|
33
|
+
export {};
|
package/lib/runtime/utils.js
CHANGED
|
@@ -34,14 +34,96 @@ const DEFAULT_COMMON_REFS = {
|
|
|
34
34
|
'v1.ObjectMeta': 'object-meta/',
|
|
35
35
|
};
|
|
36
36
|
const K8S_DOC_PREFIX = 'https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/';
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
// A reference config value plays two roles: the literal href a `RefLink` points
|
|
38
|
+
// at, AND the page-identity key `omitRoutePathRefs` uses to tell whether a ref
|
|
39
|
+
// is already documented on the current page. A `.html` href never equals a
|
|
40
|
+
// (locale-prefixed, extension-less) routePath, so a plain string silently
|
|
41
|
+
// disables the omit — which is exactly why acp-docs relies on `.html`. Split
|
|
42
|
+
// the two roles: `routePath: false` makes "never omit" explicit; a real
|
|
43
|
+
// routePath makes the omit actually work.
|
|
44
|
+
const resolveRefValue = (value) => typeof value === 'string'
|
|
45
|
+
? { href: value, routePath: value }
|
|
46
|
+
: { href: value.href, routePath: value.routePath ?? value.href };
|
|
47
|
+
const RESOLVED_REFS = {
|
|
48
|
+
...Object.fromEntries(Object.entries(DEFAULT_COMMON_REFS).map(([key, value]) => {
|
|
49
|
+
const href = `${K8S_DOC_PREFIX}${value}`;
|
|
50
|
+
return [key, { href, routePath: href }];
|
|
51
|
+
})),
|
|
52
|
+
...Object.fromEntries(Object.entries(virtual.references ?? {}).map(([key, value]) => [
|
|
39
53
|
key,
|
|
40
|
-
|
|
54
|
+
resolveRefValue(value),
|
|
41
55
|
])),
|
|
42
|
-
...virtual.references,
|
|
43
56
|
};
|
|
44
|
-
export const
|
|
57
|
+
export const COMMON_REFS = Object.fromEntries(Object.entries(RESOLVED_REFS).map(([key, { href }]) => [key, href]));
|
|
58
|
+
export const omitRoutePathRefs = (routePath) => Object.fromEntries(Object.entries(COMMON_REFS).filter(([key]) => {
|
|
59
|
+
const { routePath: rp } = RESOLVED_REFS[key];
|
|
60
|
+
// `false` → never omit (always link-only). Otherwise omit only on the
|
|
61
|
+
// page that IS this reference's own page.
|
|
62
|
+
return rp === false ? true : routePath !== rp.split('#')[0];
|
|
63
|
+
}));
|
|
64
|
+
/**
|
|
65
|
+
* Kubernetes version priority, equivalent to apimachinery's
|
|
66
|
+
* `CompareKubeAwareVersionStrings`: GA (`v1`) > beta (`v1beta1`) >
|
|
67
|
+
* alpha (`v1alpha1`); within the same tier the higher number wins; names that
|
|
68
|
+
* don't follow the convention sort last (lexicographically).
|
|
69
|
+
*/
|
|
70
|
+
const parseKubeVersion = (v) => {
|
|
71
|
+
const m = /^v(\d+)(?:(alpha|beta)(\d+))?$/.exec(v);
|
|
72
|
+
if (!m) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
major: +m[1],
|
|
77
|
+
tier: m[2] ? (m[2] === 'beta' ? 2 : 1) : 3,
|
|
78
|
+
minor: m[3] ? +m[3] : 0,
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
const compareKubeVersions = (a, b) => {
|
|
82
|
+
const pa = parseKubeVersion(a);
|
|
83
|
+
const pb = parseKubeVersion(b);
|
|
84
|
+
if (pa && !pb) {
|
|
85
|
+
return -1;
|
|
86
|
+
}
|
|
87
|
+
if (!pa && pb) {
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
if (!pa || !pb) {
|
|
91
|
+
return a.localeCompare(b);
|
|
92
|
+
}
|
|
93
|
+
if (pa.tier !== pb.tier) {
|
|
94
|
+
return pb.tier - pa.tier;
|
|
95
|
+
}
|
|
96
|
+
if (pa.major !== pb.major) {
|
|
97
|
+
return pb.major - pa.major;
|
|
98
|
+
}
|
|
99
|
+
return pb.minor - pa.minor;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Pick the CRD version a doc should render by default.
|
|
103
|
+
*
|
|
104
|
+
* - `preferred` (default): the version `kubectl` would resolve to — the
|
|
105
|
+
* highest-priority version whose `served` is not `false`. This is what an
|
|
106
|
+
* operator actually talks to, and it never renders a version the API server
|
|
107
|
+
* rejects.
|
|
108
|
+
* - `storage`: the version persisted in etcd (`storage: true`). An
|
|
109
|
+
* implementation detail, offered only as an explicit opt-in.
|
|
110
|
+
* - `first`: the legacy behavior — literally `spec.versions[0]`, i.e. whatever
|
|
111
|
+
* order the manifest happened to list.
|
|
112
|
+
*/
|
|
113
|
+
export const selectCrdVersionName = (versions, strategy = 'preferred') => {
|
|
114
|
+
if (!versions?.length) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
if (strategy === 'first') {
|
|
118
|
+
return versions[0].name;
|
|
119
|
+
}
|
|
120
|
+
if (strategy === 'storage') {
|
|
121
|
+
return (versions.find((v) => v.storage) ?? versions[0]).name;
|
|
122
|
+
}
|
|
123
|
+
const served = versions.filter((v) => v.served !== false);
|
|
124
|
+
const pool = served.length ? served : versions;
|
|
125
|
+
return [...pool].sort((a, b) => compareKubeVersions(a.name, b.name))[0].name;
|
|
126
|
+
};
|
|
45
127
|
export const CJK_PATTERN = /\p{sc=Han}/u;
|
|
46
128
|
export const handleCJKWhitespaces = (text) => {
|
|
47
129
|
if (!text) {
|
|
@@ -13,3 +13,12 @@ export declare const SUPPORTED_LANGUAGES: Language[];
|
|
|
13
13
|
export declare const TITLE_TRANSLATION_MAP: Array<Partial<Record<Language, string>>>;
|
|
14
14
|
export declare const UNVERSIONED = "unversioned";
|
|
15
15
|
export declare const UNVERSIONED_PREFIX = "unversioned-";
|
|
16
|
+
/**
|
|
17
|
+
* Directories that `doom translate` copies verbatim instead of translating.
|
|
18
|
+
* Override with `translate.copyOnlyDirectories`.
|
|
19
|
+
*
|
|
20
|
+
* The checks need this too: a copied document is supposed to still be in the
|
|
21
|
+
* source language, so asking whether it reads as Chinese is asking the wrong
|
|
22
|
+
* question of the right file.
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEFAULT_COPY_ONLY_DIRECTORIES: string[];
|
package/lib/shared/constants.js
CHANGED
|
@@ -101,3 +101,17 @@ export const TITLE_TRANSLATION_MAP = [
|
|
|
101
101
|
];
|
|
102
102
|
export const UNVERSIONED = 'unversioned';
|
|
103
103
|
export const UNVERSIONED_PREFIX = `${UNVERSIONED}-`;
|
|
104
|
+
/**
|
|
105
|
+
* Directories that `doom translate` copies verbatim instead of translating.
|
|
106
|
+
* Override with `translate.copyOnlyDirectories`.
|
|
107
|
+
*
|
|
108
|
+
* The checks need this too: a copied document is supposed to still be in the
|
|
109
|
+
* source language, so asking whether it reads as Chinese is asking the wrong
|
|
110
|
+
* question of the right file.
|
|
111
|
+
*/
|
|
112
|
+
export const DEFAULT_COPY_ONLY_DIRECTORIES = [
|
|
113
|
+
'apis/advanced_apis/**',
|
|
114
|
+
'apis/crds/**',
|
|
115
|
+
'apis/kubernetes_apis/**',
|
|
116
|
+
'apis/references/**',
|
|
117
|
+
];
|
package/lib/types.d.ts
CHANGED
|
@@ -27,6 +27,76 @@ export interface GlobalCliOptions {
|
|
|
27
27
|
export interface TranslateOptions {
|
|
28
28
|
systemPrompt?: string;
|
|
29
29
|
userPrompt?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Model id on the translation gateway. Defaults to `ALAUDA_OPENAI_MODEL`, and
|
|
32
|
+
* then to the version this was measured against.
|
|
33
|
+
*/
|
|
34
|
+
model?: string;
|
|
35
|
+
/** Reasoning effort for the translator. Defaults to `low`. */
|
|
36
|
+
reasoningEffort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
37
|
+
/**
|
|
38
|
+
* How many times a document's findings are fed back before it is failed.
|
|
39
|
+
* Exhausting them fails the document — it never ships what it could not fix.
|
|
40
|
+
*/
|
|
41
|
+
maxRepairRounds?: number;
|
|
42
|
+
/** Runaway guard: total model turns for one document, tool calls included. */
|
|
43
|
+
maxTurns?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Context the translator plans for, in tokens. Deliberately lower than what
|
|
46
|
+
* the gateway offers: planning for less costs a re-read, planning for more
|
|
47
|
+
* loses content.
|
|
48
|
+
*/
|
|
49
|
+
contextWindow?: number;
|
|
50
|
+
/** Cap on a single model response, in tokens. */
|
|
51
|
+
maxOutputTokens?: number;
|
|
52
|
+
/**
|
|
53
|
+
* How many documents are translated at once, and how many model calls may be
|
|
54
|
+
* in flight. Defaults to 2, or `ALAUDA_OPENAI_CONCURRENCY`.
|
|
55
|
+
*/
|
|
56
|
+
concurrency?: number;
|
|
57
|
+
/**
|
|
58
|
+
* The gateway's budget, in model requests a minute — calls, not documents, so
|
|
59
|
+
* the extra turns a repair round takes count against it. Defaults to 25, or
|
|
60
|
+
* `ALAUDA_OPENAI_REQUESTS_PER_MINUTE`.
|
|
61
|
+
*/
|
|
62
|
+
requestsPerMinute?: number;
|
|
63
|
+
/**
|
|
64
|
+
* The semantic check that reads both documents and says what the translation
|
|
65
|
+
* lost, added or got wrong — the only check that can see a translation which
|
|
66
|
+
* is well-formed and about something else.
|
|
67
|
+
*/
|
|
68
|
+
judge?: {
|
|
69
|
+
/**
|
|
70
|
+
* Who reviews. Defaults to a model that is *not* the translator, because
|
|
71
|
+
* two readings by one model share its blind spots and its preference for
|
|
72
|
+
* its own output. Set it to the translator's own id to turn that off.
|
|
73
|
+
*/
|
|
74
|
+
model?: string;
|
|
75
|
+
/** Defaults to `medium` — reading two documents against each other is the harder job. */
|
|
76
|
+
reasoningEffort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
77
|
+
/** How many independent readings must agree before a finding counts. Defaults to 2. */
|
|
78
|
+
draws?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Turns the judge off.
|
|
81
|
+
*
|
|
82
|
+
* Not a way to make a build pass: a document that fails the judge fails,
|
|
83
|
+
* and the escape hatch for one document is `i18n.disableAutoTranslation`
|
|
84
|
+
* in its own frontmatter. This exists for measuring what the judge is
|
|
85
|
+
* worth — running a corpus with and without it — and for a repository whose
|
|
86
|
+
* gateway has no budget for a second reading.
|
|
87
|
+
*/
|
|
88
|
+
enabled?: boolean;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Glob patterns (relative to each language directory) whose files are copied
|
|
92
|
+
* verbatim to the target language instead of being translated. Defaults to
|
|
93
|
+
* the generated API directories (`apis/advanced_apis/**`, `apis/crds/**`,
|
|
94
|
+
* `apis/kubernetes_apis/**`, `apis/references/**`) — override to change which
|
|
95
|
+
* content is copy-only. To keep a hand-maintained translation inside a
|
|
96
|
+
* copy-only directory, set `i18n.disableAutoTranslation: true` in that file's
|
|
97
|
+
* frontmatter.
|
|
98
|
+
*/
|
|
99
|
+
copyOnlyDirectories?: string[];
|
|
30
100
|
}
|
|
31
101
|
export interface LintOptions {
|
|
32
102
|
cspellOptions?: Partial<Options>;
|
package/lib/utils/helpers.js
CHANGED
|
@@ -22,7 +22,10 @@ export const resolveStaticConfig = async (filepath) => {
|
|
|
22
22
|
};
|
|
23
23
|
export async function generateRuntimeModule(patterns = [], kind, root, cwd, isProd, mapper) {
|
|
24
24
|
const runtimeModules = {};
|
|
25
|
-
|
|
25
|
+
// `tinyglobby`/`fdir` return files in filesystem (readdir) order, which is
|
|
26
|
+
// not stable across machines. Sort so the map insertion order — and thus the
|
|
27
|
+
// "first matched wins" tie-break in the API components — is deterministic.
|
|
28
|
+
const files = (patterns.length ? await glob(patterns, { cwd }) : []).sort();
|
|
26
29
|
for (const file of files) {
|
|
27
30
|
const result = await resolveStaticConfig(path.resolve(cwd, file));
|
|
28
31
|
runtimeModules[`doom-@${kind}/${file}.mjs`] =
|
|
@@ -32,7 +35,10 @@ export async function generateRuntimeModule(patterns = [], kind, root, cwd, isPr
|
|
|
32
35
|
files
|
|
33
36
|
.map((file, index) => `import _${index} from 'doom-@${kind}/${file}.mjs'`)
|
|
34
37
|
.join('\n') +
|
|
35
|
-
|
|
38
|
+
// `file` is relative to `cwd`; resolve it against `cwd` before making it
|
|
39
|
+
// relative to `root`, otherwise `path.relative` measures from
|
|
40
|
+
// `process.cwd()` and the key silently changes with the working directory.
|
|
41
|
+
`\nexport default {${files.map((file, index) => `'${path.relative(root, path.resolve(cwd, file))}':_${index}`).join(',')}}`;
|
|
36
42
|
return runtimeModules;
|
|
37
43
|
}
|
|
38
44
|
export const setNodeEnv = (env) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
"@alauda/doc-stream-sdk": "0.1.0",
|
|
47
47
|
"@alauda/doom-export": "^0.4.2",
|
|
48
48
|
"@cspell/eslint-plugin": "^10.0.0",
|
|
49
|
+
"@earendil-works/pi-agent-core": "0.84.3",
|
|
50
|
+
"@earendil-works/pi-ai": "0.84.3",
|
|
49
51
|
"@eslint-react/eslint-plugin": "^5.8.3",
|
|
50
52
|
"@eslint/js": "^10.0.1",
|
|
51
53
|
"@inquirer/prompts": "^8.4.3",
|