1load("@bazel_skylib//rules:build_test.bzl", "build_test") 2load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility 3load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs") 4load(":defs.bzl", "gen_directory") 5 6# We only build for Linux and Mac because: 7# 1. The actual doc process only runs on Linux 8# 2. Mac is a common development platform, and is close enough to Linux 9# it's feasible to make work. 10# Making CI happy under Windows is too much of a headache, though, so we don't 11# bother with that. 12_TARGET_COMPATIBLE_WITH = select({ 13 "@platforms//os:linux": [], 14 "@platforms//os:macos": [], 15 "//conditions:default": ["@platforms//:incompatible"], 16}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"] 17 18sphinx_docs( 19 name = "docs", 20 srcs = glob(["*.md"]) + [ 21 ":generated_directory", 22 ], 23 config = "conf.py", 24 formats = ["html"], 25 sphinx = ":sphinx-build", 26 target_compatible_with = _TARGET_COMPATIBLE_WITH, 27) 28 29gen_directory( 30 name = "generated_directory", 31) 32 33sphinx_build_binary( 34 name = "sphinx-build", 35 tags = ["manual"], # Only needed as part of sphinx doc building 36 deps = [ 37 "@dev_pip//myst_parser", 38 "@dev_pip//sphinx", 39 ], 40) 41 42build_test( 43 name = "build_tests", 44 targets = [":docs"], 45) 46