diff --git a/WORKSPACE b/WORKSPACE
index f0b949f..21f2082 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -39,19 +39,13 @@ swift_rules_extra_dependencies()
# MARK: - Buildifier
-load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
+load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")
-go_rules_dependencies()
+buildifier_prebuilt_deps()
-go_register_toolchains(version = "1.17.2")
+load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")
-load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
-
-gazelle_dependencies()
-
-load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
-
-protobuf_deps()
+buildifier_prebuilt_register_toolchains()
# MARK: - Integration Testing
@@ -59,8 +53,8 @@ load("@cgrindel_rules_bazel_integration_test//bazel_integration_test:deps.bzl",
bazel_integration_test_rules_dependencies()
-load("//:bazel_versions.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("@cgrindel_rules_bazel_integration_test//bazel_integration_test:defs.bzl", "bazel_binaries")
+load("//:bazel_versions.bzl", "SUPPORTED_BAZEL_VERSIONS")
bazel_binaries(versions = SUPPORTED_BAZEL_VERSIONS)
diff --git a/bazel_versions.bzl b/bazel_versions.bzl
index 94719d9..06dc47d 100644
--- a/bazel_versions.bzl
+++ b/bazel_versions.bzl
@@ -1,3 +1,5 @@
+"""Tested/Supported Bazel Versions"""
+
CURRENT_BAZEL_VERSION = "5.0.0"
OTHER_BAZEL_VERSIONS = [
diff --git a/doc/BUILD.bazel b/doc/BUILD.bazel
index dd54c7b..203343a 100644
--- a/doc/BUILD.bazel
+++ b/doc/BUILD.bazel
@@ -1,4 +1,3 @@
-load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg")
load(
"@cgrindel_bazel_starlib//bazeldoc:defs.bzl",
"doc_for_provs",
@@ -6,6 +5,7 @@ load(
"write_header",
doc_providers = "providers",
)
+load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg")
# MARK: - Documentation Providers
diff --git a/doc/rules_and_macros_overview.md b/doc/rules_and_macros_overview.md
index 0cf16ec..c556e0b 100755
--- a/doc/rules_and_macros_overview.md
+++ b/doc/rules_and_macros_overview.md
@@ -109,10 +109,6 @@ NOTE: Any labels detected in the `srcs` will be ignored.
| srcs | Optional. The Swift source files that should be formatted. | None
|
| config | Optional. The swiftformat YAML configuration file. | None
|
-**RETURNS**
-
-None.
-
diff --git a/swiftformat/defs.bzl b/swiftformat/defs.bzl
index 35d9f32..00d620c 100644
--- a/swiftformat/defs.bzl
+++ b/swiftformat/defs.bzl
@@ -1,6 +1,12 @@
+"""Public API for rules_swiftformat."""
+
load(
- "//swiftformat/internal:swiftformat_pkg.bzl",
- _swiftformat_pkg = "swiftformat_pkg",
+ "//swiftformat/internal:src_utils.bzl",
+ _src_utils = "src_utils",
+)
+load(
+ "//swiftformat/internal:swiftformat_binary.bzl",
+ _swiftformat_binary = "swiftformat_binary",
)
load(
"//swiftformat/internal:swiftformat_format.bzl",
@@ -11,17 +17,13 @@ load(
_swiftformat_library = "swiftformat_library",
)
load(
- "//swiftformat/internal:swiftformat_binary.bzl",
- _swiftformat_binary = "swiftformat_binary",
+ "//swiftformat/internal:swiftformat_pkg.bzl",
+ _swiftformat_pkg = "swiftformat_pkg",
)
load(
"//swiftformat/internal:swiftformat_test.bzl",
_swiftformat_test = "swiftformat_test",
)
-load(
- "//swiftformat/internal:src_utils.bzl",
- _src_utils = "src_utils",
-)
# Macros
swiftformat_pkg = _swiftformat_pkg
diff --git a/swiftformat/deps.bzl b/swiftformat/deps.bzl
index d93b4b4..2723cd5 100644
--- a/swiftformat/deps.bzl
+++ b/swiftformat/deps.bzl
@@ -1,3 +1,5 @@
+"""Dependencies for rules_swiftformat."""
+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
@@ -16,10 +18,10 @@ def swiftformat_rules_dependencies():
maybe(
http_archive,
name = "cgrindel_bazel_starlib",
- sha256 = "9e054e423bb7674e02052e52725b41288369dd94efff963479f76fe269b5177f",
- strip_prefix = "bazel-starlib-0.3.1",
+ sha256 = "8ac3e45dc237121283d70506497ec39feb5092af9a57bfe34f7abf4a6bd2ebaa",
+ strip_prefix = "bazel-starlib-0.6.0",
urls = [
- "http://github.com/cgrindel/bazel-starlib/archive/v0.3.1.tar.gz",
+ "http://github.com/cgrindel/bazel-starlib/archive/v0.6.0.tar.gz",
],
)
diff --git a/swiftformat/internal/src_utils.bzl b/swiftformat/internal/src_utils.bzl
index 76f3f4b..4055722 100644
--- a/swiftformat/internal/src_utils.bzl
+++ b/swiftformat/internal/src_utils.bzl
@@ -1,3 +1,5 @@
+"""Definition for src_utils module."""
+
def _is_label(src):
"""Determines whether the provided string is a label.
diff --git a/swiftformat/internal/swiftformat_binary.bzl b/swiftformat/internal/swiftformat_binary.bzl
index 0dc6382..592fef4 100644
--- a/swiftformat/internal/swiftformat_binary.bzl
+++ b/swiftformat/internal/swiftformat_binary.bzl
@@ -1,3 +1,5 @@
+"""Definition for swiftformat_binary macro."""
+
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_binary")
load(":swiftformat_pkg.bzl", "swiftformat_pkg")
diff --git a/swiftformat/internal/swiftformat_format.bzl b/swiftformat/internal/swiftformat_format.bzl
index 0e39a17..ccf13a7 100644
--- a/swiftformat/internal/swiftformat_format.bzl
+++ b/swiftformat/internal/swiftformat_format.bzl
@@ -1,13 +1,11 @@
-load("@bazel_skylib//lib:paths.bzl", "paths")
+"""A build rule that formats Swift source files. """
+
load(
"@cgrindel_bazel_starlib//updatesrc:defs.bzl",
"UpdateSrcsInfo",
"update_srcs",
)
-"""A build rule that formats Swift source files.
-"""
-
def _swiftformat_format_impl(ctx):
updsrcs = []
for src in ctx.files.srcs:
@@ -48,6 +46,15 @@ def _swiftformat_format_impl(ctx):
swiftformat_format = rule(
implementation = _swiftformat_format_impl,
attrs = {
+ "config": attr.label(
+ allow_single_file = True,
+ doc = "A swiftformat config file.",
+ default = "@//:.swiftformat",
+ ),
+ "output_suffix": attr.string(
+ default = "_formatted",
+ doc = "The suffix to add to the output filename.",
+ ),
"srcs": attr.label_list(
allow_files = True,
mandatory = True,
@@ -59,15 +66,6 @@ The Swift version to be used by `swiftformat`. You probably want to add this \
to your config file instead of adding it here.\
""",
),
- "config": attr.label(
- allow_single_file = True,
- doc = "A swiftformat config file.",
- default = "@//:.swiftformat",
- ),
- "output_suffix": attr.string(
- default = "_formatted",
- doc = "The suffix to add to the output filename.",
- ),
"_swiftformat": attr.label(
default = "@swiftformat_repos//SwiftFormat:swiftformat",
executable = True,
diff --git a/swiftformat/internal/swiftformat_library.bzl b/swiftformat/internal/swiftformat_library.bzl
index c48f7c1..5d9e6a1 100644
--- a/swiftformat/internal/swiftformat_library.bzl
+++ b/swiftformat/internal/swiftformat_library.bzl
@@ -1,3 +1,5 @@
+"""Definition for swiftformat_library macro."""
+
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load(":swiftformat_pkg.bzl", "swiftformat_pkg")
diff --git a/swiftformat/internal/swiftformat_pkg.bzl b/swiftformat/internal/swiftformat_pkg.bzl
index a3131d4..a658b83 100644
--- a/swiftformat/internal/swiftformat_pkg.bzl
+++ b/swiftformat/internal/swiftformat_pkg.bzl
@@ -1,11 +1,12 @@
-load(":src_utils.bzl", "src_utils")
-load(":swiftformat_format.bzl", "swiftformat_format")
+"""\
+A macro which defines targets that format Swift source files, test that \
+they are formatted and copies them to the workspace directory.\
+"""
+
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@cgrindel_bazel_starlib//updatesrc:defs.bzl", "updatesrc_update")
-
-"""A macro which defines targets that format Swift source files, test that
-they are formatted and copies them to the workspace directory.
-"""
+load(":src_utils.bzl", "src_utils")
+load(":swiftformat_format.bzl", "swiftformat_format")
def swiftformat_pkg(name, srcs = None, config = None):
"""Defines targets that will format, test and update the specified Swift sources.
@@ -16,9 +17,6 @@ def swiftformat_pkg(name, srcs = None, config = None):
name: The base name for the targets that will be defined.
srcs: Optional. The Swift source files that should be formatted.
config: Optional. The swiftformat YAML configuration file.
-
- Returns:
- None.
"""
if srcs == None:
srcs = native.glob(["*.swift"])
diff --git a/swiftformat/internal/swiftformat_test.bzl b/swiftformat/internal/swiftformat_test.bzl
index aa35a67..bd0f442 100644
--- a/swiftformat/internal/swiftformat_test.bzl
+++ b/swiftformat/internal/swiftformat_test.bzl
@@ -1,3 +1,5 @@
+"""Definition for swiftformat_test macro."""
+
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_test")
load(":swiftformat_pkg.bzl", "swiftformat_pkg")
diff --git a/swiftformat/load_package.bzl b/swiftformat/load_package.bzl
index c1fa359..5b89ad5 100644
--- a/swiftformat/load_package.bzl
+++ b/swiftformat/load_package.bzl
@@ -1,3 +1,5 @@
+"""Definition for swiftformat_load_package function."""
+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@cgrindel_rules_spm//spm:defs.bzl", "spm_pkg", "spm_repositories")
@@ -11,8 +13,8 @@ def swiftformat_load_package(version = None):
version: Optional. A valid semver `string` for SwiftFormat.
"""
spm_pkg_args = {
- "url": "https://github.com/nicklockwood/SwiftFormat.git",
"products": ["swiftformat"],
+ "url": "https://github.com/nicklockwood/SwiftFormat.git",
}
if version == None:
# Load the latest 0.x.x version of SwiftFormat.
diff --git a/swiftformat/swiftformat.bzl b/swiftformat/swiftformat.bzl
index 238886f..5a7446b 100644
--- a/swiftformat/swiftformat.bzl
+++ b/swiftformat/swiftformat.bzl
@@ -1,3 +1,5 @@
+"""Deprecated. Public API for rules_swiftformat."""
+
# NOTE: This file is deprecated and will be removed in a future release. Please use
# //swiftformat:defs.bzl intead.
diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel
index c53c6dc..ae8c328 100644
--- a/tests/BUILD.bazel
+++ b/tests/BUILD.bazel
@@ -1,6 +1,6 @@
-load(":src_utils_tests.bzl", "src_utils_test_suite")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg")
+load(":src_utils_tests.bzl", "src_utils_test_suite")
bzlformat_pkg(name = "bzlformat")
diff --git a/tests/src_utils_tests.bzl b/tests/src_utils_tests.bzl
index cd994b5..6431222 100644
--- a/tests/src_utils_tests.bzl
+++ b/tests/src_utils_tests.bzl
@@ -1,5 +1,7 @@
+"""Tests for src_utils module."""
+
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
-load("//swiftformat/internal:src_utils.bzl", "src_utils")
+load("//swiftformat:defs.bzl", "src_utils")
def _is_label_test(ctx):
env = unittest.begin(ctx)