2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-25 11:32:33 +00:00
bazel-lib/docs/BUILD.bazel
2021-11-08 06:20:26 -08:00

54 lines
1.2 KiB
Python

# These loads are in the docs/ package rather than anything users depend on
# so that the dependency on stardoc doesn't leak to them.
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")
# Dictionary mapping from the label of a starlark module
# (like //mylang:some.bzl) to the markdown file in this
# folder where the API docs are written.
_DOCS = {
"//mylang:defs.bzl": "rules.md",
}
[
stardoc(
name = md + "_gen",
out = md + "_",
input = tgt,
deps = [tgt.replace(".bzl", "")],
)
for [
tgt,
md,
] in _DOCS.items()
]
[
diff_test(
name = "check_" + md,
failure_message = "Run bazel run //docs:update",
file1 = md,
file2 = md + "_",
)
for md in _DOCS.values()
]
write_file(
name = "gen_update",
out = "update.sh",
content = [
"#!/usr/bin/env bash",
"cd $BUILD_WORKSPACE_DIRECTORY",
] + [
"cp -fv bazel-bin/docs/{0}_ docs/{0}".format(md)
for md in _DOCS.values()
],
)
sh_binary(
name = "update",
srcs = ["update.sh"],
data = [md + "_" for md in _DOCS.values()],
)