/ docs / api_reference / build-tsdoc.sh
build-tsdoc.sh
 1  #!/usr/bin/env bash
 2  
 3  set -ex
 4  
 5  # Function to build TypeDoc for a package
 6  build_tsdoc() {
 7      local package_path=$1
 8      local package_name=$2
 9      local output_path=$3
10  
11      echo "Building TypeDoc for $package_name..."
12  
13      # Store the absolute path to the analytics file before changing directories
14      local analytics_js_path="$(cd "$(dirname "$0")" && pwd)/typedoc-analytics.js"
15  
16      pushd "$package_path"
17  
18      # Generate TypeDoc documentation
19      npm exec -- typedoc \
20          --out "$output_path" \
21          --name "$package_name" \
22          --readme README.md \
23          --tsconfig tsconfig.json \
24          --excludePrivate \
25          --excludeProtected \
26          --excludeExternals \
27          --includeVersion \
28          --searchInComments \
29          --navigation \
30          --excludeNotDocumented false \
31          --customJs "$analytics_js_path" \
32          src/index.ts
33  
34      popd
35  }
36  
37  # Base paths
38  TYPESCRIPT_BASE="../../libs/typescript"
39  DOCS_OUTPUT_BASE="build/html/typescript_api"
40  
41  # First ensure dependencies are installed at workspace root
42  echo "Ensuring TypeScript workspace dependencies are installed..."
43  pushd "$TYPESCRIPT_BASE"
44  npm ci
45  popd
46  
47  # Remove existing docs if they exist
48  rm -rf "$DOCS_OUTPUT_BASE"
49  # Create output directory
50  mkdir -p "$DOCS_OUTPUT_BASE"
51  
52  # Build documentation for @mlflow/core
53  build_tsdoc \
54      "$TYPESCRIPT_BASE/core" \
55      "@mlflow/core" \
56      "$(pwd)/$DOCS_OUTPUT_BASE/mlflow-core"
57  
58  # Build documentation for @mlflow/openai
59  build_tsdoc \
60      "$TYPESCRIPT_BASE/integrations/openai" \
61      "@mlflow/openai" \
62      "$(pwd)/$DOCS_OUTPUT_BASE/mlflow-openai"
63  
64  # Copy the HTML template to create index.html
65  cp "$(dirname "$0")/tsdoc.index.html.template" "$DOCS_OUTPUT_BASE/index.html"
66  
67  echo "Copied TypeScript documentation into docs/build/html/typescript_api/"