#!/bin/bash

echo "Using API Extractor to generate mappings for Netscript API definitions..."
npx api-extractor run

echo ""
echo "Creating markdown from Netscript API mappings..."
npx api-documenter markdown

echo ""
echo "Running cleanup tasks..."
rm input/bitburner.api.json && rm -r input

echo ""
echo "Bundling ingame documentation..."
node tools/bundle-doc/index.mjs

echo ""
echo "Add generated docs to git..."
# This git add is needed due to documenter using wrong line endings. Console spam discarded.
git add markdown/ 2> /dev/null && git add tsdoc-metadata.json 2> /dev/null

echo ""
echo "Generate math notation output..."
node tools/bundle-doc/generate-math-notation-output.mjs

echo ""
echo "Documentation build completed."
