2021-01-22 14:25:49 +00:00
|
|
|
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
2021-02-02 20:09:33 +00:00
|
|
|
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
|
2021-01-22 14:25:49 +00:00
|
|
|
|
2021-01-24 23:23:19 +00:00
|
|
|
genrule(
|
|
|
|
name = "flatten_header_vm",
|
|
|
|
srcs = [
|
|
|
|
"gen_header.sh",
|
|
|
|
"docs.bzl",
|
|
|
|
],
|
|
|
|
outs = ["flatten_header.vm"],
|
|
|
|
cmd = "$(location gen_header.sh) $(location docs.bzl) $@",
|
|
|
|
output_to_bindir = True,
|
|
|
|
)
|
|
|
|
|
2021-01-22 14:25:49 +00:00
|
|
|
stardoc(
|
|
|
|
name = "docs",
|
|
|
|
out = "docs.md",
|
2021-01-24 23:23:19 +00:00
|
|
|
header_template = ":flatten_header_vm",
|
2021-01-22 14:25:49 +00:00
|
|
|
input = "docs.bzl",
|
|
|
|
deps = ["@rules_foreign_cc//:bzl_srcs"],
|
|
|
|
)
|
|
|
|
|
|
|
|
build_test(
|
|
|
|
name = "docs_build_test",
|
|
|
|
targets = [
|
|
|
|
":docs",
|
|
|
|
],
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
|
|
|
genrule(
|
|
|
|
name = "generate_docs_src",
|
|
|
|
srcs = [":docs"],
|
|
|
|
outs = ["generate_docs.sh"],
|
|
|
|
cmd = """cat << EOF > $@
|
|
|
|
#!/bin/bash
|
2021-03-20 20:11:57 +00:00
|
|
|
set -euo pipefail
|
2021-01-24 23:23:19 +00:00
|
|
|
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/README.md
|
2021-03-20 20:11:57 +00:00
|
|
|
EOF
|
2021-01-22 14:25:49 +00:00
|
|
|
""",
|
|
|
|
)
|
|
|
|
|
|
|
|
sh_binary(
|
|
|
|
name = "generate_docs",
|
|
|
|
srcs = [":generate_docs_src"],
|
|
|
|
data = [":docs"],
|
|
|
|
)
|
2021-03-20 20:11:57 +00:00
|
|
|
|
|
|
|
sh_binary(
|
|
|
|
name = "test_docs",
|
|
|
|
srcs = ["test_docs.sh"]
|
|
|
|
)
|