xref: /aosp_15_r20/external/bazelbuild-rules_python/sphinxdocs/docs/BUILD.bazel (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER")  # buildifier: disable=bzl-visibility
2load("//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
3load("//sphinxdocs:sphinx_stardoc.bzl", "sphinx_stardocs")
4
5package(default_visibility = ["//:__subpackages__"])
6
7# We only build for Linux and Mac because:
8# 1. The actual doc process only runs on Linux
9# 2. Mac is a common development platform, and is close enough to Linux
10#    it's feasible to make work.
11# Making CI happy under Windows is too much of a headache, though, so we don't
12# bother with that.
13_TARGET_COMPATIBLE_WITH = select({
14    "@platforms//os:linux": [],
15    "@platforms//os:macos": [],
16    "//conditions:default": ["@platforms//:incompatible"],
17}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
18
19sphinx_docs_library(
20    name = "docs_lib",
21    deps = [
22        ":artisian_api_docs",
23        ":bzl_docs",
24        ":py_api_srcs",
25        ":regular_docs",
26    ],
27)
28
29sphinx_docs_library(
30    name = "regular_docs",
31    srcs = glob(
32        ["**/*.md"],
33        exclude = ["api/**"],
34    ),
35    prefix = "sphinxdocs/",
36)
37
38sphinx_docs_library(
39    name = "artisian_api_docs",
40    srcs = glob(
41        ["api/**/*.md"],
42    ),
43    prefix = "api/sphinxdocs/",
44    strip_prefix = "sphinxdocs/docs/api/",
45)
46
47sphinx_stardocs(
48    name = "bzl_docs",
49    srcs = [
50        "//sphinxdocs:readthedocs_bzl",
51        "//sphinxdocs:sphinx_bzl",
52        "//sphinxdocs:sphinx_docs_library_bzl",
53        "//sphinxdocs:sphinx_stardoc_bzl",
54        "//sphinxdocs/private:sphinx_docs_library_bzl",
55    ],
56    prefix = "api/sphinxdocs/",
57    target_compatible_with = _TARGET_COMPATIBLE_WITH,
58)
59
60sphinx_docs_library(
61    name = "py_api_srcs",
62    srcs = ["//sphinxdocs/src/sphinx_bzl"],
63    strip_prefix = "sphinxdocs/src/",
64)
65