Skip to content

Commit 7f77c52

Browse files
committed
[wip][ci] Revise document build pipeline.
- Provide a script to build all document locally. - Integrate with the CI.
1 parent 5799dab commit 7f77c52

6 files changed

Lines changed: 486 additions & 73 deletions

File tree

doc/conf.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ def get_sha(branch: str) -> str | None:
112112

113113
def download_jvm_docs() -> None:
114114
"""Fetch docs for the JVM packages"""
115+
if os.environ.get("XGBOOST_SKIP_JVM_DOCS", None) == "1":
116+
print("Skipping JVM docs (XGBOOST_SKIP_JVM_DOCS=1)")
117+
return
118+
115119
print("Download JVM documents from S3.")
116120
branch = get_branch()
117121
commit = get_sha(branch)
@@ -161,6 +165,10 @@ def try_fetch_jvm_doc(branch: str) -> bool:
161165

162166
def download_r_docs() -> None:
163167
"""Fetch R document from s3."""
168+
if os.environ.get("XGBOOST_SKIP_R_DOCS", None) == "1":
169+
print("Skipping R docs (XGBOOST_SKIP_R_DOCS=1)")
170+
return
171+
164172
branch = get_branch()
165173
commit = get_sha(branch)
166174
print("Download R documents from S3.")
@@ -328,7 +336,10 @@ def is_readthedocs_build():
328336

329337
# List of patterns, relative to source directory, that match files and
330338
# directories to ignore when looking for source files.
331-
exclude_patterns = ["_build"]
339+
# Note: tmp/ contains pre-built HTML docs (R pkgdown, JVM javadocs/scaladocs, C++ doxygen)
340+
# that are copied via html_extra_path. We exclude them from Sphinx processing to avoid
341+
# "document isn't included in any toctree" warnings.
342+
exclude_patterns = ["_build", "tmp"]
332343
html_extra_path = []
333344
if is_readthedocs_build():
334345
html_extra_path = [TMP_DIR]

doc/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
sphinx
22
mock
33
sphinx_rtd_theme>=1.0.0
4+
sphinxcontrib-jquery
45
breathe
56
scikit-learn
67
sh

doc/sphinx_util.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

ops/pipeline/build-jvm-doc.sh

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,32 @@
11
#!/bin/bash
22
## Build docs for the JVM packages and package it in a tarball.
3-
## Note: this script assumes that the user has already built libxgboost4j.so
4-
## and placed it in the lib/ directory.
3+
##
4+
## Prerequisites:
5+
## - libxgboost4j.so must be built and placed in lib/
6+
## - BRANCH_NAME environment variable must be set
7+
##
8+
## This script uses ops/script/build_local_docs.py for the actual build.
59

610
set -euo pipefail
711

812
if [[ -z ${BRANCH_NAME:-} ]]; then
9-
echo "Make sure to define environment variable BRANCH_NAME."
13+
echo "Error: BRANCH_NAME environment variable not set"
1014
exit 1
1115
fi
1216

1317
if [[ ! -f lib/libxgboost4j.so ]]; then
14-
echo "Must place libxgboost4j.so in lib/ first"
18+
echo "Error: lib/libxgboost4j.so not found. Build it first with:"
19+
echo " python3 ops/script/build_local_docs.py jvm-lib"
1520
exit 2
1621
fi
1722

18-
echo "--- Build JVM packages doc"
23+
echo "--- Building JVM documentation ---"
1924
set -x
2025

21-
# Copy in libxgboost4j.so
22-
mkdir -p jvm-packages/xgboost4j/src/main/resources/lib/linux/x86_64/
23-
cp -v lib/libxgboost4j.so jvm-packages/xgboost4j/src/main/resources/lib/linux/x86_64/
26+
python3 ops/script/build_local_docs.py jvm --branch-name "${BRANCH_NAME}"
2427

