@alauda/doom 0.22.3 → 0.22.5
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/LICENSE +21 -0
- package/README.md +24 -1
- package/lib/cli/helpers.d.ts +1 -0
- package/lib/cli/helpers.js +3 -0
- package/lib/cli/index.js +3 -1
- package/lib/cli/load-config.d.ts +1 -1
- package/lib/cli/load-config.js +43 -3
- package/lib/cli/merge-pdfs/index.js +2 -1
- package/lib/global/VersionsNav/index.js +8 -2
- package/lib/plugins/replace/index.js +1 -1
- package/lib/plugins/replace/resolve-release.js +2 -1
- package/lib/runtime/components/OpenAPIPath.js +1 -1
- package/lib/runtime/components/OpenAPIRef.js +1 -1
- package/lib/shared/constants.d.ts +3 -2
- package/lib/shared/constants.js +14 -1
- package/lib/types.d.ts +3 -1
- package/package.json +14 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Alauda.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Doom
|
|
2
2
|
|
|
3
|
+
[](https://github.com/alauda/doom/actions/workflows/ci.yml?query=branch%3Amain)
|
|
4
|
+
[](https://github.com/plantain-00/type-coverage)
|
|
5
|
+
[](https://coderabbit.ai)
|
|
6
|
+
[](https://www.npmjs.com/package/@alauda/doom)
|
|
7
|
+
[](https://github.com/alauda/doom/releases)
|
|
8
|
+
|
|
9
|
+
[](https://conventionalcommits.org)
|
|
10
|
+
[](https://renovatebot.com)
|
|
11
|
+
[](https://standardjs.com)
|
|
12
|
+
[](https://github.com/prettier/prettier)
|
|
13
|
+
[](https://github.com/changesets/changesets)
|
|
14
|
+
|
|
3
15
|
Doctor Doom making docs.
|
|
4
16
|
|
|
5
|
-
Please view <https://doom.
|
|
17
|
+
Please view <https://doom.js.org/> for its documents.
|
|
18
|
+
|
|
19
|
+
## Changelog
|
|
20
|
+
|
|
21
|
+
Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md).
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
[MIT][] © [Alauda][]
|
|
26
|
+
|
|
27
|
+
[alauda]: https://www.alauda.io
|
|
28
|
+
[MIT]: http://opensource.org/licenses/MIT
|
package/lib/cli/helpers.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export declare const getMatchedDocFilePaths: (matched: string[]) => Promise<(str
|
|
|
6
6
|
* {@link https://github.com/web-infra-dev/rspress/blob/f3e6544780a371d7c629d8784f31dbcf28fb2b07/packages/core/src/node/utils/escapeHeadingIds.ts}
|
|
7
7
|
*/
|
|
8
8
|
export declare function escapeMarkdownHeadingIds(content: string): string;
|
|
9
|
+
export declare const defaultGitHubUrl: (url: string) => string;
|
package/lib/cli/helpers.js
CHANGED
|
@@ -29,3 +29,6 @@ export function escapeMarkdownHeadingIds(content) {
|
|
|
29
29
|
// prevent duplicate escaping
|
|
30
30
|
.replace('\\\\{#', '\\{#'));
|
|
31
31
|
}
|
|
32
|
+
export const defaultGitHubUrl = (url) => /^https?:\/\//.test(url)
|
|
33
|
+
? url
|
|
34
|
+
: `https://github.com/${url.replace(/^(\/*github.com)?\/+/i, '')}`;
|
package/lib/cli/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { build, dev, serve } from '@rspress/core';
|
|
|
9
9
|
import { watch } from 'chokidar';
|
|
10
10
|
import { program } from 'commander';
|
|
11
11
|
import { green } from 'yoctocolors';
|
|
12
|
+
import { FALSY_VALUES, TRUTHY_VALUES } from '../shared/index.js';
|
|
12
13
|
import { setNodeEnv } from '../utils/index.js';
|
|
13
14
|
import { CWD, DEFAULT_CONFIGS, I18N_FILE, SITES_FILE } from './constants.js';
|
|
14
15
|
import { exportCommand } from './export.js';
|
|
@@ -40,7 +41,8 @@ program
|
|
|
40
41
|
.option('-I, --include <language...>', 'Include **only** the specific language(s), `en ru` for example')
|
|
41
42
|
.option('-E, --exclude <language...>', 'Include all languages except the specific language(s), `ru` for example')
|
|
42
43
|
.option('-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}`')
|
|
43
|
-
.option('-r, --redirect <enum>', 'Whether to redirect to the locale closest to `navigator.language` when the user visits the site, could be `auto` or `
|
|
44
|
+
.option('-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`', 'only-default-lang')
|
|
45
|
+
.option('-R, --edit-repo [boolean|url]', 'Whether to enable or override the `editRepoBaseUrl` config feature, `https://github.com/` prefix could be omitted', (value) => FALSY_VALUES.has(value) ? false : TRUTHY_VALUES.has(value) || value, false)
|
|
44
46
|
.option('-n, --no-open [boolean]', 'Do not open the browser after starting the server')
|
|
45
47
|
.command('dev', { isDefault: true })
|
|
46
48
|
.description('Start the development server')
|
package/lib/cli/load-config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UserConfig } from '@rspress/core';
|
|
2
2
|
import type { GlobalCliOptions } from '../types.js';
|
|
3
|
-
export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, include, exclude, outDir, redirect, }?: GlobalCliOptions): Promise<{
|
|
3
|
+
export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, include, exclude, outDir, redirect, editRepo, }?: GlobalCliOptions): Promise<{
|
|
4
4
|
config: UserConfig;
|
|
5
5
|
filepath?: string;
|
|
6
6
|
}>;
|
package/lib/cli/load-config.js
CHANGED
|
@@ -7,15 +7,20 @@ import { logger } from '@rspress/shared/logger';
|
|
|
7
7
|
import { transformerMetaHighlight, transformerMetaWordHighlight, transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight, transformerRemoveNotationEscape, } from '@shikijs/transformers';
|
|
8
8
|
import { difference } from 'es-toolkit';
|
|
9
9
|
import rehypeRaw from 'rehype-raw';
|
|
10
|
+
import { cyan } from 'yoctocolors';
|
|
10
11
|
import { autoTocPlugin } from '../plugins/auto-toc/index.js';
|
|
11
12
|
import { apiPlugin, autoSidebarPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, shikiPlugin, } from '../plugins/index.js';
|
|
12
13
|
import { isExplicitlyUnversioned, UNVERSIONED, } from '../shared/index.js';
|
|
13
14
|
import { pathExists, pkgResolve, resolveStaticConfig } from '../utils/index.js';
|
|
14
15
|
import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
|
|
16
|
+
import { defaultGitHubUrl } from './helpers.js';
|
|
15
17
|
const DEFAULT_LOGO = '/logo.svg';
|
|
16
18
|
const KNOWN_LOCALE_CONFIGS = {
|
|
17
19
|
en: {
|
|
18
20
|
label: 'English',
|
|
21
|
+
editLink: {
|
|
22
|
+
text: '📝 Edit this page on GitHub',
|
|
23
|
+
},
|
|
19
24
|
},
|
|
20
25
|
zh: {
|
|
21
26
|
label: '简体中文',
|
|
@@ -25,6 +30,9 @@ const KNOWN_LOCALE_CONFIGS = {
|
|
|
25
30
|
outlineTitle: '本页概览',
|
|
26
31
|
prevPageText: '上一页',
|
|
27
32
|
nextPageText: '下一页',
|
|
33
|
+
editLink: {
|
|
34
|
+
text: '📝 在 GitHub 上编辑此页',
|
|
35
|
+
},
|
|
28
36
|
},
|
|
29
37
|
ru: {
|
|
30
38
|
label: 'Русский',
|
|
@@ -34,9 +42,12 @@ const KNOWN_LOCALE_CONFIGS = {
|
|
|
34
42
|
outlineTitle: 'Обзор страницы',
|
|
35
43
|
prevPageText: 'Предыдущая страница',
|
|
36
44
|
nextPageText: 'Следующая страница',
|
|
45
|
+
editLink: {
|
|
46
|
+
text: '📝 Редактировать эту страницу на GitHub',
|
|
47
|
+
},
|
|
37
48
|
},
|
|
38
49
|
};
|
|
39
|
-
const getCommonConfig = async ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, include, exclude, redirect, }) => {
|
|
50
|
+
const getCommonConfig = async ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, include, exclude, redirect, editRepo, }) => {
|
|
40
51
|
const fallbackToZh = 'lang' in config && !config.lang;
|
|
41
52
|
root = resolveDocRoot(CWD, root, config.root);
|
|
42
53
|
const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
|
|
@@ -44,6 +55,19 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
|
|
|
44
55
|
if (version && !isExplicitlyUnversioned(version)) {
|
|
45
56
|
base = userBase + `${version}/`;
|
|
46
57
|
}
|
|
58
|
+
let { editRepoBaseUrl } = config;
|
|
59
|
+
const editRepoEnabled = !!editRepo;
|
|
60
|
+
if (typeof editRepo === 'string') {
|
|
61
|
+
editRepoBaseUrl = editRepo;
|
|
62
|
+
}
|
|
63
|
+
if (editRepoEnabled) {
|
|
64
|
+
if (editRepoBaseUrl) {
|
|
65
|
+
editRepoBaseUrl = defaultGitHubUrl(editRepoBaseUrl);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
logger.error(`The \`${cyan('-R, --edit-repo')}\` flag is enabled specifically, but no \`${cyan('editRepoBaseUrl')}\` found, it will take no effect`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
47
71
|
const allLanguages = [];
|
|
48
72
|
const locales = [];
|
|
49
73
|
if (!fallbackToZh) {
|
|
@@ -68,10 +92,18 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
|
|
|
68
92
|
lang: name,
|
|
69
93
|
label: name,
|
|
70
94
|
...KNOWN_LOCALE_CONFIGS[name],
|
|
95
|
+
editLink: editRepoEnabled && editRepoBaseUrl
|
|
96
|
+
? {
|
|
97
|
+
docRepoBaseUrl: editRepoBaseUrl,
|
|
98
|
+
...KNOWN_LOCALE_CONFIGS.en.editLink,
|
|
99
|
+
...KNOWN_LOCALE_CONFIGS[name]?.editLink,
|
|
100
|
+
}
|
|
101
|
+
: undefined,
|
|
71
102
|
});
|
|
72
103
|
}
|
|
73
104
|
}
|
|
74
105
|
const unusedLanguages = difference(allLanguages, locales.map(({ lang }) => lang));
|
|
106
|
+
const { editLink, ...zhLocale } = KNOWN_LOCALE_CONFIGS.zh;
|
|
75
107
|
return {
|
|
76
108
|
userBase,
|
|
77
109
|
root,
|
|
@@ -103,7 +135,14 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
|
|
|
103
135
|
// https://github.com/web-infra-dev/rspress/issues/2011
|
|
104
136
|
outline: true,
|
|
105
137
|
localeRedirect: redirect,
|
|
106
|
-
...(fallbackToZh
|
|
138
|
+
...(fallbackToZh
|
|
139
|
+
? editRepoEnabled && editRepoBaseUrl
|
|
140
|
+
? {
|
|
141
|
+
...zhLocale,
|
|
142
|
+
editLink: { ...editLink, docRepoBaseUrl: editRepoBaseUrl },
|
|
143
|
+
}
|
|
144
|
+
: zhLocale
|
|
145
|
+
: { locales }),
|
|
107
146
|
},
|
|
108
147
|
plugins: [
|
|
109
148
|
apiPlugin({
|
|
@@ -179,7 +218,7 @@ const findConfig = async (basePath) => {
|
|
|
179
218
|
}
|
|
180
219
|
}
|
|
181
220
|
};
|
|
182
|
-
export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, include, exclude, outDir, redirect, } = {}) {
|
|
221
|
+
export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, include, exclude, outDir, redirect, editRepo, } = {}) {
|
|
183
222
|
let configFilePath;
|
|
184
223
|
if (configFile) {
|
|
185
224
|
configFilePath = path.resolve(configFile);
|
|
@@ -244,6 +283,7 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
|
|
|
244
283
|
include,
|
|
245
284
|
exclude,
|
|
246
285
|
redirect,
|
|
286
|
+
editRepo,
|
|
247
287
|
});
|
|
248
288
|
base = commonConfig.base;
|
|
249
289
|
const mergedConfig = mergeRsbuildConfig(commonConfig, config, {
|
|
@@ -23,7 +23,8 @@ export async function mergePDFs(entries) {
|
|
|
23
23
|
pyodide.FS.mkdirTree(MOUNT_DIR);
|
|
24
24
|
pyodide.FS.mount(
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
26
|
-
pyodide.FS.filesystems.NODEFS,
|
|
26
|
+
pyodide.FS.filesystems.NODEFS, // type-coverage:ignore-line -- out of control
|
|
27
|
+
{ root: pyodideDir }, MOUNT_DIR);
|
|
27
28
|
/**
|
|
28
29
|
* @see https://github.com/pyodide/pyodide/issues/3246#issuecomment-1312210155
|
|
29
30
|
* You need to prefix the path with emfs: or it will be treated as a url
|
|
@@ -73,7 +73,7 @@ const VersionsNav_ = () => {
|
|
|
73
73
|
}, []);
|
|
74
74
|
// hack way to detect nav menu recreation on theme change
|
|
75
75
|
useEffect(() => {
|
|
76
|
-
if (!navMenu
|
|
76
|
+
if (!navMenu) {
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -81,7 +81,13 @@ const VersionsNav_ = () => {
|
|
|
81
81
|
setNavMenu(getNavMenu);
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
|
-
|
|
84
|
+
const newNavMenu = getNavMenu();
|
|
85
|
+
if (newNavMenu !== navMenu) {
|
|
86
|
+
setNavMenu(newNavMenu);
|
|
87
|
+
}
|
|
88
|
+
else if (navMenu.parentNode) {
|
|
89
|
+
observer.observe(navMenu.parentNode, { childList: true });
|
|
90
|
+
}
|
|
85
91
|
return () => {
|
|
86
92
|
observer.disconnect();
|
|
87
93
|
};
|
|
@@ -60,7 +60,7 @@ export const replacePlugin = ({ lang, localBasePath, force, }) => {
|
|
|
60
60
|
}));
|
|
61
61
|
for (const result of results) {
|
|
62
62
|
if (result.status === 'rejected') {
|
|
63
|
-
logger.error(result.reason);
|
|
63
|
+
logger.error(result.reason); // type-coverage:ignore-line -- out of control
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
},
|
|
@@ -84,7 +84,8 @@ const resolveRelease_ = async (releaseTemplates, releaseQuery) => {
|
|
|
84
84
|
}
|
|
85
85
|
catch (err) {
|
|
86
86
|
if (err instanceof ResponseError) {
|
|
87
|
-
|
|
87
|
+
const error = err;
|
|
88
|
+
logger.error(`Failed to fetch release notes for query \`${red(releaseQuery)}\` with status \`${error.response.status}\` and ${error.data ? `data ${JSON.stringify(data, null, 2)}` : `message \`${error.message}\``}`);
|
|
88
89
|
}
|
|
89
90
|
return;
|
|
90
91
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const ACP_BASE = "/container_platform/";
|
|
2
|
-
export declare const FALSY_VALUES: Set<string>;
|
|
3
|
-
export declare const
|
|
2
|
+
export declare const FALSY_VALUES: Set<string | null | undefined>;
|
|
3
|
+
export declare const TRUTHY_VALUES: Set<string>;
|
|
4
|
+
export declare const JS_STR_FALSY_VALUES: Set<string | null | undefined>;
|
|
4
5
|
export declare const APIS_ROUTES: Set<string>;
|
|
5
6
|
export declare const Language: {
|
|
6
7
|
readonly en: "英文";
|
package/lib/shared/constants.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
export const ACP_BASE = '/container_platform/';
|
|
2
|
-
export const FALSY_VALUES = new Set([
|
|
2
|
+
export const FALSY_VALUES = new Set([
|
|
3
|
+
null,
|
|
4
|
+
undefined,
|
|
5
|
+
'',
|
|
6
|
+
'0',
|
|
7
|
+
'false',
|
|
8
|
+
'no',
|
|
9
|
+
'off',
|
|
10
|
+
'n',
|
|
11
|
+
'f',
|
|
12
|
+
]);
|
|
13
|
+
export const TRUTHY_VALUES = new Set(['1', 'true', 'yes', 'on', 'y', 't']);
|
|
3
14
|
export const JS_STR_FALSY_VALUES = new Set([
|
|
15
|
+
null,
|
|
16
|
+
undefined,
|
|
4
17
|
'',
|
|
5
18
|
'0',
|
|
6
19
|
'false',
|
package/lib/types.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ export interface GlobalCliOptions {
|
|
|
17
17
|
include?: string[];
|
|
18
18
|
exclude?: string[];
|
|
19
19
|
outDir?: string;
|
|
20
|
-
redirect?: 'auto' | 'never';
|
|
20
|
+
redirect?: 'auto' | 'never' | 'only-default-lang';
|
|
21
|
+
editRepo?: boolean | string;
|
|
21
22
|
}
|
|
22
23
|
export interface TranslateOptions {
|
|
23
24
|
systemPrompt?: string;
|
|
@@ -36,6 +37,7 @@ declare module '@rspress/shared' {
|
|
|
36
37
|
internalRoutes?: string[];
|
|
37
38
|
translate?: TranslateOptions;
|
|
38
39
|
shiki?: PluginShikiOptions;
|
|
40
|
+
editRepoBaseUrl?: string;
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
export type ContentProcessor = {
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
|
-
"repository": "git+https://github.com/alauda/
|
|
7
|
-
"homepage": "https://github.com/alauda/
|
|
6
|
+
"repository": "git+https://github.com/alauda/doom.git",
|
|
7
|
+
"homepage": "https://github.com/alauda/doom#readme",
|
|
8
8
|
"funding": "https://opencollective.com/alauda",
|
|
9
|
+
"license": "MIT",
|
|
9
10
|
"engines": {
|
|
10
11
|
"node": ">=18.17.0 <20 || >=20.1.0"
|
|
11
12
|
},
|
|
@@ -24,12 +25,20 @@
|
|
|
24
25
|
"styles",
|
|
25
26
|
"!lib/*.tsbuildinfo"
|
|
26
27
|
],
|
|
28
|
+
"keywords": [
|
|
29
|
+
"document",
|
|
30
|
+
"documentation",
|
|
31
|
+
"docs",
|
|
32
|
+
"mdx",
|
|
33
|
+
"rspress",
|
|
34
|
+
"rspress-plugins"
|
|
35
|
+
],
|
|
27
36
|
"dependencies": {
|
|
28
|
-
"@inquirer/prompts": "^7.5.
|
|
37
|
+
"@inquirer/prompts": "^7.5.1",
|
|
29
38
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
30
39
|
"@playwright/browser-chromium": "^1.52.0",
|
|
31
40
|
"@rsbuild/plugin-yaml": "^1.0.2",
|
|
32
|
-
"@rspress/core": "1.43.
|
|
41
|
+
"@rspress/core": "1.43.13",
|
|
33
42
|
"@shikijs/transformers": "^3.4.0",
|
|
34
43
|
"chokidar": "^4.0.3",
|
|
35
44
|
"cli-progress": "^3.12.0",
|