@alauda/doom 1.20.0 → 1.20.2
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/export.js
CHANGED
|
@@ -4,6 +4,7 @@ import { generatePdf, } from '@alauda/doom-export';
|
|
|
4
4
|
import { logger, serve } from '@rspress/core';
|
|
5
5
|
import { removeLeadingSlash } from '@rspress/shared';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
|
+
import { groupBy } from 'es-toolkit';
|
|
7
8
|
import { cyan, yellow } from 'yoctocolors';
|
|
8
9
|
import { autoSidebar, } from '../plugins/index.js';
|
|
9
10
|
import { getPdfName } from '../shared/index.js';
|
|
@@ -92,13 +93,18 @@ export const exportCommand = new Command('export')
|
|
|
92
93
|
outlineExcludeSelector: '.rp-toc-exclude *',
|
|
93
94
|
},
|
|
94
95
|
};
|
|
95
|
-
const exportPdf = async (sidebarItems, lang = config.lang, options) => {
|
|
96
|
-
|
|
96
|
+
const exportPdf = async (sidebarItems, lang = config.lang, { includeApisPages, overrideOutlines, ...options } = {}) => {
|
|
97
|
+
let pages = collectPages(sidebarItems, config.base);
|
|
98
|
+
if (!includeApisPages) {
|
|
99
|
+
pages = pages.filter((page) => themeConfig.locales?.length
|
|
100
|
+
? !themeConfig.locales.some((l) => page.key.startsWith(l.lang === config.lang ? 'apis/' : `${l.lang}/apis/`))
|
|
101
|
+
: !page.key.startsWith('apis/'));
|
|
102
|
+
}
|
|
97
103
|
const pdfOptions = {
|
|
98
104
|
pages,
|
|
99
105
|
outFile: getPdfName(lang, config.userBase, config.title),
|
|
100
106
|
cleanupTempDir: false,
|
|
101
|
-
customOutlines:
|
|
107
|
+
customOutlines: overrideOutlines
|
|
102
108
|
? (pages) => {
|
|
103
109
|
const pageMap = new Map();
|
|
104
110
|
let pageIndex = 0;
|
|
@@ -135,7 +141,7 @@ export const exportCommand = new Command('export')
|
|
|
135
141
|
...commonOptions,
|
|
136
142
|
...options,
|
|
137
143
|
};
|
|
138
|
-
logger.start(`Exporting ${
|
|
144
|
+
logger.start(`Exporting ${lang} language documents with ${pages.length} pages into ${yellow(pdfOptions.outFile)}...`);
|
|
139
145
|
return generatePdf(pdfOptions);
|
|
140
146
|
};
|
|
141
147
|
const findScopeFactory = (scope) => function findScope(sidebarItems) {
|
|
@@ -157,8 +163,12 @@ export const exportCommand = new Command('export')
|
|
|
157
163
|
return found;
|
|
158
164
|
};
|
|
159
165
|
const exportItems = config.export || [];
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-default-assignment
|
|
167
|
+
const { apis = [], nonApis = [] } = groupBy(exportItems, (item) => item.scope.some((s) => s.startsWith('apis/') || s.startsWith('*/apis/'))
|
|
168
|
+
? 'apis'
|
|
169
|
+
: 'nonApis');
|
|
160
170
|
const exportEntries = async (sidebarItems, allOutlines, lang = config.lang) => {
|
|
161
|
-
for (const item of
|
|
171
|
+
for (const item of nonApis) {
|
|
162
172
|
const found = findScopeFactory(item.flattenScope)(sidebarItems);
|
|
163
173
|
if (!found?.size) {
|
|
164
174
|
logger.warn(`Cannot find matched scope \`${cyan(item.scope.join(', '))}\` for lang ${lang}, skip exporting`);
|
|
@@ -170,6 +180,18 @@ export const exportCommand = new Command('export')
|
|
|
170
180
|
outFile: `${item.name || (foundSidebarItems.find((it) => it.link?.endsWith('/index')) ?? foundSidebarItems[0]).text}-${lang}.pdf`,
|
|
171
181
|
});
|
|
172
182
|
}
|
|
183
|
+
for (const item of apis) {
|
|
184
|
+
const found = findScopeFactory(item.flattenScope)(sidebarItems);
|
|
185
|
+
if (!found?.size) {
|
|
186
|
+
logger.warn(`Cannot find matched scope \`${cyan(item.scope.join(', '))}\` for lang ${lang}, skip exporting`);
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const foundSidebarItems = [...found];
|
|
190
|
+
await exportPdf(foundSidebarItems, lang, {
|
|
191
|
+
includeApisPages: true,
|
|
192
|
+
outFile: `${item.name || (foundSidebarItems.find((it) => it.link?.endsWith('/index')) ?? foundSidebarItems[0]).text}-${lang}.pdf`,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
173
195
|
};
|
|
174
196
|
if (themeConfig.locales?.length) {
|
|
175
197
|
for (const { lang, sidebar } of themeConfig.locales) {
|
|
@@ -1,7 +1,6 @@
|
|
|
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 "../../shared/index.js";
|
|
5
4
|
import { combineWalkResult } from "./utils.js";
|
|
6
5
|
import { walk } from "./walk.js";
|
|
7
6
|
// 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.
|
|
@@ -163,11 +162,6 @@ export const autoSidebar = async (config, { ignore, export: export_ }) => {
|
|
|
163
162
|
if (export_ || excludeRoutes.length) {
|
|
164
163
|
const exclude = (route.exclude ??= []);
|
|
165
164
|
exclude.push(...excludeRoutes);
|
|
166
|
-
// only exclude apis routes for sidebar but not site data to avoid dead links
|
|
167
|
-
if (export_ &&
|
|
168
|
-
!onlyIncludeRoutes.some((route) => route.startsWith('apis/') || route.startsWith('*/apis/'))) {
|
|
169
|
-
excludeRoutes.push(...APIS_ROUTES);
|
|
170
|
-
}
|
|
171
165
|
}
|
|
172
166
|
config.themeConfig ??= {};
|
|
173
167
|
config.themeConfig.locales ??= config.locales || [];
|
|
@@ -94,7 +94,7 @@ const getRefsForPath = (openapi, path, knownRefs) => {
|
|
|
94
94
|
export const OpenAPIPath = ({ path, openapiPath: openapiPath_, pathPrefix: pathPrefix_, }) => {
|
|
95
95
|
const { page } = usePage();
|
|
96
96
|
const pathPrefix = pathPrefix_ ?? (virtual.pathPrefix || '');
|
|
97
|
-
const
|
|
97
|
+
const id = useId();
|
|
98
98
|
const slugger = useMemo(() => new BananaSlug(), []);
|
|
99
99
|
const [pathItem, openapi, openapiPath, refs] = useMemo(() => {
|
|
100
100
|
for (const [pathname, openapi] of Object.entries(openapisMap)) {
|
|
@@ -117,7 +117,7 @@ export const OpenAPIPath = ({ path, openapiPath: openapiPath_, pathPrefix: pathP
|
|
|
117
117
|
console.error(`No OpenAPI path definition found for ${path}`);
|
|
118
118
|
return null;
|
|
119
119
|
}
|
|
120
|
-
return (_jsxs(UidProvider, { value:
|
|
120
|
+
return (_jsxs(UidProvider, { value: id, children: [_jsxs(HeadingTitle, { slugger: slugger, level: 2, children: [pathPrefix, path] }), pathItem.parameters && (_jsxs(_Fragment, { children: [_jsx(HeadingTitle, { slugger: slugger, level: 3, children: "Common Parameters" }), _jsx(OpenAPIParameters, { parameters: pathItem.parameters, openapi: openapi })] })), Object.values(OpenAPIV3.HttpMethods).map((method) => {
|
|
121
121
|
if (!pathItem[method]) {
|
|
122
122
|
return null;
|
|
123
123
|
}
|
|
@@ -96,12 +96,12 @@ const getRefsForSchema = (openapi, schema, knownRefs) => {
|
|
|
96
96
|
export const OpenAPIRef = ({ schema, openapiPath: openapiPath_, isCommonRef = true, collectRefs = true, }) => {
|
|
97
97
|
const { page } = usePage();
|
|
98
98
|
let uid = useUid();
|
|
99
|
-
const
|
|
99
|
+
const innerId = useId();
|
|
100
100
|
if (isCommonRef) {
|
|
101
101
|
uid = ''; // common references do not need a unique ID
|
|
102
102
|
}
|
|
103
103
|
else if (!uid) {
|
|
104
|
-
uid =
|
|
104
|
+
uid = innerId;
|
|
105
105
|
}
|
|
106
106
|
// eslint-disable-next-line react-hooks/preserve-manual-memoization
|
|
107
107
|
const [schemaItem, openapi, openapiPath] = useMemo(() => {
|
|
@@ -52,7 +52,7 @@ const fetchSiteOverrides = async (version, acpSite) => {
|
|
|
52
52
|
}))
|
|
53
53
|
.catch(() => ({ terms: namedTerms }))
|
|
54
54
|
.then(({ terms, ...siteOverrides }) => {
|
|
55
|
-
|
|
55
|
+
normalizedSiteOverrides = normalizeOverrides(siteOverrides);
|
|
56
56
|
const normalizedTerms = normalizeOverrides(terms);
|
|
57
57
|
return {
|
|
58
58
|
en: { ...normalizedSiteOverrides.en, terms: normalizedTerms.en },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -41,28 +41,28 @@
|
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@alauda/doom-export": "^0.4.0",
|
|
44
|
-
"@cspell/eslint-plugin": "^9.
|
|
45
|
-
"@eslint-react/eslint-plugin": "^2.
|
|
46
|
-
"@inquirer/prompts": "^8.
|
|
44
|
+
"@cspell/eslint-plugin": "^9.7.0",
|
|
45
|
+
"@eslint-react/eslint-plugin": "^2.13.0",
|
|
46
|
+
"@inquirer/prompts": "^8.3.0",
|
|
47
47
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
48
48
|
"@rsbuild/plugin-react": "^1.4.5",
|
|
49
49
|
"@rsbuild/plugin-sass": "^1.5.0",
|
|
50
50
|
"@rsbuild/plugin-svgr": "^1.3.0",
|
|
51
51
|
"@rsbuild/plugin-yaml": "^1.0.4",
|
|
52
|
-
"@rspress/core": "2.0.
|
|
53
|
-
"@rspress/plugin-algolia": "2.0.
|
|
54
|
-
"@rspress/plugin-sitemap": "2.0.
|
|
55
|
-
"@rspress/shared": "2.0.
|
|
52
|
+
"@rspress/core": "2.0.3",
|
|
53
|
+
"@rspress/plugin-algolia": "2.0.3",
|
|
54
|
+
"@rspress/plugin-sitemap": "2.0.3",
|
|
55
|
+
"@rspress/shared": "2.0.3",
|
|
56
56
|
"@shikijs/transformers": "^3.22.0",
|
|
57
57
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
58
|
-
"@types/react": "^19.2.
|
|
58
|
+
"@types/react": "^19.2.14",
|
|
59
59
|
"ab64": "^0.1.6",
|
|
60
60
|
"chokidar": "^5.0.0",
|
|
61
61
|
"clsx": "^2.1.1",
|
|
62
62
|
"commander": "^14.0.3",
|
|
63
63
|
"ejs": "^4.0.1",
|
|
64
64
|
"es-toolkit": "^1.44.0",
|
|
65
|
-
"eslint": "^9.39.
|
|
65
|
+
"eslint": "^9.39.3",
|
|
66
66
|
"eslint-plugin-mdx": "^3.6.2",
|
|
67
67
|
"globals": "^17.3.0",
|
|
68
68
|
"html-tag-names": "^2.1.0",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"mdast-util-phrasing": "^4.1.0",
|
|
74
74
|
"mdast-util-to-markdown": "^2.1.2",
|
|
75
75
|
"mdast-util-to-string": "^4.0.0",
|
|
76
|
-
"mermaid": "^11.12.
|
|
77
|
-
"openai": "^6.
|
|
76
|
+
"mermaid": "^11.12.3",
|
|
77
|
+
"openai": "^6.24.0",
|
|
78
78
|
"openapi-types": "^12.1.3",
|
|
79
79
|
"p-ratelimit": "^1.0.1",
|
|
80
80
|
"picomatch": "^4.0.3",
|
|
@@ -96,13 +96,13 @@
|
|
|
96
96
|
"remark-message-control": "^8.0.0",
|
|
97
97
|
"remark-stringify": "^11.0.0",
|
|
98
98
|
"shiki": "^3.22.0",
|
|
99
|
-
"simple-git": "^3.
|
|
100
|
-
"string-width": "^8.
|
|
99
|
+
"simple-git": "^3.32.2",
|
|
100
|
+
"string-width": "^8.2.0",
|
|
101
101
|
"swagger2openapi": "^7.0.8",
|
|
102
102
|
"tinyglobby": "^0.2.15",
|
|
103
|
-
"type-fest": "^5.4.
|
|
103
|
+
"type-fest": "^5.4.4",
|
|
104
104
|
"typescript": "^5.9.3",
|
|
105
|
-
"typescript-eslint": "^8.
|
|
105
|
+
"typescript-eslint": "^8.56.1",
|
|
106
106
|
"unified": "^11.0.5",
|
|
107
107
|
"unified-lint-rule": "^3.0.1",
|
|
108
108
|
"unist-util-position": "^5.0.0",
|