blob: 71bc1f3d7985757cf021f03cfb684b04fb0b84c2 [file]
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_python//python:py_test.bzl", "py_test")
load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
load(":defs.bzl", "gen_directory")
# We only build for Linux and Mac because:
# 1. The actual doc process only runs on Linux
# 2. Mac is a common development platform, and is close enough to Linux
# it's feasible to make work.
# Making CI happy under Windows is too much of a headache, though, so we don't
# bother with that.
_TARGET_COMPATIBLE_WITH = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"//conditions:default": ["@platforms//:incompatible"],
})
sphinx_docs(
name = "docs",
srcs = glob(["*.md"]) + [
":generated_directory",
],
config = "conf.py",
formats = ["html"],
renamed_srcs = {
":gen_binary_asset": "binary_asset.bin",
},
sphinx = ":sphinx-build",
strip_prefix = package_name() + "/",
target_compatible_with = _TARGET_COMPATIBLE_WITH,
)
genrule(
name = "gen_binary_asset",
outs = ["binary_asset.bin"],
cmd = "printf '\\x00\\xff\\xfe\\xfd\\x80\\x90\\x00\\x01\\x02\\x03\\x04' > $@",
)
gen_directory(
name = "generated_directory",
)
sphinx_build_binary(
name = "sphinx-build",
tags = ["manual"], # Only needed as part of sphinx doc building
deps = [
"@pypi//myst_parser",
"@pypi//sphinx",
],
)
build_test(
name = "docs_build_test",
targets = [":docs"],
)
py_test(
name = "sphinx_docs_output_test",
srcs = ["sphinx_docs_output_test.py"],
data = [":docs"],
deps = ["@pypi//absl_py"],
)