Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1d46a34
wip: sdk reference generation workflow
ben-fornefeld Jan 6, 2026
254049f
Refactor SDK reference generation workflow
ben-fornefeld Jan 6, 2026
f75a36f
Enhance SDK navigation and styling
ben-fornefeld Jan 7, 2026
1927687
cleanup
ben-fornefeld Jan 7, 2026
81afe32
fix: sdks.json
ben-fornefeld Jan 7, 2026
e97acb3
Enhance SDK reference generation and configuration
ben-fornefeld Jan 7, 2026
a191e97
improve: better idempotency comparison
ben-fornefeld Jan 7, 2026
ddcf32a
cleanup
ben-fornefeld Jan 7, 2026
3890aa2
refactor: bash to typescript generator
ben-fornefeld Jan 8, 2026
c0ecf0b
cleanup:
ben-fornefeld Jan 8, 2026
cb7be7f
refactor: migrate SDK configuration from JSON to TypeScript
ben-fornefeld Jan 8, 2026
24b4430
refactor: improve SDK reference generation and navigation
ben-fornefeld Jan 8, 2026
87e0c1d
chore: remove package.json and pnpm-lock.yaml
ben-fornefeld Jan 8, 2026
89d8116
fix: config
ben-fornefeld Jan 8, 2026
c9f0fd6
refactor: update SDK configuration and improve generation logic
ben-fornefeld Jan 8, 2026
9ce811f
chore
ben-fornefeld Jan 8, 2026
a0aa2e4
cleanup
ben-fornefeld Jan 8, 2026
38682df
refactor: improve error handling and logging in CLI and generator
ben-fornefeld Jan 8, 2026
42c4f4f
add: last 3 versions of all sdks to docs
ben-fornefeld Jan 8, 2026
9b940a6
reactive TOC
ben-fornefeld Jan 10, 2026
1dfbd1b
refactor: enhance SDK reference generation workflow
ben-fornefeld Jan 12, 2026
6bfbc7d
fix: pip install fallback
ben-fornefeld Jan 12, 2026
804758a
fix: update SDK documentation for clarity and accuracy
ben-fornefeld Jan 12, 2026
13ef59c
remove: generated sdk reference
ben-fornefeld Jan 12, 2026
07d46d4
add: limit as input
ben-fornefeld Jan 12, 2026
4d0ce3f
fix: infer limit input correctly in workflow
ben-fornefeld Jan 12, 2026
3a1d58f
fix: limit
ben-fornefeld Jan 12, 2026
a7a75f8
fix limit
ben-fornefeld Jan 12, 2026
09a27fa
chore: force color
ben-fornefeld Jan 12, 2026
15ff8e3
cleanup: action
ben-fornefeld Jan 12, 2026
ca5cedb
refactor: replace process.exit with error throwing for better error h…
ben-fornefeld Jan 12, 2026
5748e31
add: tests
ben-fornefeld Jan 12, 2026
9eb05fc
feat: enhance SDK configuration with version-specific overrides and a…
ben-fornefeld Jan 12, 2026
1df3c3a
fix: versioning config
ben-fornefeld Jan 12, 2026
b46a603
fix: silent fs move issues
ben-fornefeld Jan 12, 2026
cfaa83a
fix: pip installs
ben-fornefeld Jan 12, 2026
a3dd778
cleanup files before force regeneration
ben-fornefeld Jan 12, 2026
9670c39
fix: normailze versioning
ben-fornefeld Jan 12, 2026
4eaca6f
improve: pr test workflow + chore: cleanup docs.json
ben-fornefeld Jan 13, 2026
d8bde74
restore: docs.json
ben-fornefeld Feb 16, 2026
3fef604
Apply suggestion from @ben-fornefeld
ben-fornefeld Feb 16, 2026
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
113 changes: 113 additions & 0 deletions .github/workflows/sdk-reference-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Sync SDK Reference Documentation

on:
# manual trigger with inputs
workflow_dispatch:
inputs:
sdk:
description: "SDK to generate (see sdks.config.ts for available SDKs, or use 'all')"
required: true
default: "all"
type: string
version:
description: "Version to generate (all, latest, or specific like v2.9.0)"
required: true
default: "all"
type: string

