2024-12-09 20:28:31 -05:00
2024-12-09 20:26:35 -05:00
2024-12-09 20:26:35 -05:00
2024-12-09 20:26:35 -05:00
2024-05-17 01:44:30 +02:00
2024-12-09 20:28:31 -05:00
2024-05-17 01:44:30 +02:00

README.md

Export Nextjs Docs Script

The script automates the process of cloning documentation repositories, converting Markdown files to HTML, and generating PDF files. This README covers installation and usage.


Features

  • Clone remote repositories with sparse checkout.
  • Convert Markdown files to HTML with code block and image path preprocessing.
  • Generate PDFs with custom headers, footers, and styles.
  • Automatically create a hierarchical Table of Contents (ToC).
  • Detect the latest version of the documentation.
  • Handles YAML frontmatter for metadata-rich documentation.

Installation

Prerequisites

  • Python 3.8+
  • Required Python packages:
    • markdown
    • yaml
    • tqdm
    • playwright
    • gitpython
  • Ensure you have Playwright installed and configured:
    pip install playwright
    playwright install
    

Clone the Repository and Install

Clone the project repository, create a virtual environment, activate it, and install requirements.


```bash
git clone https://github.com/pacnpal/Docs-Exporter.git
cd Docs-Exporter
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
playwright install
```

Usage

1. Clone and Update Nextjs Repository

Run the script to clone or update the remote documentation repository:

python export-docs.py

2. Convert Markdown to HTML

The script automatically processes .md and .mdx files, converting them to styled HTML.

3. Generate PDF

A PDF is created with a generated title and ToC. Ensure no other process is using the output file.

Example Configuration

repo_url = "https://github.com/vercel/next.js.git"
branch = "canary"
docs_dir = "docs"

Output

  • PDF file: Next.js_Docs_vXX.XX.X_YYYY-MM-DD.pdf
  • Logs: Process information printed to the terminal.

LICENSE

This project is governed by the LICENSE file. Please ensure compliance when redistributing or modifying the script.

Description
Converts Next.js documentation to HTML/PDF
Readme AGPL-3.0 128 KiB
Languages
Python 87.3%
CSS 12.7%