Skip to content

Commit 137cf7c

Browse files
fix: fix multidoc cross-version links and remove duplication (#1588)
1 parent ff06828 commit 137cf7c

4 files changed

Lines changed: 5 additions & 76 deletions

File tree

.github/workflows/main.yml

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -108,46 +108,3 @@ jobs:
108108
- run: pnpm publish --provenance --access public ${{ steps.npm-tag.outputs.tag }}
109109
env:
110110
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
111-
112-
# Generates API documentation (V1 + V2) and deploys to GitHub Pages on any release
113-
deploy-docs:
114-
runs-on: ubuntu-latest
115-
if: github.event_name == 'release'
116-
needs: [publish]
117-
118-
permissions:
119-
contents: read
120-
pages: write
121-
id-token: write
122-
123-
environment:
124-
name: github-pages
125-
url: ${{ steps.deployment.outputs.page_url }}
126-
127-
steps:
128-
- uses: actions/checkout@v4
129-
130-
- name: Install pnpm
131-
uses: pnpm/action-setup@v4
132-
with:
133-
run_install: false
134-
- uses: actions/setup-node@v4
135-
with:
136-
node-version: 24
137-
cache: pnpm
138-
cache-dependency-path: pnpm-lock.yaml
139-
140-
- name: Generate multi-version docs
141-
run: bash scripts/generate-multidoc.sh tmp/docs-combined
142-
143-
- name: Configure Pages
144-
uses: actions/configure-pages@v5
145-
146-
- name: Upload Pages artifact
147-
uses: actions/upload-pages-artifact@v3
148-
with:
149-
path: tmp/docs-combined
150-
151-
- name: Deploy to GitHub Pages
152-
id: deployment
153-
uses: actions/deploy-pages@v4

docs/v2-banner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
document.addEventListener("DOMContentLoaded", function () {
22
var banner = document.createElement("div");
33
banner.innerHTML =
4-
"This documents a <strong>pre-release</strong> version of the SDK. Expect breaking changes. For the stable SDK, see the <a href='/'>V1 docs</a>.";
4+
"This documents a <strong>pre-release</strong> version of the SDK. Expect breaking changes. For the stable SDK, see the <a href='/typescript-sdk/'>V1 docs</a>.";
55
banner.style.cssText =
66
"background:#fff3cd;color:#856404;border-bottom:1px solid #ffc107;padding:8px 16px;text-align:center;font-size:14px;";
77
banner.querySelector("a").style.cssText = "color:#856404;text-decoration:underline;";

scripts/generate-multidoc.sh

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set -euo pipefail
1717

1818
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1919
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
20-
OUTPUT_DIR="${1:-$REPO_ROOT/tmp/docs-combined}"
20+
OUTPUT_DIR="$(cd "$REPO_ROOT" && realpath -m "${1:-tmp/docs-combined}")"
2121
V1_WORKTREE="$REPO_ROOT/.worktrees/v1-docs"
2222
V2_WORKTREE="$REPO_ROOT/.worktrees/v2-docs"
2323

@@ -76,7 +76,7 @@ cat > typedoc.json << 'TYPEDOC_EOF'
7676
"docs/faq.md"
7777
],
7878
"navigationLinks": {
79-
"V2 Docs": "/v2/"
79+
"V2 Docs": "/typescript-sdk/v2/"
8080
},
8181
"headings": {
8282
"readme": false
@@ -109,35 +109,6 @@ cd "$V2_WORKTREE"
109109
pnpm install
110110
pnpm -r --filter='./packages/**' build
111111

112-
# Write the V2 pre-release banner script
113-
cat > docs/v2-banner.js << 'BANNER_EOF'
114-
document.addEventListener("DOMContentLoaded", function () {
115-
var banner = document.createElement("div");
116-
banner.innerHTML =
117-
"This documents a <strong>pre-release</strong> version of the SDK. Expect breaking changes. For the stable SDK, see the <a href='/'>V1 docs</a>.";
118-
banner.style.cssText =
119-
"background:#fff3cd;color:#856404;border-bottom:1px solid #ffc107;padding:8px 16px;text-align:center;font-size:14px;";
120-
banner.querySelector("a").style.cssText = "color:#856404;text-decoration:underline;";
121-
document.body.insertBefore(banner, document.body.firstChild);
122-
123-
124-
});
125-
BANNER_EOF
126-
127-
# Patch the V2 typedoc config to add navigation links, base URL, and banner
128-
node -e "
129-
import fs from 'fs';
130-
const cfg = fs.readFileSync('typedoc.config.mjs', 'utf8');
131-
const patched = cfg.replace(
132-
/export default \{/,
133-
\"export default {\\n hostedBaseUrl: 'https://modelcontextprotocol.github.io/typescript-sdk/v2/',\\n customJs: 'docs/v2-banner.js',\"
134-
).replace(
135-
/navigation:/,
136-
\"navigationLinks: {\\n 'V1 Docs': '/',\\n },\\n navigation:\"
137-
);
138-
fs.writeFileSync('typedoc.config.mjs', patched);
139-
"
140-
141112
npx typedoc # outputs to tmp/docs/ per typedoc.config.mjs
142113

143114
mkdir -p "$OUTPUT_DIR/v2"

typedoc.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ export default {
3333
},
3434
highlightLanguages: [...OptionDefaults.highlightLanguages, 'powershell'],
3535
projectDocuments: ['docs/documents.md'],
36+
hostedBaseUrl: 'https://modelcontextprotocol.github.io/typescript-sdk/v2/',
3637
navigationLinks: {
37-
'V1 Docs': '/'
38+
'V1 Docs': '/typescript-sdk/'
3839
},
3940
navigation: {
4041
compactFolders: true,

0 commit comments

Comments
 (0)