# triggered from e2b-dev/e2b repo on release
repository_dispatch:
types: [sdk-release]

jobs:
generate:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout docs repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install generator dependencies
working-directory: sdk-reference-generator
run: pnpm install --frozen-lockfile

- name: Install Python dependencies
run: pip install -r requirements.txt

- name: Install Poetry
run: pip install poetry

- name: Determine SDK and Version
id: params
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
SDK="${{ github.event.inputs.sdk }}"
VERSION="${{ github.event.inputs.version }}"
elif [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
SDK="${{ github.event.client_payload.sdk }}"
# on repository_dispatch, default to "all" to auto-detect missing versions
VERSION="${{ github.event.client_payload.version }}"
Comment thread
ben-fornefeld marked this conversation as resolved.
Outdated
VERSION="${VERSION:-all}"
fi

echo "sdk=${SDK:-all}" >> $GITHUB_OUTPUT
echo "version=${VERSION:-all}" >> $GITHUB_OUTPUT

- name: Generate SDK Reference
working-directory: sdk-reference-generator
run: |
pnpm run generate \
--sdk "${{ steps.params.outputs.sdk }}" \
--version "${{ steps.params.outputs.version }}"

- name: Verify generated files
run: |
echo "Generated SDK reference files:"
find docs/sdk-reference -type f -name "*.mdx" 2>/dev/null | head -20 || echo "No MDX files found"

- name: Commit and push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git add docs/sdk-reference/
git add docs.json

if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "[skip ci] Update SDK reference: ${{ steps.params.outputs.sdk }} ${{ steps.params.outputs.version }}"
git push
fi

- name: Summary
run: |
echo "## SDK Reference Generation Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **SDK**: ${{ steps.params.outputs.sdk }}" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ steps.params.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Generated Files" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
find docs/sdk-reference -type f -name "*.mdx" | wc -l | xargs echo "Total MDX files:" >> $GITHUB_STEP_SUMMARY
find docs/sdk-reference -type f -name "*.mdx" >> $GITHUB_STEP_SUMMARY || true
echo '```' >> $GITHUB_STEP_SUMMARY
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
.idea
.DS_Store

node_modules

# Generated SDK navigation (intermediate file)
sdk_navigation.json
3 changes: 3 additions & 0 deletions .mintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sdk-reference-generator/

scripts/
17 changes: 9 additions & 8 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,24 @@
},
{
"group": "Deployment",
"pages": ["docs/byoc"]
"pages": [
"docs/byoc"
]
},
{
"group": "Migration",
"pages": ["docs/migration/v2"]
"pages": [
"docs/migration/v2"
]
},
{
"group": "Troubleshooting",
"pages": [
{
"group": "SDKs",
"pages": ["docs/troubleshooting/sdks/workers-edge-runtime"]
"pages": [
"docs/troubleshooting/sdks/workers-edge-runtime"
]
},
{
"group": "Templates",
Expand All @@ -191,11 +197,6 @@
]
}
]
},
{
"anchor": "SDK Reference",
"icon": "brackets-curly",
"href": "https://e2b.dev/docs/sdk-reference"
}
],
"global": {}
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Python dependencies for SDK reference generation
pydoc-markdown>=4.8.2
poetry>=1.8.0

Empty file modified scripts/generate-mcp-servers.sh
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions sdk-reference-generator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
dist/
*.log

166 changes: 166 additions & 0 deletions sdk-reference-generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# SDK Reference Documentation Generator

TypeScript-based documentation generator for E2B SDKs with automatic versioning, caching, and CI/CD integration.

## Features

- **Multi-SDK Support**: JS, Python, CLI, Code Interpreter, Desktop SDKs
- **Automatic Version Discovery**: Detects and generates missing versions
- **Intelligent Caching**: Skips reinstalling dependencies when lockfile unchanged
- **Idempotent**: Safe to run repeatedly, only generates what's missing
- **Full Visibility**: Complete logging of all subcommands for debugging
- **Verification**: Validates generated docs before finalizing
- **CI/CD Ready**: GitHub Actions integration with safety checks

