diff options
author | Yifan Hong <elsk@google.com> | 2021-12-22 15:56:40 -0800 |
---|---|---|
committer | Yifan Hong <elsk@google.com> | 2021-12-22 16:22:20 -0800 |
commit | ea0fb21069e4b2f4e826517955801c03c3bcb7d9 (patch) | |
tree | 901d5d674f60cf8ef925e148207d81325a09ad3e | |
parent | 70eb805b4f1531a74f1e678f1c1593a0dc200835 (diff) | |
download | bazel_common_rules-ea0fb21069e4b2f4e826517955801c03c3bcb7d9.tar.gz |
Use None as default arguments.
As per
https://docs.bazel.build/versions/main/skylark/macros.html#conventions
Default values for macros should be None.
Test: TH
Bug: 209506769
Change-Id: Ia8d8889cec8e7699b3177c3d479d145fc08c8a21
-rw-r--r-- | dist/dist.bzl | 7 | ||||
-rw-r--r-- | docs/docs.bzl | 22 |
2 files changed, 21 insertions, 8 deletions
diff --git a/dist/dist.bzl b/dist/dist.bzl index ea50148..46aa6e5 100644 --- a/dist/dist.bzl +++ b/dist/dist.bzl @@ -39,7 +39,6 @@ _generate_dist_manifest = rule( doc = """Generate a manifest of files to be dist to a directory.""", attrs = { "data": attr.label_list( - mandatory = True, allow_files = True, doc = """Files or targets to copy to the dist dir. @@ -47,7 +46,6 @@ In the case of targets, the rule copies the list of `files` from the target's De """, ), "archives": attr.label_list( - mandatory = True, allow_files = [".tar.gz", ".tar"], doc = """Files or targets to be extracted to the dist dir. @@ -57,7 +55,10 @@ In the case of targets, the rule copies the list of `files` from the target's De }, ) -def copy_to_dist_dir(name, data = [], archives = []): +def copy_to_dist_dir( + name, + data = None, + archives = None): """A dist rule to copy files out of Bazel's output directory into a custom location. Example: diff --git a/docs/docs.bzl b/docs/docs.bzl index 1fe02bc..e770fb6 100644 --- a/docs/docs.bzl +++ b/docs/docs.bzl @@ -21,10 +21,10 @@ def docs( name, srcs, default = None, - deps = [], - func_template = "//build/bazel_common_rules/docs:templates/func.vm", - provider_template = "//build/bazel_common_rules/docs:templates/provider.vm", - rule_template = "//build/bazel_common_rules/docs:templates/rule.vm"): + deps = None, + func_template = None, + provider_template = None, + rule_template = None): """Build docs. The following rules are also generated: @@ -48,9 +48,21 @@ def docs( rule_template: Template for generating docs for rules. """ + all_deps = [] + all_deps += srcs + if deps != None: + all_deps += deps + + if func_template == None: + func_template = "//build/bazel_common_rules/docs:templates/func.vm" + if provider_template == None: + provider_template = "//build/bazel_common_rules/docs:templates/provider.vm" + if rule_template == None: + rule_template = "//build/bazel_common_rules/docs:templates/rule.vm" + bzl_library( name = name + "_deps", - srcs = srcs + deps, + srcs = all_deps, ) all_markdown_files = [] |