/
BUILD.bazel
55 lines (49 loc) · 1.39 KB
/
BUILD.bazel
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
"""Documentation generation with stardoc
This is in a separate package from both the stardoc source files and the
resulting documentation markdown files, to prevent users trying to load()
the stardoc repository, which is not a dependency users should install.
"""
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
_DOC_SRCS = {
"//internal:repository_docs": "repository.md",
"//internal:extend_docs": "extend.md",
}
[
stardoc(
name = out.replace(".md", "_docgen"),
out = out,
# Convention: foo.bzl has bzl_library named "foo"
input = input + ".bzl",
deps = [input],
)
for [input, out] in _DOC_SRCS.items()
]
[
diff_test(
name = "check_" + out,
failure_message = "Please run bazel run //docs:update",
# source file (InputArtifact)
file1 = "//:" + out,
# result from stardoc rule above
file2 = out,
)
for out in _DOC_SRCS.values()
]
write_file(
name = "gen_update",
out = "update.sh",
content = [
"#!/usr/bin/env bash",
"cd $BUILD_WORKSPACE_DIRECTORY",
] + [
"cp -fv bazel-bin/docs/{0} {0}".format(v)
for v in _DOC_SRCS.values()
],
)
sh_binary(
name = "update",
srcs = ["update.sh"],
data = _DOC_SRCS.values(),
)