## Usage

```bash
# generate all SDKs, all versions
pnpm run generate

# generate specific SDK, latest version
pnpm run generate --sdk js-sdk --version latest

# generate specific version
pnpm run generate --sdk python-sdk --version v2.8.0

# limit to last N versions (useful for testing)
pnpm run generate --sdk all --version all --limit 5

# force regenerate existing versions (useful after config changes)
pnpm run generate --sdk js-sdk --version all --force

# combine flags
pnpm run generate --sdk all --version all --limit 3 --force
```

## Architecture

```
src/
├── cli.ts # Entry point with CLI argument parsing
├── generator.ts # Core SDK generation orchestration
├── navigation.ts # Mintlify navigation builder
├── types.ts # TypeScript interfaces
├── lib/
│ ├── constants.ts # Centralized magic strings
│ ├── utils.ts # Pure utility functions
│ ├── git.ts # Git operations (clone, tags)
│ ├── checkout.ts # Manages repo checkouts and version switching
│ ├── versions.ts # Version comparison and filtering
│ ├── files.ts # Markdown processing and flattening
│ ├── install.ts # Package manager abstraction
│ └── verify.ts # Post-generation validation
└── generators/
├── typedoc.ts # JavaScript/TypeScript docs
├── pydoc.ts # Python docs
└── cli.ts # CLI command docs
```

## Configuration

SDKs are configured in `sdks.json`:

```json
{
"sdks": {
"js-sdk": {
"displayName": "SDK (JavaScript)",
"icon": "square-js",
"order": 1,
"repo": "https://github.com/e2b-dev/e2b.git",
"tagPattern": "e2b@",
"tagFormat": "e2b@{version}",
"generator": "typedoc",
"required": true,
"minVersion": "1.0.0",
"sdkPath": "packages/js-sdk"
}
}
}
```

## Error Handling

### Strict Safety Model

1. **Required SDKs**: Any failure aborts workflow
2. **Optional SDKs**: All versions failing aborts workflow
3. **Partial failures**: Non-required SDK with some successes continues
4. **Verification**: Post-generation validation ensures quality

### Progressive Dependency Resolution

For maximum compatibility across SDK versions:

1. **Try pnpm install** - Primary package manager with caching
2. **Try npm fallback** - Uses npm with `--force` and `--legacy-peer-deps`

Each strategy visible in logs for debugging. If both strategies fail, workflow aborts.

### What Gets Logged

- ✅ Package manager output (pnpm/npm/poetry/pip)
- ✅ Build tool output (TypeDoc, pydoc-markdown, CLI builds)
- ✅ File operations (copying, flattening)
- ✅ Validation results (empty files, missing frontmatter)
- ✅ Final statistics (files, SDKs, versions)

## Verification Checks

Before finalizing, the generator verifies:

1. **Generated Files**: No empty MDX files
2. **Frontmatter**: All files have proper frontmatter
3. **Structure**: Valid directory structure
4. **docs.json**: Valid JSON with correct navigation structure

## Testing

```bash
# run unit tests
pnpm test

# run with watch mode
pnpm test:watch

# type check
npx tsc --noEmit
```

Tests cover:
- Version comparison and filtering (10 tests)
- File operations and title casing (5 tests)
- Verification logic (7 tests)

## CI/CD Integration

The generator runs in GitHub Actions on:
- Manual workflow dispatch
- Automatic repository dispatch from SDK repos on release

Safety features:
- Validates all generated files before committing
- Only commits if changes detected
- Skips CI on doc updates (`[skip ci]` in commit message)
Comment thread
ben-fornefeld marked this conversation as resolved.
Outdated
- Full logging visible in workflow runs

## Performance

- **Checkout Reuse**: Repository cloned once, versions switched via git checkout
- **Version Deduplication**: Batch comparison skips already-generated versions
- **Parallel Generation**: Could process multiple versions concurrently (future enhancement)

## Development

```bash
# install dependencies
pnpm install

# run generator locally
pnpm run generate --sdk js-sdk --limit 1

# run tests
pnpm test
```

Loading