Skip to content

Commit

Permalink
Bazel DocGen: Add target for generating all reference docs at once.
Browse files Browse the repository at this point in the history
I tested this changed manually in the git repo.

PiperOrigin-RevId: 439539890
  • Loading branch information
fweikert authored and copybara-github committed Apr 5, 2022
1 parent 1e146e4 commit ab77bd5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/main/java/com/google/devtools/build/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,26 @@ genrule(
tools = ["//src/main/java/com/google/devtools/build/docgen:skydoc_bin"],
visibility = ["//site:__pkg__"],
)

genrule(
name = "gen_reference_docs",
srcs = [
":build-encyclopedia.zip",
":command-line-reference.html",
":skylark-library.zip",
"//tools/build_defs/repo:doc",
],
outs = ["reference-docs.zip"],
cmd = "mkdir -p $(@D)/gen_docs/reference/be && " +
"cp $(location :command-line-reference.html) $(@D)/gen_docs/reference/ && " +
"unzip -q -d $(@D)/gen_docs/reference/be/ $(location :build-encyclopedia.zip) && " +
"mkdir -p $(@D)/gen_docs/rules/lib/repo && " +
"unzip -q -d $(@D)/gen_docs/rules/lib/ $(location :skylark-library.zip) && " +
"tar -xf $(location //tools/build_defs/repo:doc) -C $(@D)/gen_docs/rules/lib/repo/ && " +
# Ugly hack: we want to preserve paths relative to gen_docs/,
# which means we have to temporarily cd into that directory and zip with -r.
"pushd $(@D)/gen_docs && " +
"zip -qr tmp.zip . && " +
"popd && mv $(@D)/gen_docs/tmp.zip $@",
visibility = ["//scripts/docs:__pkg__"],
)
5 changes: 4 additions & 1 deletion tools/build_defs/repo/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,8 @@ pkg_tar(
name = "doc",
srcs = ["%s_md" % (name,) for name in REPO_BZL_FILES] + ["index.md"],
strip_prefix = "/tools/build_defs/repo",
visibility = ["//site:__subpackages__"],
visibility = [
"//site:__subpackages__",
"//src/main/java/com/google/devtools/build/lib:__pkg__",
],
)

0 comments on commit ab77bd5

Please sign in to comment.