#!/bin/sh

cp -r docs/helpers tmp_docs_helpers/
rm -rf ./docs

./node_modules/typedoc/bin/typedoc --options typedoc.json src/index.ts
cp -r tmp_docs_helpers docs/helpers
cp -r docs/helpers/* docs/

# The sidebar is a copy of the modules file (which summarises all project files).
# We only keep the links and remove the actual definitions, which will be displayed
# in the main section of the page
sed -n '/^### PolkaBTC Bridge Classes$/,$p' ./docs/modules.md > ./docs/tmp.md
sed -n '/^## Type aliases$/q;p' ./docs/tmp.md > ./docs/_sidebar.md
rm ./docs/tmp.md
rm -rf tmp_docs_helpers