|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +usage() { |
| 5 | + cat <<'EOF' |
| 6 | +Usage: |
| 7 | + scripts/build_api_docs_repo.sh <output_dir> |
| 8 | +
|
| 9 | +Builds the standalone api-docs repository payload with this layout: |
| 10 | + api-docs/ (from docs/api-full) |
| 11 | + _processwire_version.json |
| 12 | + LICENSE |
| 13 | + NOTICE |
| 14 | + README.md |
| 15 | + context7.json |
| 16 | +EOF |
| 17 | +} |
| 18 | + |
| 19 | +if [[ $# -ne 1 ]]; then |
| 20 | + usage |
| 21 | + exit 1 |
| 22 | +fi |
| 23 | + |
| 24 | +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 25 | +out_dir="$1" |
| 26 | + |
| 27 | +mkdir -p "$out_dir" |
| 28 | +mkdir -p "$out_dir/api-docs" |
| 29 | + |
| 30 | +if [[ ! -d "$repo_root/docs/api-full" ]]; then |
| 31 | + echo "Error: $repo_root/docs/api-full not found" >&2 |
| 32 | + exit 1 |
| 33 | +fi |
| 34 | + |
| 35 | +if [[ ! -f "$repo_root/docs/_processwire_version.json" ]]; then |
| 36 | + echo "Error: $repo_root/docs/_processwire_version.json not found" >&2 |
| 37 | + exit 1 |
| 38 | +fi |
| 39 | + |
| 40 | +find "$out_dir" -mindepth 1 -maxdepth 1 -exec rm -rf {} + |
| 41 | +mkdir -p "$out_dir/api-docs" |
| 42 | + |
| 43 | +cp -R "$repo_root/docs/api-full/." "$out_dir/api-docs/" |
| 44 | +cp "$repo_root/docs/_processwire_version.json" "$out_dir/_processwire_version.json" |
| 45 | +cp "$repo_root/LICENSE" "$out_dir/LICENSE" |
| 46 | +cp "$repo_root/NOTICE.md" "$out_dir/NOTICE" |
| 47 | + |
| 48 | +cat > "$out_dir/README.md" <<'EOF' |
| 49 | +# ProcessWire API Docs (Unofficial) |
| 50 | +
|
| 51 | +Unofficial, auto-generated ProcessWire API documentation in an LLM-friendly Markdown format. |
| 52 | +
|
| 53 | +The docs are generated from ProcessWire source code API docs for the ProcessWire CMS/CMF. |
| 54 | +
|
| 55 | +## Layout |
| 56 | +
|
| 57 | +- `api-docs/`: Full generated API reference (from `docs/api-full`) |
| 58 | +- `_processwire_version.json`: Version and build metadata |
| 59 | +- `LICENSE` |
| 60 | +- `NOTICE` |
| 61 | +EOF |
| 62 | + |
| 63 | +cat > "$out_dir/context7.json" <<'EOF' |
| 64 | +{ |
| 65 | + "$schema": "https://context7.com/schema/context7.json", |
| 66 | + "projectTitle": "ProcessWire API Docs", |
| 67 | + "description": "Unofficial auto-generated ProcessWire API docs in LLM-friendly Markdown format.", |
| 68 | + "folders": [ |
| 69 | + "api-docs" |
| 70 | + ], |
| 71 | + "excludeFiles": [ |
| 72 | + "LICENSE", |
| 73 | + "NOTICE", |
| 74 | + "_processwire_version.json" |
| 75 | + ] |
| 76 | +} |
| 77 | +EOF |
0 commit comments