Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions py/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("@rules_python//python:packaging.bzl", "py_package", "py_wheel")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@rules_python//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary")
load("//common:defs.bzl", "copy_file")
load("//py:defs.bzl", "generate_devtools", "generate_devtools_latest", "py_test_suite")
load("//py/private:browsers.bzl", "BROWSERS")
load("//py/private:generate_bidi.bzl", "generate_bidi")
load("//py/private:import.bzl", "py_import")
load("//py/private:sphinx_docs.bzl", "sphinx_docs")

exports_files(
["pyproject.toml"],
Expand Down Expand Up @@ -911,20 +912,20 @@ py_binary(
],
)

sphinx_build_binary(
py_console_script_binary(
name = "sphinx-build",
pkg = "@py_dev_requirements//sphinx",
script = "sphinx-build",
deps = [
":selenium",
requirement("sphinx"),
requirement("sphinx-material"),
],
)

sphinx_docs(
name = "docs",
srcs = glob(["docs/source/**/*.rst"]) + ["docs/source/conf.py"],
srcs = glob(["docs/source/**/*.rst"]),
config = "docs/source/conf.py",
formats = ["html"],
sphinx = ":sphinx-build",
)

Expand Down
46 changes: 46 additions & 0 deletions py/private/sphinx_docs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Bazel rule for building Sphinx HTML documentation."""

def _sphinx_docs_impl(ctx):
html_dir = ctx.actions.declare_directory(ctx.label.name + "/_build/html")
doctrees_dir = ctx.actions.declare_directory(ctx.label.name + "/_build/doctrees")

config_dir = ctx.file.config.dirname

args = ctx.actions.args()
args.add("-b", "html")
args.add("-d", doctrees_dir.path)
args.add(config_dir)
args.add(html_dir.path)

ctx.actions.run(
inputs = ctx.files.srcs + [ctx.file.config],
outputs = [html_dir, doctrees_dir],
executable = ctx.executable.sphinx,
arguments = [args],
mnemonic = "SphinxBuild",
progress_message = "Building Sphinx HTML docs for %{label}",
)

return [DefaultInfo(files = depset([html_dir]))]

sphinx_docs = rule(
implementation = _sphinx_docs_impl,
attrs = {
"config": attr.label(
allow_single_file = True,
mandatory = True,
doc = "Sphinx configuration file (conf.py)",
),
"sphinx": attr.label(
executable = True,
cfg = "exec",
mandatory = True,
doc = "Sphinx build binary",
),
"srcs": attr.label_list(
allow_files = True,
doc = "Source files for the documentation build",
),
},
doc = "Builds Sphinx HTML documentation into a tree artifact at <name>/_build/html.",
)
Loading