1# Copyright 2023 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15load("@docs-pypi//:requirements.bzl", "requirement") 16load("@rules_python//python:pip.bzl", "compile_pip_requirements") 17load("@rules_python//python:py_binary.bzl", "py_binary") 18 19package( 20 default_applicable_licenses = ["//:package_license"], 21) 22 23sh_binary( 24 name = "run_sphinx_build", 25 srcs = ["run_sphinx_build.sh"], 26 args = [ 27 "$(rootpath :sphinx_build)", 28 "$(rootpath :crossrefs.md)", 29 "$(rootpaths //docgen:docs)", 30 ], 31 data = [ 32 "crossrefs.md", 33 ":sphinx_build", 34 ":sphinx_sources", 35 "//docgen:docs", 36 ], 37) 38 39py_binary( 40 name = "sphinx_build", 41 srcs = ["sphinx_build.py"], 42 deps = [ 43 requirement("sphinx"), 44 requirement("sphinx_rtd_theme"), 45 requirement("myst_parser"), 46 ], 47) 48 49# Run bazel run //docs:requirements.update 50compile_pip_requirements( 51 name = "requirements", 52 requirements_in = "requirements.in", 53 requirements_txt = "requirements.txt", 54 # The requirements output differs on Windows, so just restrict it to Linux. 55 # The build process is only run on, and only works for, Linux anyways. 56 target_compatible_with = ["@platforms//os:linux"], 57) 58 59filegroup( 60 name = "sphinx_sources", 61 srcs = [ 62 # This isn't generated like the other files under the api directory, 63 # but it can't go in the glob because the exclude param will ignore it. 64 "source/api/index.md", 65 ] + glob( 66 [ 67 "**", 68 ], 69 exclude = [ 70 "source/api/**", # These are all generated files 71 "_build/**", 72 ], 73 ), 74) 75