@aigne/doc-smith 0.8.11-beta.4 → 0.8.11-beta.6
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/.aigne/doc-smith/config.yaml +2 -4
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +17 -2
- package/README.md +1 -1
- package/agents/clear/choose-contents.mjs +2 -2
- package/agents/clear/clear-document-structure.mjs +8 -8
- package/agents/clear/index.yaml +1 -1
- package/agents/evaluate/document-structure.yaml +1 -1
- package/agents/generate/check-d2-diagram-valid.mjs +26 -0
- package/agents/generate/check-document-structure.yaml +3 -3
- package/agents/generate/check-need-generate-structure.mjs +8 -8
- package/agents/generate/document-structure-tools/add-document.mjs +3 -3
- package/agents/generate/document-structure-tools/delete-document.mjs +2 -2
- package/agents/generate/document-structure-tools/move-document.mjs +3 -2
- package/agents/generate/document-structure-tools/update-document.mjs +2 -2
- package/agents/generate/generate-d2-diagram.yaml +23 -0
- package/agents/generate/generate-structure.yaml +1 -1
- package/agents/generate/merge-d2-diagram.yaml +39 -0
- package/agents/generate/update-document-structure.yaml +3 -3
- package/agents/generate/user-review-document-structure.mjs +10 -10
- package/agents/init/index.mjs +18 -10
- package/agents/publish/publish-docs.mjs +17 -20
- package/agents/update/batch-generate-document.yaml +1 -1
- package/agents/update/check-document.mjs +2 -2
- package/agents/update/generate-document.yaml +25 -0
- package/agents/utils/check-feedback-refiner.mjs +1 -1
- package/agents/utils/choose-docs.mjs +1 -1
- package/agents/utils/load-document-all-content.mjs +3 -3
- package/agents/utils/load-sources.mjs +1 -1
- package/agents/utils/save-docs.mjs +7 -28
- package/aigne.yaml +2 -2
- package/docs/_sidebar.md +1 -1
- package/docs/advanced-how-it-works.md +3 -3
- package/docs/advanced-quality-assurance.md +1 -1
- package/docs/cli-reference.ja.md +151 -80
- package/docs/cli-reference.md +126 -55
- package/docs/cli-reference.zh-TW.md +133 -62
- package/docs/cli-reference.zh.md +143 -72
- package/docs/configuration-interactive-setup.md +1 -1
- package/docs/configuration-language-support.md +1 -1
- package/docs/configuration-preferences.md +1 -1
- package/docs/configuration.ja.md +104 -48
- package/docs/configuration.md +58 -2
- package/docs/configuration.zh-TW.md +99 -42
- package/docs/configuration.zh.md +78 -21
- package/docs/features-generate-documentation.ja.md +63 -44
- package/docs/features-generate-documentation.md +54 -35
- package/docs/features-generate-documentation.zh-TW.md +67 -48
- package/docs/features-generate-documentation.zh.md +61 -41
- package/docs/features-publish-your-docs.ja.md +69 -46
- package/docs/features-publish-your-docs.md +65 -42
- package/docs/features-publish-your-docs.zh-TW.md +73 -50
- package/docs/features-publish-your-docs.zh.md +67 -44
- package/docs/features-translate-documentation.ja.md +35 -33
- package/docs/features-translate-documentation.md +24 -22
- package/docs/features-translate-documentation.zh-TW.md +32 -30
- package/docs/features-translate-documentation.zh.md +29 -27
- package/docs/features-update-and-refine.ja.md +120 -66
- package/docs/features-update-and-refine.md +110 -56
- package/docs/features-update-and-refine.zh-TW.md +116 -62
- package/docs/features-update-and-refine.zh.md +118 -64
- package/docs/getting-started.ja.md +22 -22
- package/docs/getting-started.md +1 -1
- package/docs/getting-started.zh-TW.md +16 -16
- package/docs/getting-started.zh.md +28 -28
- package/docs/overview.md +3 -3
- package/docs-mcp/analyze-docs-relevance.yaml +6 -6
- package/docs-mcp/docs-search.yaml +1 -1
- package/package.json +3 -3
- package/prompts/common/document-structure/conflict-resolution-guidance.md +3 -3
- package/prompts/common/document-structure/document-structure-rules.md +2 -2
- package/prompts/detail/{d2-chart/rules.md → d2-diagram/rules-system.md} +41 -5
- package/prompts/detail/d2-diagram/rules-user.md +4 -0
- package/prompts/detail/document-rules.md +3 -4
- package/prompts/detail/generate-document.md +8 -2
- package/prompts/detail/update-document.md +0 -2
- package/prompts/evaluate/document-structure.md +6 -6
- package/prompts/structure/check-document-structure.md +10 -10
- package/prompts/structure/document-rules.md +2 -2
- package/prompts/structure/generate-structure-system.md +3 -3
- package/prompts/structure/structure-example.md +1 -1
- package/prompts/structure/structure-getting-started.md +1 -1
- package/prompts/structure/update-document-structure.md +9 -9
- package/prompts/utils/feedback-refiner.md +1 -1
- package/tests/agents/clear/choose-contents.test.mjs +1 -1
- package/tests/agents/clear/clear-document-structure.test.mjs +36 -30
- package/tests/agents/evaluate/generate-report.test.mjs +1 -1
- package/tests/agents/generate/check-need-generate-structure.test.mjs +1 -1
- package/tests/agents/generate/document-structure-tools/add-document.test.mjs +2 -2
- package/tests/agents/generate/document-structure-tools/delete-document.test.mjs +4 -4
- package/tests/agents/generate/document-structure-tools/move-document.test.mjs +3 -3
- package/tests/agents/generate/document-structure-tools/update-document.test.mjs +3 -3
- package/tests/agents/generate/user-review-document-structure.test.mjs +7 -5
- package/tests/agents/init/init.test.mjs +25 -19
- package/tests/agents/publish/publish-docs.test.mjs +99 -0
- package/tests/agents/update/check-document.test.mjs +1 -1
- package/tests/agents/utils/check-detail-result.test.mjs +2 -15
- package/tests/agents/utils/format-document-structure.test.mjs +5 -5
- package/tests/agents/utils/load-sources.test.mjs +4 -4
- package/tests/agents/utils/save-docs.test.mjs +1 -1
- package/tests/utils/auth-utils.test.mjs +1 -1
- package/tests/utils/conflict-detector.test.mjs +1 -1
- package/tests/utils/d2-utils.test.mjs +4 -4
- package/tests/utils/deploy.test.mjs +3 -10
- package/tests/utils/docs-finder-utils.test.mjs +8 -8
- package/tests/utils/kroki-utils.test.mjs +5 -5
- package/tests/utils/preferences-utils.test.mjs +5 -3
- package/tests/utils/save-value-to-config.test.mjs +3 -1
- package/types/document-structure-schema.mjs +9 -9
- package/utils/auth-utils.mjs +4 -0
- package/utils/conflict-detector.mjs +1 -1
- package/utils/constants/index.mjs +7 -4
- package/utils/d2-utils.mjs +11 -6
- package/utils/deploy.mjs +4 -20
- package/utils/docs-finder-utils.mjs +11 -11
- package/utils/kroki-utils.mjs +5 -4
- package/utils/markdown-checker.mjs +1 -21
- /package/prompts/detail/{d2-chart → d2-diagram}/official-examples.md +0 -0
|
@@ -334,6 +334,9 @@ export const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
|
|
|
334
334
|
|
|
335
335
|
export const DOC_OFFICIAL_ACCESS_TOKEN = "DOC_OFFICIAL_ACCESS_TOKEN";
|
|
336
336
|
|
|
337
|
+
// Default application URL for the document deployment website.
|
|
338
|
+
export const DEFAULT_APP_URL = "https://docsmith.aigne.io";
|
|
339
|
+
|
|
337
340
|
// Discuss Kit related URLs
|
|
338
341
|
export const DISCUSS_KIT_STORE_URL =
|
|
339
342
|
"https://store.blocklet.dev/blocklets/z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu";
|
|
@@ -347,7 +350,7 @@ export const SUPPORTED_FILE_EXTENSIONS = [".txt", ".md", ".json", ".yaml", ".yml
|
|
|
347
350
|
export const CONFLICT_RULES = {
|
|
348
351
|
// Internal conflicts within the same question (multi-select conflicts)
|
|
349
352
|
internalConflicts: {
|
|
350
|
-
// Note: Most conflicts can be resolved through intelligent
|
|
353
|
+
// Note: Most conflicts can be resolved through intelligent documentation structure
|
|
351
354
|
// Only keeping conflicts that represent fundamental incompatibilities
|
|
352
355
|
},
|
|
353
356
|
|
|
@@ -421,7 +424,7 @@ export const CONFLICT_RULES = {
|
|
|
421
424
|
|
|
422
425
|
// Conflict resolution rules - defines how to handle conflicts when users select conflicting options
|
|
423
426
|
export const CONFLICT_RESOLUTION_RULES = {
|
|
424
|
-
// Document purpose conflicts that can be resolved through
|
|
427
|
+
// Document purpose conflicts that can be resolved through documentation structure
|
|
425
428
|
documentPurpose: [
|
|
426
429
|
{
|
|
427
430
|
conflictItems: ["getStarted", "findAnswers"],
|
|
@@ -448,7 +451,7 @@ export const CONFLICT_RESOLUTION_RULES = {
|
|
|
448
451
|
},
|
|
449
452
|
],
|
|
450
453
|
|
|
451
|
-
// Target audience conflicts that can be resolved through
|
|
454
|
+
// Target audience conflicts that can be resolved through documentation structure
|
|
452
455
|
targetAudienceTypes: [
|
|
453
456
|
{
|
|
454
457
|
conflictItems: ["endUsers", "developers"],
|
|
@@ -472,7 +475,7 @@ export const CONFLICT_RESOLUTION_RULES = {
|
|
|
472
475
|
// Resolution strategy descriptions
|
|
473
476
|
export const RESOLUTION_STRATEGIES = {
|
|
474
477
|
layered_structure: (items) =>
|
|
475
|
-
`Detected "${items.join('" and "')}" purpose conflict. Resolution strategy: Create layered
|
|
478
|
+
`Detected "${items.join('" and "')}" purpose conflict. Resolution strategy: Create layered documentation structure
|
|
476
479
|
- Quick start section: Uses "get started" style - optimizes for speed, key steps, working examples, skips complex edge cases
|
|
477
480
|
- API reference section: Uses "find answers" style - comprehensive coverage, searchability, rich examples, skips narrative flow
|
|
478
481
|
- Ensure sections complement rather than conflict with each other`,
|
package/utils/d2-utils.mjs
CHANGED
|
@@ -17,6 +17,8 @@ import { debug } from "./debug.mjs";
|
|
|
17
17
|
import { iconMap } from "./icon-map.mjs";
|
|
18
18
|
import { getContentHash } from "./utils.mjs";
|
|
19
19
|
|
|
20
|
+
const codeBlockRegex = /```d2.*\n([\s\S]*?)```/g;
|
|
21
|
+
|
|
20
22
|
export async function getChart({ content, strict }) {
|
|
21
23
|
const d2 = new D2();
|
|
22
24
|
const iconUrlList = Object.keys(iconMap);
|
|
@@ -60,7 +62,7 @@ export async function getChart({ content, strict }) {
|
|
|
60
62
|
} catch (err) {
|
|
61
63
|
if (strict) throw err;
|
|
62
64
|
|
|
63
|
-
console.error("Failed to generate D2
|
|
65
|
+
console.error("Failed to generate D2 diagram. Content:", content, "Error:", err);
|
|
64
66
|
return null;
|
|
65
67
|
} finally {
|
|
66
68
|
d2.worker.terminate();
|
|
@@ -73,8 +75,6 @@ export async function saveAssets({ markdown, docsDir }) {
|
|
|
73
75
|
return markdown;
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
const codeBlockRegex = /```d2.*\n([\s\S]*?)```/g;
|
|
77
|
-
|
|
78
78
|
const { replaced } = await runIterator({
|
|
79
79
|
input: markdown,
|
|
80
80
|
regexp: codeBlockRegex,
|
|
@@ -90,7 +90,7 @@ export async function saveAssets({ markdown, docsDir }) {
|
|
|
90
90
|
debug("Found assets cache, skipping generation", svgPath);
|
|
91
91
|
} else {
|
|
92
92
|
try {
|
|
93
|
-
debug("start generate d2
|
|
93
|
+
debug("start generate d2 diagram", svgPath);
|
|
94
94
|
if (debug.enabled) {
|
|
95
95
|
const d2FileName = `${getContentHash(d2Content)}.d2`;
|
|
96
96
|
const d2Path = path.join(assetDir, d2FileName);
|
|
@@ -102,7 +102,7 @@ export async function saveAssets({ markdown, docsDir }) {
|
|
|
102
102
|
await fs.writeFile(svgPath, svg, { encoding: "utf8" });
|
|
103
103
|
}
|
|
104
104
|
} catch (error) {
|
|
105
|
-
debug("Failed to generate D2
|
|
105
|
+
debug("Failed to generate D2 diagram. Content:", d2Content, "Error:", error);
|
|
106
106
|
return _code;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -156,7 +156,12 @@ async function runIterator({ input, regexp, fn = () => {}, options, replace = fa
|
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
export async function checkContent({ content }) {
|
|
159
|
+
export async function checkContent({ content: _content }) {
|
|
160
|
+
const matches = Array.from(_content.matchAll(codeBlockRegex));
|
|
161
|
+
let content = _content;
|
|
162
|
+
if (matches.length > 0) {
|
|
163
|
+
content = matches[0][1];
|
|
164
|
+
}
|
|
160
165
|
await ensureTmpDir();
|
|
161
166
|
const assetDir = path.join(DOC_SMITH_DIR, TMP_DIR, TMP_ASSETS_DIR, "d2");
|
|
162
167
|
await fs.ensureDir(assetDir);
|
package/utils/deploy.mjs
CHANGED
|
@@ -2,10 +2,11 @@ import { BrokerClient, STEPS } from "@blocklet/payment-broker-client/node";
|
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import open from "open";
|
|
4
4
|
import { getOfficialAccessToken } from "./auth-utils.mjs";
|
|
5
|
+
import { DEFAULT_APP_URL } from "./constants/index.mjs";
|
|
5
6
|
import { saveValueToConfig } from "./utils.mjs";
|
|
6
7
|
|
|
7
8
|
// ==================== Configuration ====================
|
|
8
|
-
const BASE_URL = process.env.DOC_SMITH_BASE_URL ||
|
|
9
|
+
const BASE_URL = process.env.DOC_SMITH_BASE_URL || DEFAULT_APP_URL;
|
|
9
10
|
const SUCCESS_MESSAGE = {
|
|
10
11
|
en: "Congratulations! Your website has been successfully installed. You can return to the command-line tool to continue the next steps.",
|
|
11
12
|
zh: "恭喜您,你的网站已安装成功!可以返回命令行工具继续后续操作!",
|
|
@@ -24,26 +25,14 @@ export async function deploy(id, cachedUrl) {
|
|
|
24
25
|
throw new Error("Failed to get official access token");
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
const client = new BrokerClient({
|
|
28
|
-
baseUrl: BASE_URL,
|
|
29
|
-
authToken,
|
|
30
|
-
paymentLinkKey: "PAYMENT_LINK_ID",
|
|
31
|
-
timeout: 300000,
|
|
32
|
-
polling: {
|
|
33
|
-
interval: 3000,
|
|
34
|
-
maxAttempts: 100,
|
|
35
|
-
backoffStrategy: "linear",
|
|
36
|
-
},
|
|
37
|
-
});
|
|
28
|
+
const client = new BrokerClient({ baseUrl: BASE_URL, authToken });
|
|
38
29
|
|
|
39
30
|
console.log(`🚀 Starting deployment...`);
|
|
40
31
|
|
|
41
32
|
const result = await client.deploy({
|
|
42
33
|
cachedCheckoutId: id,
|
|
43
34
|
cachedPaymentUrl: cachedUrl,
|
|
44
|
-
pageInfo: {
|
|
45
|
-
successMessage: SUCCESS_MESSAGE,
|
|
46
|
-
},
|
|
35
|
+
pageInfo: { successMessage: SUCCESS_MESSAGE },
|
|
47
36
|
hooks: {
|
|
48
37
|
[STEPS.PAYMENT_PENDING]: async ({ sessionId, paymentUrl, isResuming }) => {
|
|
49
38
|
console.log(`⏳ Step 1/4: Waiting for payment...`);
|
|
@@ -86,11 +75,6 @@ export async function deploy(id, cachedUrl) {
|
|
|
86
75
|
}
|
|
87
76
|
},
|
|
88
77
|
},
|
|
89
|
-
|
|
90
|
-
onError: (error, step) => {
|
|
91
|
-
console.error(`${chalk.red("❌")} Deployment failed at ${step || "unknown step"}:`);
|
|
92
|
-
console.error(` ${error.message}`);
|
|
93
|
-
},
|
|
94
78
|
});
|
|
95
79
|
|
|
96
80
|
const { appUrl, homeUrl, subscriptionUrl, dashboardUrl, vendors } = result;
|
|
@@ -24,8 +24,8 @@ function generateFileName(flatName, locale) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Find a single item by path in
|
|
28
|
-
* @param {Array} documentExecutionStructure - Array of
|
|
27
|
+
* Find a single item by path in documentation structure result and read its content
|
|
28
|
+
* @param {Array} documentExecutionStructure - Array of documentation structure items
|
|
29
29
|
* @param {string} docPath - Document path to find (supports .md filenames)
|
|
30
30
|
* @param {string} boardId - Board ID for fallback matching
|
|
31
31
|
* @param {string} docsDir - Docs directory path for reading content
|
|
@@ -116,7 +116,7 @@ export async function readFileContent(docsDir, fileName) {
|
|
|
116
116
|
* Get main language markdown files from docs directory
|
|
117
117
|
* @param {string} docsDir - Docs directory path
|
|
118
118
|
* @param {string} locale - Main language locale (e.g., 'en', 'zh', 'fr')
|
|
119
|
-
* @param {Array} documentExecutionStructure - Array of
|
|
119
|
+
* @param {Array} documentExecutionStructure - Array of documentation structure items to determine file order
|
|
120
120
|
* @returns {Promise<string[]>} Array of main language .md files ordered by documentExecutionStructure
|
|
121
121
|
*/
|
|
122
122
|
export async function getMainLanguageFiles(docsDir, locale, documentExecutionStructure = null) {
|
|
@@ -153,7 +153,7 @@ export async function getMainLanguageFiles(docsDir, locale, documentExecutionStr
|
|
|
153
153
|
|
|
154
154
|
// If documentExecutionStructure is provided, sort files according to the order in documentExecutionStructure
|
|
155
155
|
if (documentExecutionStructure && Array.isArray(documentExecutionStructure)) {
|
|
156
|
-
// Create a map from flat file name to
|
|
156
|
+
// Create a map from flat file name to documentation structure order
|
|
157
157
|
const orderMap = new Map();
|
|
158
158
|
documentExecutionStructure.forEach((item, index) => {
|
|
159
159
|
const itemFlattenedPath = item.path.replace(/^\//, "").replace(/\//g, "-");
|
|
@@ -166,16 +166,16 @@ export async function getMainLanguageFiles(docsDir, locale, documentExecutionStr
|
|
|
166
166
|
const orderA = orderMap.get(a);
|
|
167
167
|
const orderB = orderMap.get(b);
|
|
168
168
|
|
|
169
|
-
// If both files are in the
|
|
169
|
+
// If both files are in the documentation structure, sort by order
|
|
170
170
|
if (orderA !== undefined && orderB !== undefined) {
|
|
171
171
|
return orderA - orderB;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
// If only one file is in the
|
|
174
|
+
// If only one file is in the documentation structure, it comes first
|
|
175
175
|
if (orderA !== undefined) return -1;
|
|
176
176
|
if (orderB !== undefined) return 1;
|
|
177
177
|
|
|
178
|
-
// If neither file is in the
|
|
178
|
+
// If neither file is in the documentation structure, maintain alphabetical order
|
|
179
179
|
return a.localeCompare(b);
|
|
180
180
|
});
|
|
181
181
|
}
|
|
@@ -200,8 +200,8 @@ export function fileNameToFlatPath(fileName) {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/**
|
|
203
|
-
* Find
|
|
204
|
-
* @param {Array} documentExecutionStructure - Array of
|
|
203
|
+
* Find documentation structure item by flattened file name
|
|
204
|
+
* @param {Array} documentExecutionStructure - Array of documentation structure items
|
|
205
205
|
* @param {string} flatName - Flattened file name
|
|
206
206
|
* @returns {Object|null} Found item or null
|
|
207
207
|
*/
|
|
@@ -215,7 +215,7 @@ export function findItemByFlatName(documentExecutionStructure, flatName) {
|
|
|
215
215
|
/**
|
|
216
216
|
* Process selected files and convert to found items with content
|
|
217
217
|
* @param {string[]} selectedFiles - Array of selected file names
|
|
218
|
-
* @param {Array} documentExecutionStructure - Array of
|
|
218
|
+
* @param {Array} documentExecutionStructure - Array of documentation structure items
|
|
219
219
|
* @param {string} docsDir - Docs directory path
|
|
220
220
|
* @returns {Promise<Object[]>} Array of found items with content
|
|
221
221
|
*/
|
|
@@ -244,7 +244,7 @@ export async function processSelectedFiles(selectedFiles, documentExecutionStruc
|
|
|
244
244
|
|
|
245
245
|
foundItems.push(result);
|
|
246
246
|
} else {
|
|
247
|
-
console.warn(`⚠️ No
|
|
247
|
+
console.warn(`⚠️ No documentation structure item found for file: ${selectedFile}`);
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
|
package/utils/kroki-utils.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { joinURL } from "ufo";
|
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
D2_CONFIG,
|
|
11
|
+
DOC_SMITH_DIR,
|
|
11
12
|
FILE_CONCURRENCY,
|
|
12
13
|
KROKI_CONCURRENCY,
|
|
13
14
|
TMP_ASSETS_DIR,
|
|
@@ -76,7 +77,7 @@ export async function saveD2Assets({ markdown, docsDir }) {
|
|
|
76
77
|
debug("Found assets cache, skipping generation", svgPath);
|
|
77
78
|
} else {
|
|
78
79
|
try {
|
|
79
|
-
debug("
|
|
80
|
+
debug("Start generate d2 diagram", svgPath);
|
|
80
81
|
if (debug.enabled) {
|
|
81
82
|
const d2FileName = `${getContentHash(d2Content)}.d2`;
|
|
82
83
|
const d2Path = path.join(assetDir, d2FileName);
|
|
@@ -88,7 +89,7 @@ export async function saveD2Assets({ markdown, docsDir }) {
|
|
|
88
89
|
await fs.writeFile(svgPath, svg, { encoding: "utf8" });
|
|
89
90
|
}
|
|
90
91
|
} catch (error) {
|
|
91
|
-
debug("Failed to generate D2
|
|
92
|
+
debug("Failed to generate D2 diagram:", error);
|
|
92
93
|
return _code;
|
|
93
94
|
}
|
|
94
95
|
}
|
|
@@ -144,7 +145,7 @@ async function runIterator({ input, regexp, fn = () => {}, options, replace = fa
|
|
|
144
145
|
|
|
145
146
|
export async function checkD2Content({ content }) {
|
|
146
147
|
await ensureTmpDir();
|
|
147
|
-
const assetDir = path.join(
|
|
148
|
+
const assetDir = path.join(DOC_SMITH_DIR, TMP_DIR, TMP_ASSETS_DIR, "d2");
|
|
148
149
|
await fs.ensureDir(assetDir);
|
|
149
150
|
const d2Content = [D2_CONFIG, content].join("\n");
|
|
150
151
|
const fileName = `${getContentHash(d2Content)}.svg`;
|
|
@@ -166,7 +167,7 @@ export async function checkD2Content({ content }) {
|
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
export async function ensureTmpDir() {
|
|
169
|
-
const tmpDir = path.join(
|
|
170
|
+
const tmpDir = path.join(DOC_SMITH_DIR, TMP_DIR);
|
|
170
171
|
if (!(await fs.pathExists(path.join(tmpDir, ".gitignore")))) {
|
|
171
172
|
await fs.ensureDir(tmpDir);
|
|
172
173
|
await fs.writeFile(path.join(tmpDir, ".gitignore"), "**/*", { encoding: "utf8" });
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import pMap from "p-map";
|
|
4
3
|
import remarkGfm from "remark-gfm";
|
|
5
4
|
import remarkLint from "remark-lint";
|
|
6
5
|
import remarkParse from "remark-parse";
|
|
7
6
|
import { unified } from "unified";
|
|
8
7
|
import { visit } from "unist-util-visit";
|
|
9
8
|
import { VFile } from "vfile";
|
|
10
|
-
import { KROKI_CONCURRENCY } from "./constants/index.mjs";
|
|
11
|
-
import { checkContent, isValidCode } from "./d2-utils.mjs";
|
|
12
9
|
import { validateMermaidSyntax } from "./mermaid-validator.mjs";
|
|
13
10
|
|
|
14
11
|
/**
|
|
@@ -90,7 +87,7 @@ function checkDeadLinks(markdown, source, allowedLinks, errorMessages) {
|
|
|
90
87
|
// Check if this link is in the allowed links set
|
|
91
88
|
if (!allowedLinks.has(path)) {
|
|
92
89
|
errorMessages.push(
|
|
93
|
-
`Found a dead link in ${source}: [${match[1]}](${trimLink}), ensure the link exists in the
|
|
90
|
+
`Found a dead link in ${source}: [${match[1]}](${trimLink}), ensure the link exists in the documentation structure path`,
|
|
94
91
|
);
|
|
95
92
|
}
|
|
96
93
|
}
|
|
@@ -378,7 +375,6 @@ export async function checkMarkdown(markdown, source = "content", options = {})
|
|
|
378
375
|
|
|
379
376
|
// Check mermaid code blocks and other custom validations
|
|
380
377
|
const mermaidChecks = [];
|
|
381
|
-
const d2ChecksList = [];
|
|
382
378
|
visit(ast, "code", (node) => {
|
|
383
379
|
if (node.lang) {
|
|
384
380
|
const line = node.position?.start?.line || "unknown";
|
|
@@ -467,13 +463,6 @@ export async function checkMarkdown(markdown, source = "content", options = {})
|
|
|
467
463
|
specialCharMatch = nodeWithSpecialCharsRegex.exec(mermaidContent);
|
|
468
464
|
}
|
|
469
465
|
}
|
|
470
|
-
if (isValidCode(node.lang)) {
|
|
471
|
-
d2ChecksList.push({
|
|
472
|
-
content: node.value,
|
|
473
|
-
line,
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
// TODO: @zhanghan need to check correctness of every code language
|
|
477
466
|
}
|
|
478
467
|
});
|
|
479
468
|
|
|
@@ -524,15 +513,6 @@ export async function checkMarkdown(markdown, source = "content", options = {})
|
|
|
524
513
|
|
|
525
514
|
// Wait for all mermaid checks to complete
|
|
526
515
|
await Promise.all(mermaidChecks);
|
|
527
|
-
await pMap(
|
|
528
|
-
d2ChecksList,
|
|
529
|
-
async ({ content, line }) =>
|
|
530
|
-
checkContent({ content }).catch((err) => {
|
|
531
|
-
const errorMessage = err?.message || String(err) || "Unknown d2 syntax error";
|
|
532
|
-
errorMessages.push(`Found D2 syntax error in ${source} at line ${line}: ${errorMessage}`);
|
|
533
|
-
}),
|
|
534
|
-
{ concurrency: KROKI_CONCURRENCY },
|
|
535
|
-
);
|
|
536
516
|
|
|
537
517
|
// Run markdown linting rules
|
|
538
518
|
await processor.run(ast, file);
|
|
File without changes
|