Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/generate-pdfs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Generate Documentation PDFs

on:
release:
types: [published]
workflow_dispatch: # Allow manual triggering

jobs:
generate-pdfs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '19'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Install Chrome for Puppeteer
run: |
sudo apt-get update
sudo apt-get install -y chromium-browser xvfb

- name: Configure Chrome for headless mode
run: |
echo "PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser" >> $GITHUB_ENV
echo "DISPLAY=:99" >> $GITHUB_ENV

- name: Start virtual display
run: |
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &

- name: Enable PDF generation in config
run: |
sed -i 's/autoBuildPdfs: false/autoBuildPdfs: true/' docusaurus.config.js

- name: Build documentation with PDFs
run: npm run build

- name: Create PDF artifacts directory structure
run: |
mkdir -p pdf-artifacts/CoreBox
mkdir -p pdf-artifacts/ElectronicsBox
mkdir -p pdf-artifacts/InfinityBox
mkdir -p pdf-artifacts/DiscoveryFluorescence
mkdir -p pdf-artifacts/LightsheetBox
mkdir -p pdf-artifacts/QBox
mkdir -p pdf-artifacts/SeeedMicroscope

- name: Copy generated PDFs
run: |
if [ -d "build/pdfs" ]; then
# Copy all PDFs to main artifacts directory
cp -r build/pdfs/* pdf-artifacts/ 2>/dev/null || true

# Organize PDFs by toolbox if they exist
# CoreBox PDFs for different languages
find build/pdfs -name "*CoreBox*EN*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true
find build/pdfs -name "*CoreBox*DE*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true
find build/pdfs -name "*CoreBox*FR*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true
find build/pdfs -name "*CoreBox*ES*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true
find build/pdfs -name "*CoreBox*AR*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true
find build/pdfs -name "*core*" -exec cp {} pdf-artifacts/CoreBox/ \; 2>/dev/null || true

# Other toolbox PDFs
find build/pdfs -name "*Electronics*" -exec cp {} pdf-artifacts/ElectronicsBox/ \; 2>/dev/null || true
find build/pdfs -name "*electronics*" -exec cp {} pdf-artifacts/ElectronicsBox/ \; 2>/dev/null || true
find build/pdfs -name "*Infinity*" -exec cp {} pdf-artifacts/InfinityBox/ \; 2>/dev/null || true
find build/pdfs -name "*infinity*" -exec cp {} pdf-artifacts/InfinityBox/ \; 2>/dev/null || true
find build/pdfs -name "*Fluorescence*" -exec cp {} pdf-artifacts/DiscoveryFluorescence/ \; 2>/dev/null || true
find build/pdfs -name "*fluorescence*" -exec cp {} pdf-artifacts/DiscoveryFluorescence/ \; 2>/dev/null || true
find build/pdfs -name "*Lightsheet*" -exec cp {} pdf-artifacts/LightsheetBox/ \; 2>/dev/null || true
find build/pdfs -name "*lightsheet*" -exec cp {} pdf-artifacts/LightsheetBox/ \; 2>/dev/null || true
find build/pdfs -name "*QBox*" -exec cp {} pdf-artifacts/QBox/ \; 2>/dev/null || true
find build/pdfs -name "*qbox*" -exec cp {} pdf-artifacts/QBox/ \; 2>/dev/null || true
find build/pdfs -name "*Seeed*" -exec cp {} pdf-artifacts/SeeedMicroscope/ \; 2>/dev/null || true
find build/pdfs -name "*seeed*" -exec cp {} pdf-artifacts/SeeedMicroscope/ \; 2>/dev/null || true

# List what was found
echo "Generated PDFs:"
find pdf-artifacts -name "*.pdf" -type f | sort

# Count PDFs
PDF_COUNT=$(find pdf-artifacts -name "*.pdf" -type f | wc -l)
echo "Total PDFs generated: $PDF_COUNT"
else
echo "No PDFs directory found in build output"
echo "Checking build structure:"
ls -la build/ 2>/dev/null || echo "No build directory found"
fi

- name: Upload PDFs as artifacts
uses: actions/upload-artifact@v4
with:
name: documentation-pdfs-${{ github.run_number }}
path: pdf-artifacts/
if-no-files-found: warn

- name: Attach PDFs to release
if: github.event_name == 'release' && hashFiles('pdf-artifacts/**/*.pdf') != ''
uses: softprops/action-gh-release@v1
with:
files: pdf-artifacts/**/*.pdf
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63 changes: 63 additions & 0 deletions PDF_GENERATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Documentation PDF Generation

This repository now includes automated PDF generation for all toolbox documentation using the [docusaurus-plugin-papersaurus](https://github.com/simologos/docusaurus-plugin-papersaurus) plugin.

## How it works

1. **Automatic Generation**: PDFs are automatically generated when a new release is published via GitHub Actions
2. **Manual Trigger**: The workflow can also be manually triggered from the Actions tab
3. **Organized Output**: PDFs are organized by toolbox type for easy access

## Generated PDFs

The workflow generates PDFs for the following documentation:

### CoreBox (with language variants)
- English documentation
- German documentation (Deutsch)
- French documentation (Français)
- Spanish documentation (Español)
- Arabian documentation

### Other Toolboxes
- ElectronicsBox
- InfinityBox
- DiscoveryFluorescence
- LightsheetBox
- QBox
- SeeedMicroscope

## Accessing PDFs

Generated PDFs are available in two ways:

1. **Release Assets**: Attached to each GitHub release
2. **Workflow Artifacts**: Available as artifacts from the GitHub Actions workflow

## For Maintainers

### Manual PDF Generation

To manually generate PDFs locally (requires Chrome/Chromium):

1. Install Chrome or Chromium browser
2. Set environment variable: `export PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser`
3. Enable PDF generation in `docusaurus.config.js`: `autoBuildPdfs: true`
4. Run: `npm run build`
5. PDFs will be generated in `build/pdfs/`

### Workflow Configuration

The PDF generation workflow is located at `.github/workflows/generate-pdfs.yml` and:

- Installs required dependencies including Chrome
- Builds the documentation with PDF generation enabled
- Organizes PDFs by toolbox type
- Uploads artifacts and attaches to releases

## Technical Details

- **Plugin**: docusaurus-plugin-papersaurus v2.0.3
- **PDF Engine**: Puppeteer with Chrome/Chromium
- **Organization**: Automated sorting by toolbox folder structure
- **Trigger**: Release events and manual workflow dispatch
Loading
Loading