Skip to content

Commit 875fcb5

Browse files
Add API documentation with GitHub Pages deployment
This adds automated generation and deployment of versioned API documentation using TypeDoc and GitHub Pages. Documentation will be generated and published when a new release is created. ## Changes 1. **Documentation generation script** (see `scripts/generate-gh-pages.sh`) Generates TypeDoc documentation for a specific version tag and commits it to the gh-pages branch. The script uses git worktrees to isolate the documentation generation process from the main workspace. Documentation for each release is stored in a versioned directory (e.g., `v1.2.3/`) on the gh-pages branch. The script: - Creates the gh-pages branch as an orphan branch if it doesn't exist - Parses semantic versions from tag names, ignoring arbitrary prefixes (e.g., tags `1.2.3`, `v1.2.3`, and `release-1.2.3` all create `v1.2.3/`) - Preserves all existing version directories when generating new documentation - Determines the latest version using semantic version sorting - Copies any custom documentation from the `docs/` directory to the gh-pages root (for the latest version only) - Generates a landing page listing all versions in descending order (only if no index file exists after copying custom documentation) - Creates a `latest/` redirect that always points to the most recent version 2. **GitHub Actions workflow** (see `.github/workflows/main.yml`) Added a `publish-gh-pages` job that runs after the `publish` job on release events. This ensures documentation is generated and published only after the npm package is successfully published. The job invokes the generation script with the release tag name and pushes the updated gh-pages branch. 3. **CI validation** (see `package.json`) Updated the `check` script to include TypeDoc validation with `--emit none`. This ensures TypeDoc can successfully parse the codebase (without generating output), catching documentation issues early in CI. 4. **Documentation link** (see `README.md`) Added a link to the published API documentation in the Documentation section of the README. ## TypeDoc Configuration TypeDoc is configured via `typedoc.json`: - Uses the `src` directory as the entry point with the `expand` strategy - Uses `tsconfig.prod.json` which excludes test files ## Documentation URL Published documentation will be available at: https://modelcontextprotocol.github.io/typescript-sdk/ Individual versions will be accessible at: - https://modelcontextprotocol.github.io/typescript-sdk/v1.2.3/ - https://modelcontextprotocol.github.io/typescript-sdk/latest/ Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 29cb080 commit 875fcb5

File tree

6 files changed

+443
-1
lines changed

6 files changed

+443
-1
lines changed

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,35 @@ jobs:
6565
- run: npm publish --provenance --access public
6666
env:
6767
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
68+
69+
publish-gh-pages:
70+
runs-on: ubuntu-latest
71+
if: github.event_name == 'release'
72+
needs: [publish]
73+
74+
permissions:
75+
contents: write
76+
77+
steps:
78+
- uses: actions/checkout@v4
79+
with:
80+
fetch-depth: 0 # Fetch all history for all branches
81+
82+
- uses: actions/setup-node@v4
83+
with:
84+
node-version: 24
85+
cache: npm
86+
87+
- name: Install dependencies
88+
run: npm ci
89+
90+
- name: Configure Git
91+
run: |
92+
git config --global user.name "github-actions[bot]"
93+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
94+
95+
- name: Generate documentation
96+
run: ./scripts/generate-gh-pages.sh ${{ github.ref_name }}
97+
98+
- name: Push to gh-pages
99+
run: git push origin gh-pages

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,7 @@ app.listen(3000);
14981498

14991499
## Documentation
15001500

1501+
- [SDK API documentation](https://modelcontextprotocol.github.io/typescript-sdk/)
15011502
- [Model Context Protocol documentation](https://modelcontextprotocol.io)
15021503
- [MCP Specification](https://spec.modelcontextprotocol.io)
15031504
- [Example Servers](https://github.com/modelcontextprotocol/servers)

0 commit comments

Comments
 (0)