@writedocs/generator 0.13.4 → 0.14.0
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/README.md +28 -28
- package/astro.config.mjs +645 -645
- package/bin/writedocs.js +359 -356
- package/package.json +99 -99
- package/src/cli/base-path-layout.js +44 -44
- package/src/cli/build-auth.js +135 -135
- package/src/cli/build.js +223 -203
- package/src/cli/check-built-styles.js +41 -41
- package/src/cli/convert.js +124 -124
- package/src/cli/dev.js +269 -268
- package/src/cli/exit-when-flushed.js +42 -42
- package/src/cli/generate-api-pages.js +509 -507
- package/src/cli/og-image-worker.js +20 -20
- package/src/cli/og-images.js +70 -70
- package/src/cli/page-list-watch.js +71 -69
- package/src/cli/run-astro.js +97 -97
- package/src/cli/run-pagefind.js +154 -154
- package/src/cli/write-mcp-files.js +103 -103
- package/src/cli/write-redirects-file.js +158 -158
- package/src/components/ApiReferencePanel.astro +1792 -1792
- package/src/components/AppIcon.astro +51 -51
- package/src/components/Card.astro +193 -193
- package/src/components/CodeGroup.astro +63 -39
- package/src/components/CopyPageMenu.astro +374 -374
- package/src/components/Hint.astro +188 -188
- package/src/components/Icon.astro +72 -72
- package/src/components/Image.astro +165 -165
- package/src/components/Tile.astro +67 -67
- package/src/components/Video.astro +137 -137
- package/src/content.config.ts +219 -203
- package/src/layout/BaseLayout.astro +908 -908
- package/src/layout/components/AnalyticsScripts.astro +49 -49
- package/src/layout/components/Breadcrumbs.astro +98 -98
- package/src/layout/components/ConsentBanner.astro +119 -119
- package/src/layout/components/MobileMenu.astro +225 -225
- package/src/layout/components/NavTree.astro +422 -408
- package/src/layout/components/Sidebar.astro +232 -232
- package/src/layout/components/SiteFooter.astro +87 -87
- package/src/layout/components/TopBar.astro +386 -386
- package/src/layout/styles/base.css +332 -326
- package/src/layout/styles/mobile-menu.css +285 -285
- package/src/lib/agent-markdown.js +164 -164
- package/src/lib/asset-dimensions.js +89 -89
- package/src/lib/base-path.js +90 -90
- package/src/lib/cli-report.js +22 -22
- package/src/lib/code-line-numbers.js +13 -0
- package/src/lib/config-schema.js +12 -1
- package/src/lib/config-schema.ts +2523 -2509
- package/src/lib/config.ts +1331 -1316
- package/src/lib/consent.js +108 -108
- package/src/lib/content-check.js +4 -1
- package/src/lib/content-store-reload-integration.js +101 -101
- package/src/lib/drafts.js +186 -0
- package/src/lib/icon-data-dev.js +53 -53
- package/src/lib/image-size.js +152 -152
- package/src/lib/json-schema-descriptions.js +228 -228
- package/src/lib/link-check.js +553 -544
- package/src/lib/llms-index.ts +90 -90
- package/src/lib/mcp-dev-integration.js +65 -65
- package/src/lib/mcp-index.ts +102 -102
- package/src/lib/mintlify-convert.js +605 -605
- package/src/lib/moved-api-pages.js +49 -49
- package/src/lib/og-cards.js +33 -33
- package/src/lib/og-image.js +235 -235
- package/src/lib/openapi-dev-status.js +80 -80
- package/src/lib/openapi-reload-integration.js +193 -193
- package/src/lib/pages.js +346 -312
- package/src/lib/project-files-integration.js +116 -116
- package/src/lib/project-files.js +137 -137
- package/src/lib/rehype-base-path.js +62 -62
- package/src/lib/rehype-image-loading.js +71 -71
- package/src/lib/robots-txt.js +21 -21
- package/src/lib/search-scope.js +44 -44
- package/src/lib/selector-placement.js +50 -50
- package/src/lib/seo-tags.js +157 -155
- package/src/lib/shiki-code-block.js +7 -1
- package/src/lib/site-base.ts +27 -27
- package/src/lib/styles-asset-integration.js +291 -291
- package/src/lib/wdignore-cases.json +195 -195
- package/src/lib/wdignore.js +177 -177
- package/src/pages/404.astro +63 -63
- package/src/pages/[...slug].astro +1773 -1608
- package/src/pages/[...slug].md.ts +93 -93
- package/src/pages/llms-full.txt.ts +88 -88
- package/src/pages/og/[...slug].png.ts +63 -63
- package/src/scripts/mobile-menu.ts +80 -80
- package/src/scripts/search.ts +245 -245
- package/src/scripts/sidebar-scroll.ts +61 -61
- package/src/styles/global.css +40 -40
package/src/cli/convert.js
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
// `writedocs convert --mintlify [dir]` / `--writedocs [dir]` - turns a
|
|
2
|
-
// Mintlify project's docs.json, or a config.json from the previous writedocs,
|
|
3
|
-
// into writedocs.json, in the same folder, then checks the pages the same way
|
|
4
|
-
// `writedocs validate` does. The conversions themselves are
|
|
5
|
-
// lib/mintlify-convert.js and lib/writedocs-legacy-convert.js; this file is
|
|
6
|
-
// the CLI around them.
|
|
7
|
-
import fs from 'node:fs';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import { loadMintlifyConfig, convertMintlifyConfig, formatNotes } from '../lib/mintlify-convert.js';
|
|
10
|
-
import { loadLegacyConfig, convertLegacyConfig } from '../lib/writedocs-legacy-convert.js';
|
|
11
|
-
import { validateDocsConfig, formatValidationIssuesDetailed } from '../lib/config-schema.js';
|
|
12
|
-
import { checkContent, formatContentIssues } from '../lib/content-check.js';
|
|
13
|
-
import { log, step, plural, color, displayPath, CliExit, logToStderr } from './output.js';
|
|
14
|
-
|
|
15
|
-
const SOURCES = {
|
|
16
|
-
mintlify: {
|
|
17
|
-
file: 'docs.json',
|
|
18
|
-
load: loadMintlifyConfig,
|
|
19
|
-
convert: async (input) => convertMintlifyConfig(input),
|
|
20
|
-
missing(contentDir) {
|
|
21
|
-
if (fs.existsSync(path.join(contentDir, 'mint.json'))) {
|
|
22
|
-
log.error("Found mint.json, Mintlify's older config format.");
|
|
23
|
-
log.detail(color.dim(`Run "npx mint upgrade" in ${contentDir} to turn it into docs.json, then run this again.`));
|
|
24
|
-
} else {
|
|
25
|
-
log.error(`No docs.json found in ${contentDir}`);
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
domainHint: '(Mintlify sets this in its dashboard, not docs.json.)',
|
|
29
|
-
},
|
|
30
|
-
writedocs: {
|
|
31
|
-
file: 'config.json',
|
|
32
|
-
load: loadLegacyConfig,
|
|
33
|
-
convert: (input, contentDir) => convertLegacyConfig(input, contentDir),
|
|
34
|
-
missing(contentDir) {
|
|
35
|
-
log.error(`No config.json found in ${contentDir}`);
|
|
36
|
-
},
|
|
37
|
-
domainHint: '(config.json had no field for it.)',
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export async function runConvert({ source = 'mintlify', contentDir, force = false, dryRun = false }) {
|
|
42
|
-
// --dry-run's stdout is the converted writedocs.json and nothing else, so
|
|
43
|
-
// `writedocs convert --dry-run > writedocs.json` works; the notes and the
|
|
44
|
-
// page check go to stderr.
|
|
45
|
-
if (dryRun) logToStderr();
|
|
46
|
-
const from = SOURCES[source];
|
|
47
|
-
const inputPath = path.join(contentDir, from.file);
|
|
48
|
-
if (!fs.existsSync(inputPath)) {
|
|
49
|
-
from.missing(contentDir);
|
|
50
|
-
throw new CliExit(1);
|
|
51
|
-
}
|
|
52
|
-
const outPath = path.join(contentDir, 'writedocs.json');
|
|
53
|
-
if (!dryRun && !force && fs.existsSync(outPath)) {
|
|
54
|
-
log.error(`${displayPath(outPath)} already exists.`);
|
|
55
|
-
log.detail(color.dim('Pass --force to overwrite it, or --dry-run to only see the result.'));
|
|
56
|
-
throw new CliExit(1);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let input;
|
|
60
|
-
try {
|
|
61
|
-
input = from.load(inputPath);
|
|
62
|
-
} catch (err) {
|
|
63
|
-
log.error(`Couldn't read ${displayPath(inputPath)}: ${err.message}`);
|
|
64
|
-
throw new CliExit(1);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const { config, notes } = await from.convert(input, contentDir);
|
|
68
|
-
const text = `${JSON.stringify(config, null, 2)}\n`;
|
|
69
|
-
|
|
70
|
-
// The result must pass writedocs' own schema - if it doesn't, that's a
|
|
71
|
-
// converter bug, and writing it would only hand the author a broken file.
|
|
72
|
-
const result = validateDocsConfig(text);
|
|
73
|
-
if (!result.ok) {
|
|
74
|
-
log.error('The converted writedocs.json is not valid - this is a bug in the converter, please report it:');
|
|
75
|
-
log.line();
|
|
76
|
-
log.line(formatValidationIssuesDetailed(result.issues, { total: result.issuesTotal, truncated: result.issuesTruncated }));
|
|
77
|
-
log.line(`\n${text}`);
|
|
78
|
-
throw new CliExit(1);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (dryRun) {
|
|
82
|
-
process.stdout.write(text);
|
|
83
|
-
} else {
|
|
84
|
-
fs.writeFileSync(outPath, text);
|
|
85
|
-
log.success(`Converted ${from.file} to ${color.bold(displayPath(outPath))}`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (notes.length) {
|
|
89
|
-
log.line();
|
|
90
|
-
log.info(`${plural(notes.length, 'thing')} couldn't be carried over as-is:`);
|
|
91
|
-
log.line();
|
|
92
|
-
log.line(formatNotes(notes));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// The pages, checked against the converted config - what's left to fix
|
|
96
|
-
// before the first build.
|
|
97
|
-
const checking = step('Checking pages');
|
|
98
|
-
const content = await checkContent(contentDir, text);
|
|
99
|
-
// The domain reminder comes once, at the end, with where the source tool
|
|
100
|
-
// kept that setting.
|
|
101
|
-
content.warnings = content.warnings.filter((w) => w.code !== 'no-domain');
|
|
102
|
-
checking.stop();
|
|
103
|
-
if (content.errors.length) {
|
|
104
|
-
log.line();
|
|
105
|
-
log.error(`${plural(content.errors.length, 'error')} in the pages - the build would fail on these:`);
|
|
106
|
-
log.line();
|
|
107
|
-
log.line(formatContentIssues(content.errors));
|
|
108
|
-
}
|
|
109
|
-
if (content.warnings.length) {
|
|
110
|
-
log.line();
|
|
111
|
-
log.warn(`${plural(content.warnings.length, 'warning')} in the pages:`);
|
|
112
|
-
log.line();
|
|
113
|
-
log.line(formatContentIssues(content.warnings));
|
|
114
|
-
}
|
|
115
|
-
log.line();
|
|
116
|
-
const summary = `Checked ${plural(content.pages, 'page')}: ${plural(content.errors.length, 'error')}, ${plural(content.warnings.length, 'warning')}`;
|
|
117
|
-
if (content.errors.length) log.error(summary);
|
|
118
|
-
else log.success(summary);
|
|
119
|
-
if (!config.domain) {
|
|
120
|
-
log.info(
|
|
121
|
-
`Next: set "domain" in writedocs.json to your site's URL - it turns on sitemap.xml and absolute links for social previews. ${from.domainHint}`
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
1
|
+
// `writedocs convert --mintlify [dir]` / `--writedocs [dir]` - turns a
|
|
2
|
+
// Mintlify project's docs.json, or a config.json from the previous writedocs,
|
|
3
|
+
// into writedocs.json, in the same folder, then checks the pages the same way
|
|
4
|
+
// `writedocs validate` does. The conversions themselves are
|
|
5
|
+
// lib/mintlify-convert.js and lib/writedocs-legacy-convert.js; this file is
|
|
6
|
+
// the CLI around them.
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { loadMintlifyConfig, convertMintlifyConfig, formatNotes } from '../lib/mintlify-convert.js';
|
|
10
|
+
import { loadLegacyConfig, convertLegacyConfig } from '../lib/writedocs-legacy-convert.js';
|
|
11
|
+
import { validateDocsConfig, formatValidationIssuesDetailed } from '../lib/config-schema.js';
|
|
12
|
+
import { checkContent, formatContentIssues } from '../lib/content-check.js';
|
|
13
|
+
import { log, step, plural, color, displayPath, CliExit, logToStderr } from './output.js';
|
|
14
|
+
|
|
15
|
+
const SOURCES = {
|
|
16
|
+
mintlify: {
|
|
17
|
+
file: 'docs.json',
|
|
18
|
+
load: loadMintlifyConfig,
|
|
19
|
+
convert: async (input) => convertMintlifyConfig(input),
|
|
20
|
+
missing(contentDir) {
|
|
21
|
+
if (fs.existsSync(path.join(contentDir, 'mint.json'))) {
|
|
22
|
+
log.error("Found mint.json, Mintlify's older config format.");
|
|
23
|
+
log.detail(color.dim(`Run "npx mint upgrade" in ${contentDir} to turn it into docs.json, then run this again.`));
|
|
24
|
+
} else {
|
|
25
|
+
log.error(`No docs.json found in ${contentDir}`);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
domainHint: '(Mintlify sets this in its dashboard, not docs.json.)',
|
|
29
|
+
},
|
|
30
|
+
writedocs: {
|
|
31
|
+
file: 'config.json',
|
|
32
|
+
load: loadLegacyConfig,
|
|
33
|
+
convert: (input, contentDir) => convertLegacyConfig(input, contentDir),
|
|
34
|
+
missing(contentDir) {
|
|
35
|
+
log.error(`No config.json found in ${contentDir}`);
|
|
36
|
+
},
|
|
37
|
+
domainHint: '(config.json had no field for it.)',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export async function runConvert({ source = 'mintlify', contentDir, force = false, dryRun = false }) {
|
|
42
|
+
// --dry-run's stdout is the converted writedocs.json and nothing else, so
|
|
43
|
+
// `writedocs convert --dry-run > writedocs.json` works; the notes and the
|
|
44
|
+
// page check go to stderr.
|
|
45
|
+
if (dryRun) logToStderr();
|
|
46
|
+
const from = SOURCES[source];
|
|
47
|
+
const inputPath = path.join(contentDir, from.file);
|
|
48
|
+
if (!fs.existsSync(inputPath)) {
|
|
49
|
+
from.missing(contentDir);
|
|
50
|
+
throw new CliExit(1);
|
|
51
|
+
}
|
|
52
|
+
const outPath = path.join(contentDir, 'writedocs.json');
|
|
53
|
+
if (!dryRun && !force && fs.existsSync(outPath)) {
|
|
54
|
+
log.error(`${displayPath(outPath)} already exists.`);
|
|
55
|
+
log.detail(color.dim('Pass --force to overwrite it, or --dry-run to only see the result.'));
|
|
56
|
+
throw new CliExit(1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let input;
|
|
60
|
+
try {
|
|
61
|
+
input = from.load(inputPath);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
log.error(`Couldn't read ${displayPath(inputPath)}: ${err.message}`);
|
|
64
|
+
throw new CliExit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const { config, notes } = await from.convert(input, contentDir);
|
|
68
|
+
const text = `${JSON.stringify(config, null, 2)}\n`;
|
|
69
|
+
|
|
70
|
+
// The result must pass writedocs' own schema - if it doesn't, that's a
|
|
71
|
+
// converter bug, and writing it would only hand the author a broken file.
|
|
72
|
+
const result = validateDocsConfig(text);
|
|
73
|
+
if (!result.ok) {
|
|
74
|
+
log.error('The converted writedocs.json is not valid - this is a bug in the converter, please report it:');
|
|
75
|
+
log.line();
|
|
76
|
+
log.line(formatValidationIssuesDetailed(result.issues, { total: result.issuesTotal, truncated: result.issuesTruncated }));
|
|
77
|
+
log.line(`\n${text}`);
|
|
78
|
+
throw new CliExit(1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (dryRun) {
|
|
82
|
+
process.stdout.write(text);
|
|
83
|
+
} else {
|
|
84
|
+
fs.writeFileSync(outPath, text);
|
|
85
|
+
log.success(`Converted ${from.file} to ${color.bold(displayPath(outPath))}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (notes.length) {
|
|
89
|
+
log.line();
|
|
90
|
+
log.info(`${plural(notes.length, 'thing')} couldn't be carried over as-is:`);
|
|
91
|
+
log.line();
|
|
92
|
+
log.line(formatNotes(notes));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// The pages, checked against the converted config - what's left to fix
|
|
96
|
+
// before the first build.
|
|
97
|
+
const checking = step('Checking pages');
|
|
98
|
+
const content = await checkContent(contentDir, text);
|
|
99
|
+
// The domain reminder comes once, at the end, with where the source tool
|
|
100
|
+
// kept that setting.
|
|
101
|
+
content.warnings = content.warnings.filter((w) => w.code !== 'no-domain');
|
|
102
|
+
checking.stop();
|
|
103
|
+
if (content.errors.length) {
|
|
104
|
+
log.line();
|
|
105
|
+
log.error(`${plural(content.errors.length, 'error')} in the pages - the build would fail on these:`);
|
|
106
|
+
log.line();
|
|
107
|
+
log.line(formatContentIssues(content.errors));
|
|
108
|
+
}
|
|
109
|
+
if (content.warnings.length) {
|
|
110
|
+
log.line();
|
|
111
|
+
log.warn(`${plural(content.warnings.length, 'warning')} in the pages:`);
|
|
112
|
+
log.line();
|
|
113
|
+
log.line(formatContentIssues(content.warnings));
|
|
114
|
+
}
|
|
115
|
+
log.line();
|
|
116
|
+
const summary = `Checked ${plural(content.pages, 'page')}: ${plural(content.errors.length, 'error')}, ${plural(content.warnings.length, 'warning')}`;
|
|
117
|
+
if (content.errors.length) log.error(summary);
|
|
118
|
+
else log.success(summary);
|
|
119
|
+
if (!config.domain) {
|
|
120
|
+
log.info(
|
|
121
|
+
`Next: set "domain" in writedocs.json to your site's URL - it turns on sitemap.xml and absolute links for social previews. ${from.domainHint}`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|