Skip to content

Commit 7fb85a7

Browse files
Add API documentation generation with phpDocumentor
- Add phpDocumentor configuration and `docs` Makefile target - Generate docs during CI to catch errors before releases - Set up GitHub Pages with Jekyll for hosting generated docs - Add GitHub Actions workflow to deploy docs to GitHub Pages on releases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3699323 commit 7fb85a7

File tree

8 files changed

+98
-6
lines changed

8 files changed

+98
-6
lines changed

.github/workflows/docs.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v5
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '8.4'
22+
coverage: "none"
23+
24+
- name: Install Composer
25+
uses: "ramsey/composer-install@v3"
26+
27+
- name: Generate API Documentation
28+
run: make docs
29+
30+
- name: Copy API docs into docs directory
31+
run: cp -r build/docs docs/api
32+
33+
- name: Deploy to gh-pages branch
34+
uses: peaceiris/actions-gh-pages@v4
35+
with:
36+
github_token: ${{ secrets.GITHUB_TOKEN }}
37+
publish_dir: ./docs
38+
enable_jekyll: true

.github/workflows/pipeline.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ jobs:
7676

7777
- name: PHPStan
7878
run: vendor/bin/phpstan analyse
79+
80+
- name: Documentation
81+
run: make docs

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ vendor
66
examples/**/dev.log
77
examples/**/cache
88
examples/**/sessions
9+
10+
# phpDocumentor
11+
build/
12+
.phpdoc/
13+
phpDocumentor.phar

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: deps-stable deps-low cs rector phpstan tests coverage run-examples ci ci-stable ci-lowest
1+
.PHONY: deps-stable deps-low cs rector phpstan tests coverage run-examples ci ci-stable ci-lowest docs
22

33
deps-stable:
44
composer update --prefer-stable
@@ -29,3 +29,8 @@ ci: ci-stable
2929
ci-stable: deps-stable cs phpstan tests
3030

3131
ci-lowest: deps-low cs phpstan tests
32+
33+
docs:
34+
vendor/bin/phpdoc
35+
@grep -q 'No errors have been found' build/docs/reports/errors.html || \
36+
(echo "Documentation errors found. See build/docs/reports/errors.html" && exit 1)

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@
3333
"symfony/uid": "^6.4 || ^7.3 || ^8.0"
3434
},
3535
"require-dev": {
36+
"laminas/laminas-httphandlerrunner": "^2.12",
37+
"nyholm/psr7": "^1.8",
38+
"nyholm/psr7-server": "^1.1",
3639
"php-cs-fixer/shim": "^3.91",
40+
"phpdocumentor/shim": "^3",
3741
"phpstan/phpstan": "^2.1",
3842
"phpunit/phpunit": "^10.5",
3943
"psr/cache": "^3.0",
4044
"psr/simple-cache": "^3.0",
4145
"symfony/cache": "^6.4 || ^7.3 || ^8.0",
4246
"symfony/console": "^6.4 || ^7.3 || ^8.0",
43-
"symfony/process": "^6.4 || ^7.3 || ^8.0",
44-
"nyholm/psr7": "^1.8",
45-
"nyholm/psr7-server": "^1.1",
46-
"laminas/laminas-httphandlerrunner": "^2.12"
47+
"symfony/process": "^6.4 || ^7.3 || ^8.0"
4748
},
4849
"autoload": {
4950
"psr-4": {
@@ -69,7 +70,8 @@
6970
"config": {
7071
"sort-packages": true,
7172
"allow-plugins": {
72-
"php-http/discovery": false
73+
"php-http/discovery": false,
74+
"phpdocumentor/shim": true
7375
}
7476
}
7577
}

docs/_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include:
2+
- _*

docs/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="refresh" content="0; url=api/">
6+
<link rel="canonical" href="api/">
7+
<title>MCP PHP SDK Documentation</title>
8+
</head>
9+
<body>
10+
<p>Redirecting to <a href="api/">API Documentation</a>...</p>
11+
</body>
12+
</html>

phpdoc.dist.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<phpdocumentor
3+
configVersion="3"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns="https://www.phpdoc.org"
6+
xsi:noNamespaceSchemaLocation="https://docs.phpdoc.org/latest/phpdoc.xsd"
7+
>
8+
<title>MCP PHP SDK</title>
9+
<paths>
10+
<output>build/docs</output>
11+
</paths>
12+
<version number="latest">
13+
<api>
14+
<source dsn=".">
15+
<path>src</path>
16+
</source>
17+
<output>api</output>
18+
<ignore>
19+
<path>vendor/**/*</path>
20+
<path>tests/**/*</path>
21+
</ignore>
22+
</api>
23+
</version>
24+
<setting name="graphs.enabled" value="true"/>
25+
</phpdocumentor>

0 commit comments

Comments
 (0)