feat: allow additional common args to be passed to update_docs

This commit is contained in:
Derek Cormier 2023-02-18 20:09:27 -08:00
parent 23eb184493
commit 83fb3050c2
5 changed files with 28 additions and 4 deletions

3
docs/docs.md generated
View File

@ -30,7 +30,7 @@ This is helpful for minimizing boilerplate in repos wih lots of stardoc targets.
## update_docs
<pre>
update_docs(<a href="#update_docs-name">name</a>)
update_docs(<a href="#update_docs-name">name</a>, <a href="#update_docs-kwargs">kwargs</a>)
</pre>
Stamps an executable run for writing all stardocs declared with stardoc_with_diff_test to the source tree.
@ -55,5 +55,6 @@ bazel build //docs/... && bazel test //docs/... && bazel run //docs:update
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="update_docs-name"></a>name | the name of executable target | <code>"update"</code> |
| <a id="update_docs-kwargs"></a>kwargs | Other common named parameters such as <code>tags</code> or <code>visibility</code> | none |

View File

@ -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",
@ -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,
)

View File

@ -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")

View File

@ -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)
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 = {})},
)

View File

@ -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
@ -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 = {}
@ -60,4 +61,5 @@ def update_docs(name = "update"):
write_source_files(
name = name,
files = update_files,
**kwargs
)