Skip to content

Commit

Permalink
feat: allow additional common args to be passed to update_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide committed Feb 20, 2023
1 parent 677a1b8 commit b1822c4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/docs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions e2e/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test")
load("@aspect_bazel_lib//lib:jq.bzl", "jq")
load("@aspect_bazel_lib//lib:yq.bzl", "yq")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@aspect_bazel_lib_host//:defs.bzl", "host")

bzl_library(
name = "defs",
Expand Down Expand Up @@ -86,3 +87,9 @@ diff_test(
# Source directories are not support on remote execution.
tags = ["no-remote-exec"],
)

genrule(
name = "host_bazel_version",
outs = ["host_bazel_version.txt"],
cmd = "echo '%s' > $@" % host.bazel_version,
)
6 changes: 6 additions & 0 deletions e2e/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ local_path_override(
module_name = "aspect_bazel_lib",
path = "../..",
)

ext = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "ext")

ext.host()

use_repo(ext, "aspect_bazel_lib_host")
12 changes: 10 additions & 2 deletions lib/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ load(
)
load("//lib/private:host_repo.bzl", "host_repo")

def _toolchain_extension(_):
def _toolchain_extension(mctx):
register_copy_directory_toolchains(register = False)
register_copy_to_directory_toolchains(register = False)
register_jq_toolchains(register = False)
register_yq_toolchains(register = False)
host_repo(name = "aspect_bazel_lib_host")

create_host_repo = False
for module in mctx.modules:
if len(module.tags.host) > 0:
create_host_repo = True

if create_host_repo:
host_repo(name = "aspect_bazel_lib_host")

# TODO: some way for users to control repo name/version of the tools installed
ext = module_extension(
implementation = _toolchain_extension,
tag_classes = {"host": tag_class(attrs = {})},
)
4 changes: 3 additions & 1 deletion lib/private/docs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def stardoc_with_diff_test(
**kwargs
)

def update_docs(name = "update"):
def update_docs(name = "update", **kwargs):
"""Stamps an executable run for writing all stardocs declared with stardoc_with_diff_test to the source tree.
This is to be used in tandem with `stardoc_with_diff_test()` to produce a convenient workflow
Expand All @@ -45,6 +45,7 @@ def update_docs(name = "update"):
Args:
name: the name of executable target
**kwargs: Other common named parameters such as `tags` or `visibility`
"""

update_files = {}
Expand All @@ -60,4 +61,5 @@ def update_docs(name = "update"):
write_source_files(
name = name,
files = update_files,
**kwargs
)

0 comments on commit b1822c4

Please sign in to comment.