Skip to content

Commit 8552f12

Browse files
committed
feat: add comprehensive help output for PDF generation script
1 parent d5a57e4 commit 8552f12

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

scripts/generate-pdf.js

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,68 @@ const puppeteer = require('puppeteer');
55
const { PDFDocument } = require('pdf-lib');
66
const { marked } = require('marked');
77

8+
// Help function
9+
function showHelp() {
10+
console.log(`
11+
Docusaurus PDF Generator
12+
13+
USAGE:
14+
node scripts/generate-pdf.js [VERSION] [OPTIONS]
15+
16+
ARGUMENTS:
17+
VERSION Version to generate PDF for (default: 'current')
18+
Examples: current, 0.14, 0.13, 0.12
19+
20+
OPTIONS:
21+
--help, -h Show this help message
22+
23+
ENVIRONMENT VARIABLES:
24+
LOCALE Language locale for the documentation (default: 'en')
25+
Examples: en, zh, ja, fr
26+
27+
BLACKLISTED_CATEGORIES Comma-separated list of categories to exclude from PDF
28+
Examples: changelog,roadmap,api-reference
29+
30+
EXAMPLES:
31+
# Generate PDF for current English docs
32+
node scripts/generate-pdf.js current
33+
34+
# Generate PDF for version 0.14 English docs
35+
node scripts/generate-pdf.js 0.14
36+
37+
# Generate PDF for current Chinese docs
38+
LOCALE=zh node scripts/generate-pdf.js current
39+
40+
# Generate PDF for version 0.14 with blacklisted categories
41+
BLACKLISTED_CATEGORIES=changelog,roadmap node scripts/generate-pdf.js 0.14
42+
43+
# Generate PDF for Chinese version 0.14 with blacklisted categories
44+
LOCALE=zh BLACKLISTED_CATEGORIES=changelog,roadmap node scripts/generate-pdf.js 0.14
45+
46+
OUTPUT:
47+
PDF files are generated in the 'pdf-build' directory with the naming pattern:
48+
- docs-current.pdf (for current English docs)
49+
- docs-0.14.pdf (for version 0.14 English docs)
50+
- docs-current-zh.pdf (for current Chinese docs)
51+
- docs-0.14-zh.pdf (for version 0.14 Chinese docs)
52+
53+
NOTES:
54+
- The script follows the sidebar order defined in sidebars.js or versioned sidebar files
55+
- Outbound links (http://, https://) are converted to plain text in the PDF
56+
- Front matter is automatically removed from markdown files
57+
- Individual PDFs are generated first, then combined into a single document
58+
`);
59+
}
60+
61+
// Parse command line arguments
62+
const args = process.argv.slice(2);
63+
if (args.includes('--help') || args.includes('-h')) {
64+
showHelp();
65+
process.exit(0);
66+
}
67+
868
// Get version from command line
9-
const version = process.argv[2] || 'current'; // Default to current docs
69+
const version = args[0] || 'current'; // Default to current docs
1070

1171
// Configuration - can be moved to a config file if needed
1272
const BLACKLISTED_CATEGORIES = process.env.BLACKLISTED_CATEGORIES

0 commit comments

Comments
 (0)