|
| 1 | +#!/bin/sh |
| 2 | +set -eu |
| 3 | +cd "$(dirname "$0")/.." |
| 4 | +PHPDOC_PHAR="bin/phpDocumentor.phar" |
| 5 | +if [ ! -f "$PHPDOC_PHAR" ]; then |
| 6 | + mkdir -p bin |
| 7 | + # Pin a recent stable version; check https://github.com/phpDocumentor/phpDocumentor/releases for latest |
| 8 | + curl -fsSL -o "$PHPDOC_PHAR" "https://phpdoc.org/phpDocumentor.phar" |
| 9 | + chmod +x "$PHPDOC_PHAR" |
| 10 | +fi |
| 11 | +rm -rf docs/_site |
| 12 | + |
| 13 | +# Pass 1: HTML output via the default template. |
| 14 | +php "$PHPDOC_PHAR" --config phpdoc.dist.xml |
| 15 | + |
| 16 | +# Pass 2: Markdown output alongside HTML for AI agents that want |
| 17 | +# parallel `.md` files. Uses the saggre/phpdocumentor-markdown |
| 18 | +# community template (require-dev). The markdown files are written |
| 19 | +# alongside the HTML in docs/_site/ — same paths, different extensions. |
| 20 | +MD_TEMPLATE="vendor/saggre/phpdocumentor-markdown/themes/markdown" |
| 21 | +if [ ! -d "$MD_TEMPLATE" ]; then |
| 22 | + echo "Markdown template missing. Run 'composer install' first." >&2 |
| 23 | + exit 1 |
| 24 | +fi |
| 25 | +php "$PHPDOC_PHAR" --config phpdoc.dist.xml --template="$MD_TEMPLATE" |
| 26 | + |
| 27 | +# Pass 3: llms.txt — curated index for AI agents, per llmstxt.org. |
| 28 | +# Lists the top-level entry points (Core, Services, Exceptions); the 600+ |
| 29 | +# generated Resource DTOs are reachable by walking classes/WorkOS/Resource/. |
| 30 | +SITE="docs/_site" |
| 31 | +{ |
| 32 | + echo "# WorkOS PHP SDK" |
| 33 | + echo |
| 34 | + echo "> Official PHP SDK for the WorkOS API: authentication, SSO, Directory Sync, audit logs, and more." |
| 35 | + echo |
| 36 | + echo "API reference auto-generated from source. Each class has a parallel \`.md\` file alongside its HTML page." |
| 37 | + echo |
| 38 | + echo "## Core" |
| 39 | + echo |
| 40 | + find "$SITE/classes/WorkOS" -maxdepth 1 -name "*.md" | sort | while read -r f; do |
| 41 | + name=$(basename "$f" .md) |
| 42 | + echo "- [$name](${f#$SITE/})" |
| 43 | + done |
| 44 | + echo |
| 45 | + echo "## Services" |
| 46 | + echo |
| 47 | + find "$SITE/classes/WorkOS/Service" -maxdepth 1 -name "*.md" | sort | while read -r f; do |
| 48 | + name=$(basename "$f" .md) |
| 49 | + echo "- [$name](${f#$SITE/})" |
| 50 | + done |
| 51 | + echo |
| 52 | + echo "## Exceptions" |
| 53 | + echo |
| 54 | + find "$SITE/classes/WorkOS/Exception" -maxdepth 1 -name "*.md" | sort | while read -r f; do |
| 55 | + name=$(basename "$f" .md) |
| 56 | + echo "- [$name](${f#$SITE/})" |
| 57 | + done |
| 58 | + echo |
| 59 | + echo "## Optional" |
| 60 | + echo |
| 61 | + echo "- [Resource DTOs](classes/WorkOS/Resource/): generated request/response types, one \`.md\` file per class." |
| 62 | +} > "$SITE/llms.txt" |
0 commit comments