"""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") # gazelle:ignore _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(), )