-
Notifications
You must be signed in to change notification settings - Fork 196
/
document.sh
executable file
·26 lines (20 loc) · 741 Bytes
/
document.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash
#
# Generates API docs and updates the README TOC
set -e
set -o pipefail
echo Generating new API docs
npx typedoc src/index.ts
# Link back to README at the top; the -i.bak and rm is to support both Mac & Linux.
# See https://stackoverflow.com/a/22084103/1464495
sed -i.bak "s/^@openmrs\/$1$/[Back to README.md](..\/README.md)/" "docs/API.md"
rm docs/API.md.bak
# Delete everything up to the functions in the index file
start=$(grep -n -m 1 Enumerations docs/API.md | cut -f1 -d:)
end=$(grep -n -m 1 Functions docs/API.md | cut -f1 -d:)
sed -i.bak "${start},$(expr ${end} - 1)d" docs/API.md
rm docs/API.md.bak
if grep -q tocstop README.md; then
echo Generating TOC
npx markdown-toc -i --maxdepth 2 README.md
fi