25-
cd jvm-packages/
26-
# Install JVM packages in local Maven repository
27-
mvn --no-transfer-progress install -Pdocs
28-
# Build Scaladocs
29-
mvn --no-transfer-progress scala:doc -Pdocs
30-
# Build Javadocs
31-
mvn --no-transfer-progress javadoc:javadoc -Pdocs
32-
33-
# Package JVM docs in a tarball
34-
mkdir -p tmp/scaladocs
35-
cp -rv xgboost4j/target/reports/apidocs/ ./tmp/javadocs/
36-
cp -rv xgboost4j/target/site/scaladocs/ ./tmp/scaladocs/xgboost4j/
37-
cp -rv xgboost4j-spark/target/site/scaladocs/ ./tmp/scaladocs/xgboost4j-spark/
38-
cp -rv xgboost4j-spark-gpu/target/site/scaladocs/ ./tmp/scaladocs/xgboost4j-spark-gpu/
39-
cp -rv xgboost4j-flink/target/site/scaladocs/ ./tmp/scaladocs/xgboost4j-flink/
40-
41-
cd tmp
42-
tar cvjf ${BRANCH_NAME}.tar.bz2 javadocs/ scaladocs/
43-
mv ${BRANCH_NAME}.tar.bz2 ..
44-
cd ..
45-
rm -rfv tmp/
28+
# Verify output
29+
[[ -f "jvm-packages/${BRANCH_NAME}.tar.bz2" ]] || {
30+
echo "Error: jvm-packages/${BRANCH_NAME}.tar.bz2 not found"
31+
exit 3
32+
}

ops/pipeline/build-r-docs.sh

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
11
#!/bin/bash
22
## Build docs for the R package and package it in a tarball.
3+
##
4+
## Prerequisites:
5+
## - BRANCH_NAME environment variable must be set
6+
## - R and required packages must be available
7+
##
8+
## This script uses ops/script/build_local_docs.py for the actual build.
39

410
set -euo pipefail
511

612
if [[ -z ${BRANCH_NAME:-} ]]; then
7-
echo "Make sure to define environment variable BRANCH_NAME."
13+
echo "Error: BRANCH_NAME environment variable not set"
814
exit 1
915
fi
1016

11-
if [[ -z "${R_LIBS_USER:-}" ]]; then
12-
export R_LIBS_USER=/tmp/rtmpdir
13-
fi
14-
15-
echo "--- Build R package doc"
17+
# Setup R_LIBS_USER
18+
export R_LIBS_USER="${R_LIBS_USER:-/tmp/rtmpdir}"
1619
echo "R_LIBS_USER: ${R_LIBS_USER}"
17-
set -x
1820

19-
if [[ ! -d ${R_LIBS_USER} ]]; then
20-
echo "Make ${R_LIBS_USER} for installing temporary R packages."
21-
mkdir ${R_LIBS_USER}
22-
fi
21+
mkdir -p "${R_LIBS_USER}"
2322

24-
# Used only in container environment
25-
if command -v gosu 2>&1 >/dev/null; then
26-
gosu root chown -R $UID:$GROUPS ${R_LIBS_USER}
23+
# Container environment: fix permissions
24+
if command -v gosu &>/dev/null; then
25+
gosu root chown -R "$UID:$GROUPS" "${R_LIBS_USER}"
2726
fi
2827

29-
cd R-package
30-
31-
MAKEFLAGS=-j$(nproc) Rscript ./tests/helper_scripts/install_deps.R
32-
# Some examples are failing
33-
MAKEFLAGS=-j$(nproc) Rscript -e "pkgdown::build_site(examples=FALSE)"
34-
# Install the package for vignettes
35-
MAKEFLAGS=-j$(nproc) R CMD INSTALL .
36-
37-
cd -
38-
39-
cd doc/R-package
40-
make -j$(nproc) all
28+
echo "--- Building R documentation ---"
29+
set -x
4130

42-
cd ../../ # back to project root
31+
python3 ops/script/build_local_docs.py r \
32+
--branch-name "${BRANCH_NAME}" \
33+
--r-libs-user "${R_LIBS_USER}"
4334

44-
tar cvjf r-docs-${BRANCH_NAME}.tar.bz2 R-package/docs doc/R-package/xgboost_introduction.md doc/R-package/xgboostfromJSON.md
35+
# Verify output
36+
[[ -f "r-docs-${BRANCH_NAME}.tar.bz2" ]] || {
37+
echo "Error: r-docs-${BRANCH_NAME}.tar.bz2 not found"
38+
exit 3
39+
}

0 commit comments

Comments
 (0)