Skip to content

Commit 0ed66f8

Browse files
committed
add docs for features.bzl
1 parent 01be3e2 commit 0ed66f8

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

docs/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ sphinx_stardocs(
8181
name = "bzl_api_docs",
8282
srcs = [
8383
"//python:defs_bzl",
84+
"//python:features_bzl",
8485
"//python:packaging_bzl",
8586
"//python:pip_bzl",
8687
"//python:py_binary_bzl",

python/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ bzl_library(
7979
bzl_library(
8080
name = "features_bzl",
8181
srcs = ["features.bzl"],
82+
deps = [
83+
"@rules_python_internal//:rules_python_config_bzl",
84+
],
8285
)
8386

8487
bzl_library(

python/features.bzl

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,48 @@ load("@rules_python_internal//:rules_python_config.bzl", "config")
1919
# See https://git-scm.com/docs/git-archive/2.29.0#Documentation/git-archive.txt-export-subst
2020
_VERSION_PRIVATE = "$Format:%(describe:tags=true)$"
2121

22+
def _features_typedef():
23+
"""Information about features rules_python has implemented.
24+
25+
::::{field} precompile
26+
:type: bool
27+
28+
True if the precompile attributes are available.
29+
:::{versionadded} TODO
30+
:::
31+
::::
32+
33+
::::{field} site_packages_root_attr
34+
:type: bool
35+
36+
True if the {obj}`site_packages_root` attribute is available.
37+
38+
:::{versionadded} VERSION_NEXT_FEATURE
39+
:::
40+
::::
41+
42+
::::{field} uses_builtin_rules
43+
:type: bool
44+
45+
True if the rules are using the Bazel-builtin implementation.
46+
47+
:::{versionadded} TODO
48+
:::
49+
::::
50+
51+
::::{field} version
52+
:type: str
53+
54+
The rules_python version. This is a semver format, e.g. `X.Y.Z` with
55+
optional trailing `-rcN`. For unreleased versions, it is an empty string.
56+
:::{versionadded} TODO
57+
::::
58+
"""
59+
2260
features = struct(
23-
version = _VERSION_PRIVATE if "$Format" not in _VERSION_PRIVATE else "",
61+
TYPEDEF = _features_typedef,
2462
precompile = True,
25-
uses_builtin_rules = not config.enable_pystar,
2663
site_packages_root_attr = True,
64+
uses_builtin_rules = not config.enable_pystar,
65+
version = _VERSION_PRIVATE if "$Format" not in _VERSION_PRIVATE else "",
2766
)

0 commit comments

Comments
 (0)