Skip to content

Commit ad3ecfb

Browse files
committed
docs: extract multiversion javadoc post-build step
Move the multiversion post-build Java selection into a dedicated helper so multiversion.sh only wires sphinx-multiversion. The helper is branch-owned, but it still invokes the checkout-local docs/_utils/javadoc.sh, so historical refs keep their own Maven and docs configuration while using Java 8. Leave API output cleanup in javadoc.sh instead of duplicating it in the multiversion wrapper. Also harden the Javadoc copy step by failing explicitly when the generated API output directory is empty, avoiding a confusing unexpanded glob error.
1 parent fe75777 commit ad3ecfb

3 files changed

Lines changed: 39 additions & 38 deletions

File tree

docs/_utils/javadoc.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ if [[ ! -d "$JAVADOC_SOURCE_DIR" ]]; then
2121
echo "Javadoc output directory was not generated" >&2
2222
exit 1
2323
fi
24+
shopt -s nullglob
25+
JAVADOC_FILES=("$JAVADOC_SOURCE_DIR"/*)
26+
if (( ${#JAVADOC_FILES[@]} == 0 )); then
27+
echo "Javadoc output directory is empty" >&2
28+
exit 1
29+
fi
2430
if [[ -d "$OUTPUT_DIR" ]]; then
2531
rm -r "$OUTPUT_DIR"
2632
fi
2733
mkdir -p "$OUTPUT_DIR"
28-
mv -f "$JAVADOC_SOURCE_DIR"/* "$OUTPUT_DIR"
34+
mv -f "${JAVADOC_FILES[@]}" "$OUTPUT_DIR"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# sphinx-multiversion runs this script from each temporary checkout. This
5+
# branch-owned wrapper only selects the Java runtime; the actual Javadocs are
6+
# still generated by the checkout's own docs/_utils/javadoc.sh so historical
7+
# refs keep their branch-local docs and Maven configuration.
8+
9+
version_name="${SPHINX_MULTIVERSION_NAME:-unknown}"
10+
11+
if [[ "${version_name}" == scylla-* || "${version_name}" == tags/* ]]; then
12+
if [[ -z "${JAVA_HOME_8_X64:-}" ]]; then
13+
echo "JAVA_HOME_8_X64 is required to build historical docs for ${version_name}" >&2
14+
exit 1
15+
fi
16+
17+
export JAVA_HOME="$JAVA_HOME_8_X64"
18+
export PATH="$JAVA_HOME/bin:$PATH"
19+
echo "Using Java 8 for historical docs version ${version_name}"
20+
elif [[ -n "${JAVA_HOME_11_X64:-}" ]]; then
21+
export JAVA_HOME="$JAVA_HOME_11_X64"
22+
export PATH="$JAVA_HOME/bin:$PATH"
23+
echo "Using Java 11 for ${version_name}"
24+
fi
25+
26+
echo "Building Javadocs for ${version_name} with Java:"
27+
java -version
28+
29+
bash -e ./docs/_utils/javadoc.sh

docs/_utils/multiversion.sh

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,9 @@
11
#! /bin/bash
22
set -euo pipefail
33

4-
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
5-
6-
# sphinx-multiversion runs post-build commands from each temporary checkout.
7-
# Keep using that checkout's own docs/_utils/javadoc.sh and Maven config, but
8-
# select the Java runtime here so older refs build with the JDK they expect.
9-
POST_BUILD_JAVADOC='
10-
set -euo pipefail
11-
12-
version_name="${SPHINX_MULTIVERSION_NAME:-unknown}"
13-
14-
if [[ "${version_name}" == scylla-* || "${version_name}" == tags/* ]]; then
15-
if [[ -z "${JAVA_HOME_8_X64:-}" ]]; then
16-
echo "JAVA_HOME_8_X64 is required to build historical docs for ${version_name}" >&2
17-
exit 1
18-
fi
19-
20-
export JAVA_HOME="$JAVA_HOME_8_X64"
21-
export PATH="$JAVA_HOME/bin:$PATH"
22-
echo "Using Java 8 for historical docs version ${version_name}"
23-
elif [[ -n "${JAVA_HOME_11_X64:-}" ]]; then
24-
export JAVA_HOME="$JAVA_HOME_11_X64"
25-
export PATH="$JAVA_HOME/bin:$PATH"
26-
echo "Using Java 11 for ${version_name}"
27-
fi
28-
29-
echo "Building Javadocs for ${version_name} with Java:"
30-
java -version
31-
32-
output_dir="docs/_build/dirhtml/api"
33-
if [[ -n "${SPHINX_MULTIVERSION_OUTPUTDIR:-}" ]]; then
34-
output_dir="${SPHINX_MULTIVERSION_OUTPUTDIR}/api"
35-
fi
36-
rm -rf "$output_dir"
37-
38-
bash -e ./docs/_utils/javadoc.sh
39-
'
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
406

417
cd "$REPO_ROOT" && sphinx-multiversion docs/source docs/_build/dirhtml \
428
--pre-build "bash -c \"(find . -mindepth 2 -name README.md -execdir mv '{}' index.md ';'; find . -mindepth 2 -name README.rst -execdir mv '{}' index.rst ';')\"" \
43-
--post-build "bash -c '$POST_BUILD_JAVADOC'"
9+
--post-build "bash '$SCRIPT_DIR/multiversion-javadoc.sh'"

0 commit comments

Comments
 (0)