From a14029088b85e774cb8c7484811c45eda452efed Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 29 Sep 2023 15:16:11 -0700 Subject: [PATCH] chore: enable buildifier check for module docstrings Suppress existing warnings on files, since I don't know what the docstrings should have been. --- .pre-commit-config.yaml | 2 +- .../deps.bzl | 1 + .../lib_a/deps.bzl | 1 + .../local_config_sh.bzl | 1 + .../sh_path.bzl | 1 + .../lib_a/deps.bzl | 1 + .../lib_b/deps.bzl | 1 + .../06-specify_dev_dependency/lib_a/deps.bzl | 1 + bzlmod/utils/librarian/librarian.bzl | 1 + .../attaching_transitions_to_rules/defs.bzl | 1 + configurations/basic_build_setting/defs.bzl | 1 + .../cc_binary_selectable_copts/defs.bzl | 1 + configurations/cc_test/defs.bzl | 1 + .../label_typed_build_setting/defs.bzl | 1 + configurations/multi_arch_binary/defs.bzl | 1 + .../read_attr_in_transition/defs.bzl | 1 + .../select_on_build_setting/defs.bzl | 1 + .../transition_on_native_flag/defs.bzl | 1 + .../use_skylib_build_setting/defs.bzl | 1 + flags-parsing-tutorial/build_defs.bzl | 1 + make-variables/testapp/defs.bzl | 1 + rules/depsets/foo.bzl | 1 + rules/executable/fortune.bzl | 14 ++++---- rules/implicit_output/hash.bzl | 1 + rules/predeclared_outputs/hash.bzl | 34 ++++++++++--------- 25 files changed, 49 insertions(+), 23 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 42d6e7bfc..36ddf4465 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,4 +15,4 @@ repos: - id: buildifier - id: buildifier-lint args: - - --warnings=-module-docstring,-provider-params,-name-conventions,-unnamed-macro + - --warnings=-provider-params,-name-conventions,-unnamed-macro diff --git a/bzlmod/03-introduce_dependencies_with_module_extension/deps.bzl b/bzlmod/03-introduce_dependencies_with_module_extension/deps.bzl index 0758bbe59..fe4172346 100644 --- a/bzlmod/03-introduce_dependencies_with_module_extension/deps.bzl +++ b/bzlmod/03-introduce_dependencies_with_module_extension/deps.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") def world_cities(): diff --git a/bzlmod/03-introduce_dependencies_with_module_extension/lib_a/deps.bzl b/bzlmod/03-introduce_dependencies_with_module_extension/lib_a/deps.bzl index 8475f6ffe..5d86168db 100644 --- a/bzlmod/03-introduce_dependencies_with_module_extension/lib_a/deps.bzl +++ b/bzlmod/03-introduce_dependencies_with_module_extension/lib_a/deps.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") def emojis(): diff --git a/bzlmod/04-local_config_and_register_toolchains/local_config_sh.bzl b/bzlmod/04-local_config_and_register_toolchains/local_config_sh.bzl index 671e229b7..e7bd7d2e3 100644 --- a/bzlmod/04-local_config_and_register_toolchains/local_config_sh.bzl +++ b/bzlmod/04-local_config_and_register_toolchains/local_config_sh.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring def _is_windows(repository_ctx): """Returns true if the host OS is Windows.""" return repository_ctx.os.name.startswith("windows") diff --git a/bzlmod/04-local_config_and_register_toolchains/sh_path.bzl b/bzlmod/04-local_config_and_register_toolchains/sh_path.bzl index 320783078..20e0ee47f 100644 --- a/bzlmod/04-local_config_and_register_toolchains/sh_path.bzl +++ b/bzlmod/04-local_config_and_register_toolchains/sh_path.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring def _write_sh_path_impl(ctx): # Save the shell path to the given output file. sh_path = ctx.toolchains["@bazel_tools//tools/sh:toolchain_type"].path diff --git a/bzlmod/05-integrate_third_party_package_manager/lib_a/deps.bzl b/bzlmod/05-integrate_third_party_package_manager/lib_a/deps.bzl index 64be888c3..26f985350 100644 --- a/bzlmod/05-integrate_third_party_package_manager/lib_a/deps.bzl +++ b/bzlmod/05-integrate_third_party_package_manager/lib_a/deps.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring load("@librarian//:librarian.bzl", "fetch_book") def fetch_book_for_lib_a(): diff --git a/bzlmod/05-integrate_third_party_package_manager/lib_b/deps.bzl b/bzlmod/05-integrate_third_party_package_manager/lib_b/deps.bzl index d3161afb0..263b25a0b 100644 --- a/bzlmod/05-integrate_third_party_package_manager/lib_b/deps.bzl +++ b/bzlmod/05-integrate_third_party_package_manager/lib_b/deps.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring load("@librarian//:librarian.bzl", "fetch_book") def fetch_book_for_lib_b(): diff --git a/bzlmod/06-specify_dev_dependency/lib_a/deps.bzl b/bzlmod/06-specify_dev_dependency/lib_a/deps.bzl index 7f196c67f..b55775619 100644 --- a/bzlmod/06-specify_dev_dependency/lib_a/deps.bzl +++ b/bzlmod/06-specify_dev_dependency/lib_a/deps.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring load("@librarian//:librarian.bzl", "fetch_book") def deps(): diff --git a/bzlmod/utils/librarian/librarian.bzl b/bzlmod/utils/librarian/librarian.bzl index 8c68913de..3f3d974dd 100644 --- a/bzlmod/utils/librarian/librarian.bzl +++ b/bzlmod/utils/librarian/librarian.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring def _get_librarian_path(ctx): if ctx.os.name.find("windows") != -1: return ctx.path(Label("//:librarian.cmd")) diff --git a/configurations/attaching_transitions_to_rules/defs.bzl b/configurations/attaching_transitions_to_rules/defs.bzl index f9593c535..b268d3252 100644 --- a/configurations/attaching_transitions_to_rules/defs.bzl +++ b/configurations/attaching_transitions_to_rules/defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring # Load the provider of the pre-made settings defined in bazel_skylib. load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") diff --git a/configurations/basic_build_setting/defs.bzl b/configurations/basic_build_setting/defs.bzl index 07b58ea80..e6bd86719 100644 --- a/configurations/basic_build_setting/defs.bzl +++ b/configurations/basic_build_setting/defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring TemperatureProvider = provider(fields = ["type"]) temperatures = ["HOT", "LUKEWARM", "ICED"] diff --git a/configurations/cc_binary_selectable_copts/defs.bzl b/configurations/cc_binary_selectable_copts/defs.bzl index ffc60a683..35c4d31ee 100644 --- a/configurations/cc_binary_selectable_copts/defs.bzl +++ b/configurations/cc_binary_selectable_copts/defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring def _copt_transition_impl(_, attr): # settings provides read access to existing flags. But # this transition doesn't need to read any flags. diff --git a/configurations/cc_test/defs.bzl b/configurations/cc_test/defs.bzl index 8fd6cf5d3..3e4c2cb60 100644 --- a/configurations/cc_test/defs.bzl +++ b/configurations/cc_test/defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring # We can transition on native options using this # //command_line_option: syntax _BUILD_SETTING = "//command_line_option:test_arg" diff --git a/configurations/label_typed_build_setting/defs.bzl b/configurations/label_typed_build_setting/defs.bzl index e16d311c6..9c7228e62 100644 --- a/configurations/label_typed_build_setting/defs.bzl +++ b/configurations/label_typed_build_setting/defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring ToolInfo = provider(fields = ["type"]) # buildifier: disable=print diff --git a/configurations/multi_arch_binary/defs.bzl b/configurations/multi_arch_binary/defs.bzl index cc0e6bab3..259bfa440 100644 --- a/configurations/multi_arch_binary/defs.bzl +++ b/configurations/multi_arch_binary/defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring def _transition_impl(_, __): # Return a dict of dicts. The values are the updates to the configuration. # The keys are arbitrary helpful strings that can be used to access the split diff --git a/configurations/read_attr_in_transition/defs.bzl b/configurations/read_attr_in_transition/defs.bzl index 4bf0291f3..4cd8409bf 100644 --- a/configurations/read_attr_in_transition/defs.bzl +++ b/configurations/read_attr_in_transition/defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring # Load the provider of the pre-made settings defined in bazel_skylib. load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") diff --git a/configurations/select_on_build_setting/defs.bzl b/configurations/select_on_build_setting/defs.bzl index e80c215f8..259088c5a 100644 --- a/configurations/select_on_build_setting/defs.bzl +++ b/configurations/select_on_build_setting/defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring FruitInfo = provider(fields = ["type"]) # buildifier: disable=print diff --git a/configurations/transition_on_native_flag/defs.bzl b/configurations/transition_on_native_flag/defs.bzl index fa9cb48a1..51d9ce6c2 100644 --- a/configurations/transition_on_native_flag/defs.bzl +++ b/configurations/transition_on_native_flag/defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring def _transition_impl(_, attr): # Attaching the special prefix "//comand_line_option" to the name of a native # flag makes the flag available to transition on. The result of this transition diff --git a/configurations/use_skylib_build_setting/defs.bzl b/configurations/use_skylib_build_setting/defs.bzl index a475e5574..412019307 100644 --- a/configurations/use_skylib_build_setting/defs.bzl +++ b/configurations/use_skylib_build_setting/defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring # Load the provider of the pre-made settings defined in bazel_skylib load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") diff --git a/flags-parsing-tutorial/build_defs.bzl b/flags-parsing-tutorial/build_defs.bzl index 0e3f2c017..1b66e4a04 100644 --- a/flags-parsing-tutorial/build_defs.bzl +++ b/flags-parsing-tutorial/build_defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring BuildSettingInfo = provider() def _string_imp(ctx): diff --git a/make-variables/testapp/defs.bzl b/make-variables/testapp/defs.bzl index 8a080b57e..d2a38b6b3 100644 --- a/make-variables/testapp/defs.bzl +++ b/make-variables/testapp/defs.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring def _var_providing_rule_impl(ctx): return [ platform_common.TemplateVariableInfo({ diff --git a/rules/depsets/foo.bzl b/rules/depsets/foo.bzl index ddcc2819c..94635f1ad 100644 --- a/rules/depsets/foo.bzl +++ b/rules/depsets/foo.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring FooFiles = provider("transitive_sources") def get_transitive_srcs(srcs, deps): diff --git a/rules/executable/fortune.bzl b/rules/executable/fortune.bzl index 2234e5c52..c396c4907 100644 --- a/rules/executable/fortune.bzl +++ b/rules/executable/fortune.bzl @@ -1,9 +1,11 @@ -# A rule that generates a "fortune"-style executable for haikus. It takes haiku -# files as inputs, and produces a data file consisting of their concatenation, -# along with a shell script. -# -# To run, use -# bazel run //executable:bazel_haikus +"""A rule that generates a "fortune"-style executable for haikus. + +It takes haiku +files as inputs, and produces a data file consisting of their concatenation, +along with a shell script. +To run, use + bazel run //executable:bazel_haikus +""" # The script content, with placeholders for the data file name and number of # haikus. diff --git a/rules/implicit_output/hash.bzl b/rules/implicit_output/hash.bzl index ae97a1db0..11cf36b6c 100644 --- a/rules/implicit_output/hash.bzl +++ b/rules/implicit_output/hash.bzl @@ -1,3 +1,4 @@ +# buildifier: disable=module-docstring def _impl(ctx): # Create actions to generate the three output files. # Actions are run only when the corresponding file is requested. diff --git a/rules/predeclared_outputs/hash.bzl b/rules/predeclared_outputs/hash.bzl index eb3570b71..b2ca0a84f 100644 --- a/rules/predeclared_outputs/hash.bzl +++ b/rules/predeclared_outputs/hash.bzl @@ -1,19 +1,21 @@ -# A rule that takes in a series of "declarations" and produces "compiled -# output" for some of those declarations, along with a manifest. Here, the -# declarations are simply words in a dictionary text file, and the compiled -# output of a word is just its hash. -# -# The compiled outputs are specified by the user, while the manifest file is -# created automatically. Both kinds of outputs are predeclared, and can be -# referred to in the target graph or built in the command line, e.g.: -# -# bazel build //predeclared_outputs:dog.md5 -# -# If you do not need to refer to the output files as labels, it may be simpler -# to pass in the words as an attr.string_list, and declare the files in the -# implementation function instead. -# -# This rule assumes the presence of shell commands "grep", "md5sum", and "cut". +""" +A rule that takes in a series of "declarations" and produces "compiled +output" for some of those declarations, along with a manifest. Here, the +declarations are simply words in a dictionary text file, and the compiled +output of a word is just its hash. + +The compiled outputs are specified by the user, while the manifest file is +created automatically. Both kinds of outputs are predeclared, and can be +referred to in the target graph or built in the command line, e.g.: + + bazel build //predeclared_outputs:dog.md5 + +If you do not need to refer to the output files as labels, it may be simpler +to pass in the words as an attr.string_list, and declare the files in the +implementation function instead. + +This rule assumes the presence of shell commands "grep", "md5sum", and "cut". +""" def _word_hashes_impl(ctx): dictionary = ctx.file.dictionary