@alauda/doom 1.13.1 → 1.13.3
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/helpers.js +1 -1
- package/lib/cli/index.js +1 -0
- package/lib/cli/lint.d.ts +1 -0
- package/lib/cli/lint.js +10 -3
- package/lib/cli/load-config.d.ts +2 -2
- package/lib/cli/load-config.js +12 -8
- package/lib/global/VersionsNav/index.js +3 -3
- package/lib/plugins/api/index.d.ts +2 -2
- package/lib/plugins/api/index.js +1 -1
- package/lib/plugins/attributes/index.js +1 -1
- package/lib/plugins/attributes/remark-attributes/index.d.ts +1 -1
- package/lib/plugins/attributes/remark-attributes/index.js +3 -3
- package/lib/plugins/auto-sidebar/index.d.ts +2 -2
- package/lib/plugins/auto-sidebar/index.js +3 -3
- package/lib/plugins/auto-sidebar/utils.d.ts +1 -1
- package/lib/plugins/auto-sidebar/utils.js +2 -2
- package/lib/plugins/auto-sidebar/walk.js +2 -2
- package/lib/plugins/auto-toc/index.js +1 -1
- package/lib/plugins/auto-toc/remark-auto-toc.js +1 -1
- package/lib/plugins/directives/index.js +1 -1
- package/lib/plugins/global/index.d.ts +2 -2
- package/lib/plugins/global/index.js +2 -2
- package/lib/plugins/index.d.ts +9 -9
- package/lib/plugins/index.js +9 -9
- package/lib/plugins/mermaid/index.js +1 -1
- package/lib/plugins/permission/index.d.ts +2 -2
- package/lib/plugins/permission/index.js +1 -1
- package/lib/plugins/replace/index.d.ts +3 -3
- package/lib/plugins/replace/index.js +6 -6
- package/lib/plugins/replace/normalize-img-src.d.ts +1 -1
- package/lib/plugins/replace/normalize-img-src.js +1 -1
- package/lib/plugins/replace/parse-toc.js +1 -1
- package/lib/plugins/replace/rehype-normalize-link.js +1 -1
- package/lib/plugins/replace/remark-replace.d.ts +1 -1
- package/lib/plugins/replace/remark-replace.js +4 -4
- package/lib/plugins/replace/resolve-reference.d.ts +1 -1
- package/lib/plugins/replace/resolve-reference.js +3 -3
- package/lib/plugins/shiki/index.d.ts +1 -1
- package/lib/plugins/shiki/index.js +1 -1
- package/lib/plugins/shiki/transformers/index.d.ts +1 -1
- package/lib/plugins/shiki/transformers/index.js +1 -1
- package/lib/remark-lint/check-dead-links.d.ts +2 -0
- package/lib/remark-lint/check-dead-links.js +43 -0
- package/lib/remark-lint/index.d.ts +1 -0
- package/lib/remark-lint/index.js +1 -0
- package/lib/remarkrc.js +2 -1
- package/lib/runtime/components/index.d.ts +0 -2
- package/lib/runtime/components/index.js +0 -2
- package/lib/shared/index.d.ts +3 -3
- package/lib/shared/index.js +3 -3
- package/lib/types.d.ts +3 -2
- package/lib/utils/constants.d.ts +2 -0
- package/lib/utils/constants.js +2 -0
- package/lib/utils/helpers.d.ts +1 -1
- package/lib/utils/helpers.js +2 -2
- package/lib/utils/index.d.ts +4 -4
- package/lib/utils/index.js +4 -4
- package/package.json +15 -15
- package/lib/runtime/components/Card.d.ts +0 -1
- package/lib/runtime/components/Card.js +0 -1
- package/lib/runtime/components/LinkCard.d.ts +0 -1
- package/lib/runtime/components/LinkCard.js +0 -1
package/lib/cli/helpers.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import { glob } from 'tinyglobby';
|
|
3
3
|
import { xfetch } from 'x-fetch';
|
|
4
4
|
import { parse } from 'yaml';
|
|
5
|
-
import { FALSY_VALUES, TRUTHY_VALUES } from
|
|
5
|
+
import { FALSY_VALUES, TRUTHY_VALUES } from "../shared/index.js";
|
|
6
6
|
export const parseBoolean = (value) => value === undefined || !FALSY_VALUES.has(value);
|
|
7
7
|
export const parseBooleanOrString = (value) => value === undefined ||
|
|
8
8
|
(FALSY_VALUES.has(value) ? false : TRUTHY_VALUES.has(value) || value);
|
package/lib/cli/index.js
CHANGED
|
@@ -46,6 +46,7 @@ program
|
|
|
46
46
|
.option('-a, --algolia [boolean|alauda]', 'Whether to enable or use the alauda (docs.alauda.io) preset for Algolia search', parseBooleanOrString, false)
|
|
47
47
|
.option('-S, --site-url', 'Whether to enable the siteUrl for sitemap generation', parseBoolean, false)
|
|
48
48
|
.option('-n, --no-open', 'Do not open the browser after starting the server')
|
|
49
|
+
.option('--lang <language>', 'Specify the language of the documentation')
|
|
49
50
|
.command('dev', { isDefault: true })
|
|
50
51
|
.description('Start the development server')
|
|
51
52
|
.argument('[root]', 'Root directory of the documentation')
|
package/lib/cli/lint.d.ts
CHANGED
package/lib/cli/lint.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import { logger } from '@rspress/core';
|
|
3
4
|
import { Command } from 'commander';
|
|
4
5
|
import { ESLint } from 'eslint';
|
|
5
6
|
import { cyan } from 'yoctocolors';
|
|
6
|
-
import doom from
|
|
7
|
-
import {
|
|
7
|
+
import doom from "../eslint.js";
|
|
8
|
+
import { OPTIONS_FILE, STORAGE_DIR } from "../utils/index.js";
|
|
9
|
+
import { loadConfig } from "./load-config.js";
|
|
8
10
|
export const lintCommand = new Command('lint')
|
|
9
11
|
.description('Lint the documentation')
|
|
10
12
|
.argument('[root]', 'Root directory of the documentation')
|
|
11
13
|
.option('-g, --glob <path...>', 'Glob patterns of source dirs/files to lint', '**/*.{js,jsx,ts,tsx,md,mdx}')
|
|
12
14
|
.option('--no-cspell', 'Disable cspell linting')
|
|
15
|
+
.option('--debug', 'Show debug logs', false)
|
|
13
16
|
.action(async function (root) {
|
|
14
|
-
const { cspell, glob,
|
|
17
|
+
const { cspell, glob,
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
|
+
debug, ...globalOptions } = this.optsWithGlobals();
|
|
20
|
+
await fs.mkdir(STORAGE_DIR, { recursive: true });
|
|
21
|
+
await fs.writeFile(OPTIONS_FILE, JSON.stringify({ root, globalOptions }, null, 2));
|
|
15
22
|
const { config } = await loadConfig(root, globalOptions);
|
|
16
23
|
const docsDir = config.root;
|
|
17
24
|
const eslint = new ESLint({
|
package/lib/cli/load-config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UserConfig } from '@rspress/core';
|
|
2
|
-
import type { GlobalCliOptions } from '../types.
|
|
3
|
-
export declare function loadConfig(root?: string | URL, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, include, exclude, outDir, redirect, editRepo, algolia, siteUrl, }?: GlobalCliOptions): Promise<{
|
|
2
|
+
import type { GlobalCliOptions } from '../types.ts';
|
|
3
|
+
export declare function loadConfig(root?: string | URL, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, include, exclude, outDir, redirect, editRepo, algolia, siteUrl, lang, }?: GlobalCliOptions): Promise<{
|
|
4
4
|
config: UserConfig;
|
|
5
5
|
configFilePath: string;
|
|
6
6
|
}>;
|
package/lib/cli/load-config.js
CHANGED
|
@@ -15,12 +15,12 @@ import { transformerMetaHighlight, transformerMetaWordHighlight, transformerNota
|
|
|
15
15
|
import { difference } from 'es-toolkit';
|
|
16
16
|
import { glob } from 'tinyglobby';
|
|
17
17
|
import { cyan } from 'yoctocolors';
|
|
18
|
-
import { attributesPlugin } from
|
|
19
|
-
import { apiPlugin, autoSidebarPlugin, autoTocPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, } from
|
|
20
|
-
import { isExplicitlyUnversioned, normalizeSlash, UNVERSIONED, } from
|
|
21
|
-
import { pathExists, pkgResolve, resolveStaticConfig } from
|
|
22
|
-
import { DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from
|
|
23
|
-
import { defaultGitHubUrl, isDoc } from
|
|
18
|
+
import { attributesPlugin } from "../plugins/attributes/index.js";
|
|
19
|
+
import { apiPlugin, autoSidebarPlugin, autoTocPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, } from "../plugins/index.js";
|
|
20
|
+
import { isExplicitlyUnversioned, normalizeSlash, UNVERSIONED, } from "../shared/index.js";
|
|
21
|
+
import { pathExists, pkgResolve, resolveStaticConfig } from "../utils/index.js";
|
|
22
|
+
import { DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from "./constants.js";
|
|
23
|
+
import { defaultGitHubUrl, isDoc } from "./helpers.js";
|
|
24
24
|
const DEFAULT_LOGO = '/logo.svg';
|
|
25
25
|
const KNOWN_LOCALE_CONFIGS = {
|
|
26
26
|
en: {
|
|
@@ -64,7 +64,10 @@ const ALAUDA_RU_ALGOLIA_OPTIONS = {
|
|
|
64
64
|
apiKey: '786fa6da36fe76777d688387c0520c5b',
|
|
65
65
|
indexName: 'docs_alauda_io_gbnijigq50_pages',
|
|
66
66
|
};
|
|
67
|
-
const getCommonConfig = async ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, include, exclude, redirect, editRepo, algolia, siteUrl, }) => {
|
|
67
|
+
const getCommonConfig = async ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, include, exclude, redirect, editRepo, algolia, siteUrl, lang, }) => {
|
|
68
|
+
if (lang != null) {
|
|
69
|
+
config.lang = lang;
|
|
70
|
+
}
|
|
68
71
|
const fallbackToZh = 'lang' in config && !config.lang;
|
|
69
72
|
root = resolveDocRoot(root, config.root);
|
|
70
73
|
const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
|
|
@@ -272,7 +275,7 @@ const findConfig = async (basePath) => {
|
|
|
272
275
|
}
|
|
273
276
|
}
|
|
274
277
|
};
|
|
275
|
-
export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, include, exclude, outDir, redirect, editRepo, algolia, siteUrl, } = {}) {
|
|
278
|
+
export async function loadConfig(root, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, include, exclude, outDir, redirect, editRepo, algolia, siteUrl, lang, } = {}) {
|
|
276
279
|
let configFilePath;
|
|
277
280
|
if (configFile) {
|
|
278
281
|
configFilePath = path.resolve(configFile);
|
|
@@ -344,6 +347,7 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
|
|
|
344
347
|
editRepo,
|
|
345
348
|
algolia,
|
|
346
349
|
siteUrl,
|
|
350
|
+
lang,
|
|
347
351
|
});
|
|
348
352
|
base = commonConfig.base;
|
|
349
353
|
const mergedConfig = mergeRsbuildConfig(commonConfig, config, {
|
|
@@ -17,12 +17,12 @@ const getNavMenu = () => {
|
|
|
17
17
|
}
|
|
18
18
|
return document.querySelector('.rspress-nav-menu');
|
|
19
19
|
};
|
|
20
|
-
const LEGACY_VERSIONS = ['
|
|
20
|
+
const LEGACY_VERSIONS = ['3.18.1', '3.18.0', '3.16', '3.14'];
|
|
21
21
|
const LEGACY_NAV_ITEMS = LEGACY_VERSIONS.map((v) => ({
|
|
22
22
|
text: v,
|
|
23
|
-
link: `https://
|
|
23
|
+
link: `https://cloud.alauda.cn/v3/document/navigation?version=v${v}&language=true`,
|
|
24
24
|
}));
|
|
25
|
-
const ALLOWED_LEGACY_DOMAINS = new Set(['docs.alauda.cn'
|
|
25
|
+
const ALLOWED_LEGACY_DOMAINS = new Set(['docs.alauda.cn']);
|
|
26
26
|
if (!isProduction()) {
|
|
27
27
|
ALLOWED_LEGACY_DOMAINS.add('localhost');
|
|
28
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RspressPlugin } from '@rspress/core';
|
|
2
|
-
import type { ApiPluginOptions } from './types.
|
|
3
|
-
export type * from './types.
|
|
2
|
+
import type { ApiPluginOptions } from './types.ts';
|
|
3
|
+
export type * from './types.ts';
|
|
4
4
|
export declare const apiPlugin: ({ localBasePath, }: ApiPluginOptions) => RspressPlugin;
|
package/lib/plugins/api/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { openapiSchemaToJsonSchema } from '@openapi-contrib/openapi-schema-to-json-schema';
|
|
2
2
|
import { convertObj } from 'swagger2openapi';
|
|
3
|
-
import { generateRuntimeModule } from
|
|
3
|
+
import { generateRuntimeModule } from "../../utils/index.js";
|
|
4
4
|
export const apiPlugin = ({ localBasePath, }) => {
|
|
5
5
|
return {
|
|
6
6
|
name: 'doom-api',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Root } from 'mdast';
|
|
2
2
|
import type { Extension as FromMarkdownExtension } from 'mdast-util-from-markdown';
|
|
3
3
|
import type { Plugin } from 'unified';
|
|
4
|
-
import type { AttributesExtension } from './types.
|
|
4
|
+
import type { AttributesExtension } from './types.ts';
|
|
5
5
|
export interface AttributesData {
|
|
6
6
|
micromarkExtensions?: AttributesExtension[];
|
|
7
7
|
fromMarkdownExtensions?: FromMarkdownExtension[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { attributesTransformer } from
|
|
2
|
-
import { mdastAttributes } from
|
|
3
|
-
import { micromarkAttributes } from
|
|
1
|
+
import { attributesTransformer } from "./attributes-transformer.js";
|
|
2
|
+
import { mdastAttributes } from "./mdast-attributes.js";
|
|
3
|
+
import { micromarkAttributes } from "./micromark-attributes.js";
|
|
4
4
|
export const remarkAttributes = function () {
|
|
5
5
|
const data = this.data();
|
|
6
6
|
function add(key, value) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RspressPlugin, type UserConfig } from '@rspress/core';
|
|
2
|
-
export type * from './walk.
|
|
3
|
-
export type * from './type.
|
|
2
|
+
export type * from './walk.ts';
|
|
3
|
+
export type * from './type.ts';
|
|
4
4
|
export interface AutoSidebarPluginOptions {
|
|
5
5
|
ignore?: boolean;
|
|
6
6
|
export?: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import {} from '@rspress/core';
|
|
3
3
|
import { addTrailingSlash } from '@rspress/shared';
|
|
4
|
-
import { APIS_ROUTES } from
|
|
5
|
-
import { combineWalkResult } from
|
|
6
|
-
import { walk } from
|
|
4
|
+
import { APIS_ROUTES } from "../../shared/index.js";
|
|
5
|
+
import { combineWalkResult } from "./utils.js";
|
|
6
|
+
import { walk } from "./walk.js";
|
|
7
7
|
// Scan all the directories and files in the work directory(such as `docs`), and then generate the nav and sidebar configuration according to the directory structure.
|
|
8
8
|
// We will do as follows:
|
|
9
9
|
// 1. scan the directory structure, and extract all the `_meta.json` files.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NavItem } from '@rspress/shared';
|
|
2
|
-
import type { DoomSidebar } from './walk.
|
|
2
|
+
import type { DoomSidebar } from './walk.ts';
|
|
3
3
|
export declare function detectFilePath(rawPath: string, extensions: string[]): Promise<string | undefined>;
|
|
4
4
|
export declare function extractInfoFromFrontmatter(filePath: string, rootDir: string, extensions: string[]): Promise<{
|
|
5
5
|
realPath: string | undefined;
|
|
@@ -2,8 +2,8 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { logger } from '@rspress/core';
|
|
4
4
|
import { loadFrontMatter } from '@rspress/shared/node-utils';
|
|
5
|
-
import { extractTextAndId } from
|
|
6
|
-
import { pathExists } from
|
|
5
|
+
import { extractTextAndId } from "../../shared/index.js";
|
|
6
|
+
import { pathExists } from "../../utils/index.js";
|
|
7
7
|
export async function detectFilePath(rawPath, extensions) {
|
|
8
8
|
// The params doesn't have extension name, so we need to try to find the file with the extension name.
|
|
9
9
|
let realPath = rawPath;
|
|
@@ -4,8 +4,8 @@ import { logger, removeTrailingSlash, withBase, } from '@rspress/core';
|
|
|
4
4
|
import { isExternalUrl, removeLeadingSlash, slash, } from '@rspress/shared';
|
|
5
5
|
import { unset } from 'es-toolkit/compat';
|
|
6
6
|
import picomatch from 'picomatch';
|
|
7
|
-
import { pathExists, readJson } from
|
|
8
|
-
import { detectFilePath, extractInfoFromFrontmatter } from
|
|
7
|
+
import { pathExists, readJson } from "../../utils/index.js";
|
|
8
|
+
import { detectFilePath, extractInfoFromFrontmatter } from "./utils.js";
|
|
9
9
|
const sidebarSorter = (a, b) => {
|
|
10
10
|
const aWeight = 'weight' in a && a.weight != null ? a.weight : 100;
|
|
11
11
|
const bWeight = 'weight' in b && b.weight != null ? b.weight : 100;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RspressPlugin } from '@rspress/core';
|
|
2
|
-
import { type DoomSite } from '../../shared/index.
|
|
3
|
-
import type { ExportItem } from '../../types.
|
|
2
|
+
import { type DoomSite } from '../../shared/index.ts';
|
|
3
|
+
import type { ExportItem } from '../../types.ts';
|
|
4
4
|
export interface GlobalPluginOptions {
|
|
5
5
|
version?: string;
|
|
6
6
|
download?: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { addTrailingSlash } from '@rspress/shared';
|
|
4
|
-
import { ACP_BASE } from
|
|
5
|
-
import { baseResolve, pkgResolve } from
|
|
4
|
+
import { ACP_BASE } from "../../shared/index.js";
|
|
5
|
+
import { baseResolve, pkgResolve } from "../../utils/index.js";
|
|
6
6
|
const globalComponentsDir = baseResolve('global');
|
|
7
7
|
const componentsDir = baseResolve('runtime/components');
|
|
8
8
|
export const globalPlugin = ({ version, download, }) => {
|
package/lib/plugins/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './api/index.
|
|
2
|
-
export * from './auto-sidebar/index.
|
|
3
|
-
export * from './auto-toc/index.
|
|
4
|
-
export * from './directives/index.
|
|
5
|
-
export * from './global/index.
|
|
6
|
-
export * from './mermaid/index.
|
|
7
|
-
export * from './permission/index.
|
|
8
|
-
export * from './replace/index.
|
|
9
|
-
export * from './shiki/index.
|
|
1
|
+
export * from './api/index.ts';
|
|
2
|
+
export * from './auto-sidebar/index.ts';
|
|
3
|
+
export * from './auto-toc/index.ts';
|
|
4
|
+
export * from './directives/index.ts';
|
|
5
|
+
export * from './global/index.ts';
|
|
6
|
+
export * from './mermaid/index.ts';
|
|
7
|
+
export * from './permission/index.ts';
|
|
8
|
+
export * from './replace/index.ts';
|
|
9
|
+
export * from './shiki/index.ts';
|
package/lib/plugins/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
1
|
+
export * from "./api/index.js";
|
|
2
|
+
export * from "./auto-sidebar/index.js";
|
|
3
|
+
export * from "./auto-toc/index.js";
|
|
4
|
+
export * from "./directives/index.js";
|
|
5
|
+
export * from "./global/index.js";
|
|
6
|
+
export * from "./mermaid/index.js";
|
|
7
|
+
export * from "./permission/index.js";
|
|
8
|
+
export * from "./replace/index.js";
|
|
9
|
+
export * from "./shiki/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RspressPlugin } from '@rspress/core';
|
|
2
|
-
import type { PermissionPluginOptions } from './types.
|
|
3
|
-
export type * from './types.
|
|
2
|
+
import type { PermissionPluginOptions } from './types.ts';
|
|
3
|
+
export type * from './types.ts';
|
|
4
4
|
export declare const permissionPlugin: ({ localBasePath, }: PermissionPluginOptions) => RspressPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RspressPlugin } from '@rspress/core';
|
|
2
|
-
export * from './normalize-img-src.
|
|
3
|
-
export type * from './types.
|
|
4
|
-
export * from './utils.
|
|
2
|
+
export * from './normalize-img-src.ts';
|
|
3
|
+
export type * from './types.ts';
|
|
4
|
+
export * from './utils.ts';
|
|
5
5
|
declare module 'unified' {
|
|
6
6
|
interface Data {
|
|
7
7
|
pageMeta: Record<string, unknown>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import { logger } from '@rspress/core';
|
|
3
|
-
import { rehypeNormalizeLink } from
|
|
4
|
-
import { remarkExplicitJsx } from
|
|
5
|
-
import { MD_RELEASE_COMMENT_PATTERN, MDX_RELEASE_COMMENT_PATTERN, remarkReplace, } from
|
|
6
|
-
import { mdProcessor, mdxProcessor, normalizeReferenceItems } from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
3
|
+
import { rehypeNormalizeLink } from "./rehype-normalize-link.js";
|
|
4
|
+
import { remarkExplicitJsx } from "./remark-explicit-jsx.js";
|
|
5
|
+
import { MD_RELEASE_COMMENT_PATTERN, MDX_RELEASE_COMMENT_PATTERN, remarkReplace, } from "./remark-replace.js";
|
|
6
|
+
import { mdProcessor, mdxProcessor, normalizeReferenceItems } from "./utils.js";
|
|
7
|
+
export * from "./normalize-img-src.js";
|
|
8
|
+
export * from "./utils.js";
|
|
9
9
|
export const replacePlugin = ({ lang, localBasePath, force, }) => {
|
|
10
10
|
let userConfig;
|
|
11
11
|
let normalizedItems;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RootContent } from 'mdast';
|
|
2
|
-
import type { NormalizedReferenceSource } from './types.
|
|
2
|
+
import type { NormalizedReferenceSource } from './types.ts';
|
|
3
3
|
export interface NormalizeImgSrcOptions {
|
|
4
4
|
refSource?: NormalizedReferenceSource;
|
|
5
5
|
localPublicBase: string;
|
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { isExternalUrl, removeLeadingSlash } from '@rspress/shared';
|
|
4
4
|
import { cloneDeep } from 'es-toolkit';
|
|
5
5
|
import { visit } from 'unist-util-visit';
|
|
6
|
-
import { RELATIVE_URL_PATTERN } from
|
|
6
|
+
import { RELATIVE_URL_PATTERN } from "./utils.js";
|
|
7
7
|
export const normalizeImgSrc = (content, { refSource, localPublicBase, publicBase, sourceBase, targetBase, force, translating, }) => {
|
|
8
8
|
content = cloneDeep(content);
|
|
9
9
|
const resolveImgSrc = (src, force) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Slugger from 'github-slugger';
|
|
2
2
|
import { visitChildren } from 'unist-util-visit-children';
|
|
3
|
-
import { extractTextAndId } from
|
|
3
|
+
import { extractTextAndId } from "../../shared/index.js";
|
|
4
4
|
export const parseToc = (tree, allDepths) => {
|
|
5
5
|
let title = '';
|
|
6
6
|
const toc = [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isExternalUrl } from '@rspress/shared';
|
|
2
2
|
import { visit } from 'unist-util-visit';
|
|
3
|
-
import { getASTNodeImport } from
|
|
3
|
+
import { getASTNodeImport } from "../shared.js";
|
|
4
4
|
const getMdxSrcAttribute = (tempVar) => {
|
|
5
5
|
return {
|
|
6
6
|
type: 'mdxJsxAttribute',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Root } from 'mdast';
|
|
2
2
|
import type { Plugin } from 'unified';
|
|
3
|
-
import type { NormalizedReferenceSource, ReleaseNotesOptions } from './types.
|
|
3
|
+
import type { NormalizedReferenceSource, ReleaseNotesOptions } from './types.ts';
|
|
4
4
|
export declare const MD_RELEASE_COMMENT_PATTERN: RegExp;
|
|
5
5
|
export declare const MDX_RELEASE_COMMENT_PATTERN: RegExp;
|
|
6
6
|
export declare const maybeHaveRef: (filepath: string, content: string) => boolean | undefined;
|
|
@@ -5,10 +5,10 @@ import { logger } from '@rspress/core';
|
|
|
5
5
|
import { isProduction } from '@rspress/shared';
|
|
6
6
|
import { parse, stringify } from 'yaml';
|
|
7
7
|
import { cyan, red } from 'yoctocolors';
|
|
8
|
-
import { normalizeImgSrc } from
|
|
9
|
-
import { resolveReference } from
|
|
10
|
-
import { resolveRelease } from
|
|
11
|
-
import { getFrontmatterNode, isCI, mdProcessor, mdxProcessor } from
|
|
8
|
+
import { normalizeImgSrc } from "./normalize-img-src.js";
|
|
9
|
+
import { resolveReference } from "./resolve-reference.js";
|
|
10
|
+
import { resolveRelease } from "./resolve-release.js";
|
|
11
|
+
import { getFrontmatterNode, isCI, mdProcessor, mdxProcessor } from "./utils.js";
|
|
12
12
|
const MD_REF_START_COMMENT_PATTERN = /<!-{2,} *reference-start#(.+) *-{2,}>/;
|
|
13
13
|
const MDX_REF_START_COMMENT_PATTERN = /\{\/\*+ *reference-start#(.+) *\*+\/\}/;
|
|
14
14
|
const MDX_REF_START_PATTERN = /\/\*+ *reference-start#(.+) *\*+\//;
|
|
@@ -4,9 +4,9 @@ import { logger } from '@rspress/core';
|
|
|
4
4
|
import { isProduction } from '@rspress/shared';
|
|
5
5
|
import { render } from 'ejs';
|
|
6
6
|
import { red } from 'yoctocolors';
|
|
7
|
-
import { resolveRepo } from
|
|
8
|
-
import { parseToc } from
|
|
9
|
-
import { getFrontmatterNode, mdProcessor, mdxProcessor } from
|
|
7
|
+
import { resolveRepo } from "../../utils/index.js";
|
|
8
|
+
import { parseToc } from "./parse-toc.js";
|
|
9
|
+
import { getFrontmatterNode, mdProcessor, mdxProcessor } from "./utils.js";
|
|
10
10
|
const refCache = new Map();
|
|
11
11
|
const resolveReference_ = async (localBasePath, localPublicBase, items, refName, force) => {
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './transformers/index.
|
|
1
|
+
export * from './transformers/index.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./transformers/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './callouts.
|
|
1
|
+
export * from './callouts.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./callouts.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { PluginDriver, RouteService, remarkLink, } from '@rspress/core';
|
|
4
|
+
import { isProduction } from '@rspress/shared';
|
|
5
|
+
import { lintRule } from 'unified-lint-rule';
|
|
6
|
+
import { loadConfig } from "../cli/load-config.js";
|
|
7
|
+
import { OPTIONS_FILE } from "../utils/index.js";
|
|
8
|
+
let config;
|
|
9
|
+
let configFilePath;
|
|
10
|
+
export const checkDeadLinks = lintRule('doom-lint:check-dead-links', async (tree, vfile) => {
|
|
11
|
+
if (!config || !configFilePath) {
|
|
12
|
+
let optionsText;
|
|
13
|
+
try {
|
|
14
|
+
optionsText = await fs.readFile(OPTIONS_FILE, 'utf8');
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
//
|
|
18
|
+
}
|
|
19
|
+
const { root, globalOptions } = (optionsText ? JSON.parse(optionsText) : {});
|
|
20
|
+
({ config, configFilePath } = await loadConfig(root, globalOptions));
|
|
21
|
+
}
|
|
22
|
+
const relativePath = path.relative(config.root, vfile.path);
|
|
23
|
+
// Ignore files outside the root directory
|
|
24
|
+
if (relativePath.startsWith('..')) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let routeService = RouteService.getInstance();
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
29
|
+
if (!routeService) {
|
|
30
|
+
const pluginDriver = await PluginDriver.create(config, configFilePath, isProduction());
|
|
31
|
+
routeService = await RouteService.create({
|
|
32
|
+
config,
|
|
33
|
+
scanDir: config.root,
|
|
34
|
+
externalPages: await pluginDriver.addPages(),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
remarkLink({
|
|
38
|
+
cleanUrls: false,
|
|
39
|
+
routeService,
|
|
40
|
+
remarkLinkOptions: config.markdown?.link,
|
|
41
|
+
lint: true,
|
|
42
|
+
})(tree, vfile);
|
|
43
|
+
});
|
package/lib/remark-lint/index.js
CHANGED
package/lib/remarkrc.js
CHANGED
|
@@ -10,7 +10,7 @@ import remarkLintLintMatchPunctuation from 'remark-lint-match-punctuation';
|
|
|
10
10
|
import remarkLintNoChinesePunctuationInNumber from 'remark-lint-no-chinese-punctuation-in-number';
|
|
11
11
|
import remarkLintNoDuplicateHeadingsInSection from 'remark-lint-no-duplicate-headings-in-section';
|
|
12
12
|
import remarkLintNoHiddenTableCell from 'remark-lint-no-hidden-table-cell';
|
|
13
|
-
import doomLint, { noDeepHeading, noDeepList, noParagraphIndent, tableSize, unitCase, } from "./remark-lint/index.js";
|
|
13
|
+
import doomLint, { checkDeadLinks, noDeepHeading, noDeepList, noParagraphIndent, tableSize, unitCase, } from "./remark-lint/index.js";
|
|
14
14
|
export default {
|
|
15
15
|
plugins: [
|
|
16
16
|
remarkDirective,
|
|
@@ -23,6 +23,7 @@ export default {
|
|
|
23
23
|
remarkLintNoDuplicateHeadingsInSection,
|
|
24
24
|
remarkLintNoHiddenTableCell,
|
|
25
25
|
doomLint,
|
|
26
|
+
checkDeadLinks,
|
|
26
27
|
noDeepHeading,
|
|
27
28
|
noDeepList,
|
|
28
29
|
noParagraphIndent,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './AcpApisOverview.js';
|
|
2
2
|
export * from './Badge.js';
|
|
3
3
|
export * from './Callouts.js';
|
|
4
|
-
export * from './Card.js';
|
|
5
4
|
export * from './Directive.js';
|
|
6
5
|
export * from './ExternalApisOverview.js';
|
|
7
6
|
export * from './ExternalSite.js';
|
|
@@ -9,7 +8,6 @@ export * from './ExternalSiteLink.js';
|
|
|
9
8
|
export * from './JsonViewer.js';
|
|
10
9
|
export * from './K8sCrd.js';
|
|
11
10
|
export * from './K8sPermissionTable.js';
|
|
12
|
-
export * from './LinkCard.js';
|
|
13
11
|
export * from './Markdown.js';
|
|
14
12
|
export * from './Mermaid.js';
|
|
15
13
|
export * from './OpenAPIPath.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './AcpApisOverview.js';
|
|
2
2
|
export * from './Badge.js';
|
|
3
3
|
export * from './Callouts.js';
|
|
4
|
-
export * from './Card.js';
|
|
5
4
|
export * from './Directive.js';
|
|
6
5
|
export * from './ExternalApisOverview.js';
|
|
7
6
|
export * from './ExternalSite.js';
|
|
@@ -9,7 +8,6 @@ export * from './ExternalSiteLink.js';
|
|
|
9
8
|
export * from './JsonViewer.js';
|
|
10
9
|
export * from './K8sCrd.js';
|
|
11
10
|
export * from './K8sPermissionTable.js';
|
|
12
|
-
export * from './LinkCard.js';
|
|
13
11
|
export * from './Markdown.js';
|
|
14
12
|
export * from './Mermaid.js';
|
|
15
13
|
export * from './OpenAPIPath.js';
|
package/lib/shared/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './constants.
|
|
2
|
-
export * from './helpers.
|
|
3
|
-
export * from './types.
|
|
1
|
+
export * from './constants.ts';
|
|
2
|
+
export * from './helpers.ts';
|
|
3
|
+
export * from './types.ts';
|
package/lib/shared/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./constants.js";
|
|
2
|
+
export * from "./helpers.js";
|
|
3
|
+
export * from "./types.js";
|
package/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Options } from '@cspell/eslint-plugin';
|
|
2
2
|
import type { serve } from '@rspress/core';
|
|
3
|
-
import type { ApiPluginOptions, AutoSidebarPluginOptions, PermissionPluginOptions, ReferenceItem, ReleaseNotesOptions } from './plugins/index.
|
|
4
|
-
import type { DoomSite } from './shared/index.
|
|
3
|
+
import type { ApiPluginOptions, AutoSidebarPluginOptions, PermissionPluginOptions, ReferenceItem, ReleaseNotesOptions } from './plugins/index.ts';
|
|
4
|
+
import type { DoomSite } from './shared/index.ts';
|
|
5
5
|
export type BaseServeOptions = Parameters<typeof serve>[0];
|
|
6
6
|
export type ServeOptions = Omit<BaseServeOptions, 'config'>;
|
|
7
7
|
export interface GlobalCliOptions {
|
|
@@ -22,6 +22,7 @@ export interface GlobalCliOptions {
|
|
|
22
22
|
editRepo?: boolean | string;
|
|
23
23
|
algolia?: boolean | 'alauda';
|
|
24
24
|
siteUrl?: boolean;
|
|
25
|
+
lang?: string;
|
|
25
26
|
}
|
|
26
27
|
export interface TranslateOptions {
|
|
27
28
|
systemPrompt?: string;
|
package/lib/utils/constants.d.ts
CHANGED
package/lib/utils/constants.js
CHANGED
|
@@ -2,3 +2,5 @@ import path from 'node:path';
|
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
export const BASE_DIR = path.resolve(fileURLToPath(import.meta.url), '../..');
|
|
4
4
|
export const PKG_DIR = path.resolve(BASE_DIR, '..');
|
|
5
|
+
export const STORAGE_DIR = path.resolve('node_modules/.doom');
|
|
6
|
+
export const OPTIONS_FILE = path.resolve(STORAGE_DIR, 'options.json');
|
package/lib/utils/helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StringMapper } from '../shared/types.
|
|
1
|
+
import type { StringMapper } from '../shared/types.ts';
|
|
2
2
|
export declare const baseResolve: (...paths: string[]) => string;
|
|
3
3
|
export declare const pkgResolve: (...paths: string[]) => string;
|
|
4
4
|
export declare const resolveStaticConfig: <T = unknown>(filepath: string) => Promise<T>;
|
package/lib/utils/helpers.js
CHANGED
|
@@ -2,8 +2,8 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { glob } from 'tinyglobby';
|
|
4
4
|
import { parse } from 'yaml';
|
|
5
|
-
import { JSON_EXTENSION, YAML_EXTENSIONS } from
|
|
6
|
-
import { BASE_DIR, PKG_DIR } from
|
|
5
|
+
import { JSON_EXTENSION, YAML_EXTENSIONS } from "../cli/constants.js";
|
|
6
|
+
import { BASE_DIR, PKG_DIR } from "./constants.js";
|
|
7
7
|
export const baseResolve = (...paths) => path.resolve(BASE_DIR, ...paths);
|
|
8
8
|
export const pkgResolve = (...paths) => path.resolve(PKG_DIR, ...paths);
|
|
9
9
|
export const resolveStaticConfig = async (filepath) => {
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './constants.
|
|
2
|
-
export * from './fs.
|
|
3
|
-
export * from './git.
|
|
4
|
-
export * from './helpers.
|
|
1
|
+
export * from './constants.ts';
|
|
2
|
+
export * from './fs.ts';
|
|
3
|
+
export * from './git.ts';
|
|
4
|
+
export * from './helpers.ts';
|
package/lib/utils/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./constants.js";
|
|
2
|
+
export * from "./fs.js";
|
|
3
|
+
export * from "./git.js";
|
|
4
|
+
export * from "./helpers.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -40,22 +40,22 @@
|
|
|
40
40
|
"rspress-plugins"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@alauda/doom-export": "^0.1.
|
|
43
|
+
"@alauda/doom-export": "^0.1.1",
|
|
44
44
|
"@cspell/eslint-plugin": "^8.19.4 || ^9.2.1",
|
|
45
45
|
"@eslint-react/eslint-plugin": "^1.53.1",
|
|
46
46
|
"@inquirer/prompts": "^7.8.6",
|
|
47
47
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
48
|
-
"@playwright/browser-chromium": "^1.55.
|
|
49
|
-
"@rsbuild/plugin-react": "^1.4.
|
|
48
|
+
"@playwright/browser-chromium": "^1.55.1",
|
|
49
|
+
"@rsbuild/plugin-react": "^1.4.1",
|
|
50
50
|
"@rsbuild/plugin-sass": "^1.4.0",
|
|
51
51
|
"@rsbuild/plugin-svgr": "^1.2.2",
|
|
52
52
|
"@rsbuild/plugin-yaml": "^1.0.3",
|
|
53
|
-
"@rspress/core": "2.0.0-beta.
|
|
54
|
-
"@rspress/plugin-algolia": "2.0.0-beta.
|
|
55
|
-
"@rspress/plugin-llms": "2.0.0-beta.
|
|
56
|
-
"@rspress/plugin-sitemap": "2.0.0-beta.
|
|
57
|
-
"@rspress/shared": "2.0.0-beta.
|
|
58
|
-
"@shikijs/transformers": "^3.
|
|
53
|
+
"@rspress/core": "2.0.0-beta.34",
|
|
54
|
+
"@rspress/plugin-algolia": "2.0.0-beta.34",
|
|
55
|
+
"@rspress/plugin-llms": "2.0.0-beta.34",
|
|
56
|
+
"@rspress/plugin-sitemap": "2.0.0-beta.34",
|
|
57
|
+
"@rspress/shared": "2.0.0-beta.34",
|
|
58
|
+
"@shikijs/transformers": "^3.13.0",
|
|
59
59
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
60
60
|
"ab64": "^0.1.6",
|
|
61
61
|
"chokidar": "^4.0.3",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"commander": "^13.1.0 || ^14.0.1",
|
|
64
64
|
"ejs": "^3.1.10",
|
|
65
65
|
"es-toolkit": "^1.39.10",
|
|
66
|
-
"eslint": "^9.
|
|
66
|
+
"eslint": "^9.36.0",
|
|
67
67
|
"eslint-plugin-mdx": "^3.6.2",
|
|
68
68
|
"globals": "^16.4.0",
|
|
69
69
|
"html-tag-names": "^2.1.0",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"mdast-util-phrasing": "^4.1.0",
|
|
75
75
|
"mdast-util-to-markdown": "^2.1.2",
|
|
76
76
|
"mdast-util-to-string": "^4.0.0",
|
|
77
|
-
"mermaid": "^11.
|
|
78
|
-
"openai": "^5.
|
|
77
|
+
"mermaid": "^11.12.0",
|
|
78
|
+
"openai": "^5.23.1",
|
|
79
79
|
"openapi-types": "^12.1.3",
|
|
80
80
|
"p-ratelimit": "^1.0.1",
|
|
81
81
|
"picomatch": "^4.0.3",
|
|
@@ -96,14 +96,14 @@
|
|
|
96
96
|
"remark-mdx": "^3.1.1",
|
|
97
97
|
"remark-message-control": "^8.0.0",
|
|
98
98
|
"remark-stringify": "^11.0.0",
|
|
99
|
-
"shiki": "^3.
|
|
99
|
+
"shiki": "^3.13.0",
|
|
100
100
|
"simple-git": "^3.28.0",
|
|
101
101
|
"string-width": "^7.2.0",
|
|
102
102
|
"swagger2openapi": "^7.0.8",
|
|
103
103
|
"tinyglobby": "^0.2.15",
|
|
104
104
|
"type-fest": "^4.41.0 || ^5.0.0",
|
|
105
105
|
"typescript": "^5.9.2",
|
|
106
|
-
"typescript-eslint": "^8.44.
|
|
106
|
+
"typescript-eslint": "^8.44.1",
|
|
107
107
|
"unified": "^11.0.5",
|
|
108
108
|
"unified-lint-rule": "^3.0.1",
|
|
109
109
|
"unist-util-position": "^5.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Card, Card as default } from '@rspress/core/theme';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Card, Card as default } from '@rspress/core/theme';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { LinkCard, LinkCard as default } from '@rspress/core/theme';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { LinkCard, LinkCard as default } from '@rspress/core/theme';
|