Skip to content

Commit 6f8f76e

Browse files
committed
chore: add a custom flag to enable doc extract
1 parent 151d9f8 commit 6f8f76e

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

BUILD

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@rules_license//rules:license.bzl", "license")
2+
load("//rules:common_settings.bzl", "bool_flag")
23
load("//:bzl_library.bzl", "bzl_library")
34

45
package(
@@ -95,3 +96,17 @@ filegroup(
9596
"//toolchains/unittest:distribution",
9697
] + glob(["*.bzl"]),
9798
)
99+
100+
101+
bool_flag(
102+
name = "extract_docs",
103+
build_setting_default = False,
104+
visibility = ["//visibility:public"],
105+
)
106+
107+
config_setting(
108+
name = "extract_docs_flag",
109+
flag_values = {
110+
":extract_docs": "true",
111+
},
112+
)

bzl_library.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ def bzl_library(name, srcs = [], deps = [], **kwargs):
4747
target_compatible_with = [],
4848
**kwargs
4949
)
50-
51-
if hasattr(native, "starlark_doc_extract"):
50+
enable_doc_extract = select({
51+
Label("//:extract_docs_flag"): hasattr(native, "starlark_doc_extract"),
52+
"//conditions:default": False,
53+
})
54+
if enable_doc_extract:
5255
for i, src in enumerate(srcs):
5356
native.starlark_doc_extract(
5457
name = "{}.doc_extract{}".format(name, i if i > 0 else ""),

0 commit comments

Comments
 (0)