diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..28a6f5f7 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,38 @@ +name: Deploy Documentation + +on: + release: + types: [published] + workflow_dispatch: + +permissions: + contents: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + coverage: "none" + + - name: Install Composer + uses: "ramsey/composer-install@v3" + + - name: Generate API Documentation + run: make docs + + - name: Copy API docs into docs directory + run: cp -r build/docs docs/api + + - name: Deploy to gh-pages branch + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs + enable_jekyll: true diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index aa1a0142..929d9123 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -132,3 +132,6 @@ jobs: - name: PHPStan run: vendor/bin/phpstan analyse + + - name: Documentation + run: make docs diff --git a/.gitignore b/.gitignore index 3d4a2bcf..9baa3469 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,8 @@ examples/**/dev.log examples/**/cache examples/**/sessions results + +# phpDocumentor +build/ +.phpdoc/ +phpDocumentor.phar diff --git a/Makefile b/Makefile index 59d00e43..0984def7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: deps-stable deps-low cs phpstan tests unit-tests inspector-tests coverage ci ci-stable ci-lowest +.PHONY: deps-stable deps-low cs phpstan tests unit-tests inspector-tests coverage ci ci-stable ci-lowest docs deps-stable: composer update --prefer-stable @@ -35,3 +35,8 @@ ci: ci-stable ci-stable: deps-stable cs phpstan tests ci-lowest: deps-low cs phpstan tests + +docs: + vendor/bin/phpdoc + @grep -q 'No errors have been found' build/docs/reports/errors.html || \ + (echo "Documentation errors found. See build/docs/reports/errors.html" && exit 1) diff --git a/composer.json b/composer.json index 83a08f39..eff01183 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,9 @@ "laminas/laminas-httphandlerrunner": "^2.12", "nyholm/psr7": "^1.8", "nyholm/psr7-server": "^1.1", + "phar-io/composer-distributor": "^1.0.2", "php-cs-fixer/shim": "^3.91", + "phpdocumentor/shim": "^3", "phpstan/phpstan": "^2.1", "phpunit/phpunit": "^10.5", "psr/simple-cache": "^2.0 || ^3.0", @@ -69,7 +71,8 @@ }, "config": { "allow-plugins": { - "php-http/discovery": false + "php-http/discovery": false, + "phpdocumentor/shim": true }, "sort-packages": true } diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 00000000..b3611564 --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1,2 @@ +include: + - _* diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 00000000..c6cf2f25 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,12 @@ + + +
+ + + +Redirecting to API Documentation...
+ + diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml new file mode 100644 index 00000000..c9d7920d --- /dev/null +++ b/phpdoc.dist.xml @@ -0,0 +1,25 @@ + +