forked from margo/specification
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-documentation.bash
More file actions
executable file
·49 lines (41 loc) · 1.18 KB
/
generate-documentation.bash
File metadata and controls
executable file
·49 lines (41 loc) · 1.18 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
set -eu
THIS_SCRIPT="$(readlink -f "${0}")"
THIS_DIR="$(dirname "${THIS_SCRIPT}")"
ROOT_DIR="$(dirname "${THIS_DIR}")"
DOCS_GEN="${THIS_DIR}"
CONFIGS="${DOCS_GEN}/configurations"
if command -v poetry 2>&1 >/dev/null ; then
RUN="poetry run"
else
if ! command -v linkml 2>&1 >/dev/null ; then
echo "The command 'linkml' is missing"
exit 1
fi
if ! command -v mkdocs 2>&1 >/dev/null ; then
echo "The command 'mkdocs' is missing"
exit 1
fi
RUN=""
fi
gen_spec () {
ITEM_REL_PATH=$(jq -r '.root' "${CONFIGS}/$1")
SCHEMA_FILE=$(jq -r '.schemafile' "${CONFIGS}/$1")
MKDOWN_FILE=$(jq -r '.markdowndoc' "${CONFIGS}/$1")
SRC_ROOT="${ROOT_DIR}/${ITEM_REL_PATH}"
SPEC_ROOT="${ROOT_DIR}/system-design${ITEM_REL_PATH#src}"
echo "${SRC_ROOT}"
${RUN} linkml generate doc \
--directory="${SRC_ROOT}/docs" \
--template-directory="${SRC_ROOT}/resources" \
"${SRC_ROOT}/${SCHEMA_FILE}"
mv "${SRC_ROOT}/docs/index.md" "${SPEC_ROOT}/${MKDOWN_FILE}"
rm -r "${SRC_ROOT}/docs"
}
for spec in $(ls "${CONFIGS}") ; do
gen_spec "${spec}"
done
(
cd "${ROOT_DIR}"
${RUN} mkdocs build
)