feat: add github action to generate typedoc json automatically

This commit is contained in:
Kbscript
2025-02-13 16:39:02 +08:00
parent 24d25898bf
commit ff38b2b999
3 changed files with 70 additions and 8 deletions

View File

@@ -4,20 +4,19 @@ set -euo pipefail
# generate declaration files via typedoc
ENGINE_PATH="$(pwd)"
TYPEDOC="typedoc@0.23.28"
# Set default output directory if not provided
OUTPUT_DIR=${1:-./api}
# Validate required environment variable
if [ -z "${TYPEDOC:-}" ]; then
echo "Error: TYPEDOC environment variable is not set" >&2
exit 1
fi
for directory in ${ENGINE_PATH}/packages/*
do
if [ -d $directory ]; then
bn=`basename $directory`;
echo "typedoc compiling $directory"
npx $TYPEDOC --version
npx $TYPEDOC --json api/$bn.json --tsconfig $directory/tsconfig.json $directory/src/index.ts;
SUCCESS+=("api/$bn.json")
npx $TYPEDOC --json ${OUTPUT_DIR}/$bn.json --tsconfig $directory/tsconfig.json $directory/src/index.ts;
SUCCESS+=("${OUTPUT_DIR}/$bn.json")
fi
done