Skip to content

feat: add script to generate pdf from our markdown docs #1861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 53 commits into
base: main
Choose a base branch
from

Conversation

sunng87
Copy link
Member

@sunng87 sunng87 commented Jun 24, 2025

What's Changed in this PR

This patch adds a script to generate pdf from markdown files.

The script is mostly generated by AI

TODO Items:

  • images
  • cross-doc links doesn't work
  • pdf index
  • custom pdf cover

Checklist

  • Please confirm that all corresponding versions of the documents have been revised.
  • Please ensure that the content in sidebars.ts matches the current document structure when you changed the document structure.
  • This change requires follow-up update in localized docs.

Copy link

cloudflare-workers-and-pages bot commented Jun 24, 2025

Deploying greptime-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6885ff4
Status: ✅  Deploy successful!
Preview URL: https://665fd736.greptime-docs.pages.dev
Branch Preview URL: https://feature-doc-pdf.greptime-docs.pages.dev

View logs

@sunng87 sunng87 marked this pull request as ready for review June 24, 2025 21:33
@sunng87 sunng87 requested a review from nicecui June 24, 2025 21:34
@sunng87
Copy link
Member Author

sunng87 commented Jun 24, 2025

A sample of generated content is like
docs-0.14.pdf

Options like removing some content, customize cover page are supported.

❯ npm run pdf -- --help

> [email protected] pdf
> node scripts/generate-pdf.js --help


Docusaurus PDF Generator

USAGE:
  node scripts/generate-pdf.js [VERSION] [OPTIONS]

ARGUMENTS:
  VERSION                 Version to generate PDF for (default: 'current')
                         Examples: current, 0.14, 0.13, 0.12

OPTIONS:
  --help, -h             Show this help message
  --skip-generation      Skip individual PDF generation and combine existing temp files
  --keep-temp            Keep temporary PDF files after successful generation
  --locale LOCALE        Language locale for the documentation (default: 'en')
                         Examples: en, zh, ja, fr
  --blacklist CATEGORIES Comma-separated list of categories to exclude from PDF
                         Examples: changelog,roadmap,api-reference
  --cover FILE           Path to PDF file to use as cover page (prepended to output)
                         Example: --cover docs/cover.pdf


EXAMPLES:
  # Generate PDF for current English docs
  node scripts/generate-pdf.js current

  # Generate PDF for version 0.14 English docs
  node scripts/generate-pdf.js 0.14

  # Generate PDF for current Chinese docs
  node scripts/generate-pdf.js current --locale zh

  # Generate PDF for version 0.14 with blacklisted categories
  node scripts/generate-pdf.js 0.14 --blacklist changelog,roadmap

  # Generate PDF for Chinese version 0.14 with blacklisted categories
  node scripts/generate-pdf.js 0.14 --locale zh --blacklist changelog,roadmap

  # Generate PDF with custom cover page
  node scripts/generate-pdf.js current --cover docs/cover.pdf

  # Generate PDF and keep temporary files for debugging
  node scripts/generate-pdf.js current --keep-temp

OUTPUT:
  PDF files are generated in the 'pdf-build' directory with the naming pattern:
  - docs-current.pdf (for current English docs)
  - docs-0.14.pdf (for version 0.14 English docs)
  - docs-current-zh.pdf (for current Chinese docs)
  - docs-0.14-zh.pdf (for version 0.14 Chinese docs)

NOTES:
  - The script follows the sidebar order defined in sidebars.js or versioned sidebar files
  - Outbound links (http://, https://) are converted to plain text in the PDF
  - Front matter is automatically removed from markdown files
  - Individual PDFs are generated first, then combined into a single document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant