-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilddocs
More file actions
executable file
·64 lines (53 loc) · 1.76 KB
/
builddocs
File metadata and controls
executable file
·64 lines (53 loc) · 1.76 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
set -euo pipefail
# Build or prepare docs across regular repos, worktrees, and bare-parent
# layouts. When run from a docs context, this performs the docs build.
# When run from a project root, it prepares the docs artifact that qb needs
# before a worktree-root Maven build.
find_project_root_for_docs() {
if [[ -f "$PWD/docs/site-playbook.yml" ]]; then
printf '%s\n' "$PWD"
return 0
fi
if [[ -f "$PWD/site-playbook.yml" && -d "$PWD/.." ]]; then
(cd "$PWD/.." && pwd)
return 0
fi
local git_root=""
git_root=$(git rev-parse --show-toplevel 2>/dev/null) || true
if [[ -n "$git_root" && -f "$git_root/docs/site-playbook.yml" ]]; then
printf '%s\n' "$git_root"
return 0
fi
return 1
}
has_symlink_git_dir() {
local root="$1"
[[ -L "$root/.git" ]]
}
project_root=$(find_project_root_for_docs) || {
echo "Error: could not locate project root for docs." >&2
exit 1
}
docs_dir="$project_root/docs"
is_docs_context=false
case "$(cd "$PWD" && pwd)" in
"$docs_dir"|"$docs_dir"/*) is_docs_context=true ;;
esac
# From the project root, only worktrees need special preparation. Regular
# checkouts let the main Maven reactor handle docs directly.
if ! $is_docs_context; then
[[ -d "$docs_dir" ]] || exit 0
if has_symlink_git_dir "$project_root"; then
exec "$HOME/bin/qb-install-docs-artifact" "$project_root" "${MVNFILTER_LEVEL:-3}"
fi
exit 0
fi
# In a worktree docs module, Antora needs the playbook URL rewritten via
# docbuild before Maven runs. Everywhere else the regular docs reactor works.
if has_symlink_git_dir "$project_root"; then
cd "$docs_dir"
exec "$HOME/bin/cxappdev/docbuild" "$@"
fi
cd "$project_root"
exec "$HOME/bin/qb" -pl docs "$@"