-
Notifications
You must be signed in to change notification settings - Fork 38
/
BUILD
82 lines (75 loc) · 1.88 KB
/
BUILD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
_DOC_SRCS = {
"rules": [
"apple_genrule",
"toolchain_substitution",
"universal_binary",
],
}
write_file(
name = "rules_header",
out = "rules_header.vm",
content = [
"<!-- Generated with Stardoc, Do Not Edit! -->",
"",
"${moduleDocstring}",
"On this page:",
"",
] + [" * [{0}](#{0})".format(r) for r in _DOC_SRCS["rules"]] + [
"",
],
)
[
stardoc(
name = file + "_doc",
out = file + ".md_pre",
header_template = file + "_header.vm",
input = "//rules:rules.doc.bzl",
symbol_names = symbols,
tags = ["no-sandbox"], # https://github.com/bazelbuild/stardoc/issues/112
deps = ["//rules"],
)
for [
file,
symbols,
] in _DOC_SRCS.items()
]
[
genrule(
name = "fix_stardoc_" + file,
srcs = [file + ".md_pre"],
outs = [file + ".md_"],
cmd = "sed '/rules.doc.bzl/,+1d' $(SRCS) > $(OUTS)",
)
for file in _DOC_SRCS.keys()
]
[
diff_test(
name = "test_" + file,
failure_message = "\nPlease update the docs by running\n bazel run //doc:update",
file1 = file + ".md_",
file2 = file + ".md",
)
for file in _DOC_SRCS.keys()
]
write_file(
name = "gen_update",
out = "update.sh",
content = [
"#!/usr/bin/env bash",
"cd $BUILD_WORKSPACE_DIRECTORY",
] + [
"cp -fv bazel-bin/doc/{0}.md_ doc/{0}.md".format(
file,
)
for file in _DOC_SRCS.keys()
],
)
sh_binary(
name = "update",
srcs = ["update.sh"],
data = [file + ".md_" for file in _DOC_SRCS.keys()],
)