Files
kumomta/docs/build.sh
T
Wez Furlong d416b31af9 docs: add toml_data macro
This macro allows embedding TOML data into the docs,
and showing it in a tab that has both the TOML and JSON
representation of that data.

It works by executing the toml2jsonc helper that was added
in an earlier commit.

There's some machinery here to compile that utility to run
in the context of the mkdocs docker image; that works
locally, let's see how well it works in CI!

Usage is simple; before:

```toml
["something"]
foo = "bar"
```

after:

{% call toml_data() %}
["something"]
foo = "bar"
{% endcall %}

The first page to get switched over to this is https://docs.kumomta.com/tutorial/configuring_kumomta/

refs: https://github.com/KumoCorp/kumomta/issues/212
2024-07-03 14:59:52 -07:00

75 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
set -e
set -x
CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-${PWD}/target}
SERVE=no
if [ "$1" == "serve" ] ; then
SERVE=yes
fi
tracked_markdown=$(mktemp)
trap "rm ${tracked_markdown}" "EXIT"
find docs -type f | egrep '\.(markdown|md)$' > $tracked_markdown
cargo_deps="gelatyx"
for doc_dep in $cargo_deps ; do
if ! hash $doc_dep 2>/dev/null ; then
cargo install $doc_dep --locked
fi
done
if test -z "${CHECK_ONLY}" ; then
gelatyx --language lua --file-list $tracked_markdown --language-config stylua.toml
fi
if ! gelatyx --language lua --color always --file-list $tracked_markdown --language-config stylua.toml --check ; then
echo
echo "Be sure to run ./docs/build.sh to apply formatting before you push changes."
echo
exit 1
fi
if test -x ${CARGO_TARGET_DIR}/debug/kumod ; then
./docs/update-openapi.sh
fi
if test -x ${CARGO_TARGET_DIR}/debug/kcli ; then
${CARGO_TARGET_DIR}/debug/kcli markdown-help
fi
# https://github.com/rust-lang/cargo/issues/2025
# Document only our own crates
# TODO: consider using:
# <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#rustdoc-map>
cargo tree --depth 0 -e normal --prefix none | \
cut -d' ' -f1 | sort -u | xargs printf -- '-p %s\n' | \
xargs cargo doc --no-deps --locked --lib
if [ "$CI" == true ] ; then
rm docs/rustapi
ln -sf ${CARGO_TARGET_DIR}/doc docs/rustapi
fi
python3 docs/generate-toc.py || exit 1
# Adjust path to pick up pip-installed binaries
PATH="$HOME/.local/bin;$PATH"
# Keep the toc generator formatted
if hash black 2>/dev/null ; then
black docs/generate-toc.py
fi
if [ "$CI" == true ] ; then
exit 0
fi
docker build -t kumomta/mkdocs-material --pull -f docs/Dockerfile .
if [ "$SERVE" == "yes" ] ; then
docker run --rm -it --network=host -v ${PWD}:/docs kumomta/mkdocs-material serve
else
docker run --rm -e CARDS=${CARDS} -v ${PWD}:/docs kumomta/mkdocs-material build
fi