Skip to content

Commit

Permalink
docs(format): include API docs for each language/tool (#251)
Browse files Browse the repository at this point in the history
* docs(format): include API docs for each language/tool

This makes it more clear that there's a 'yaml' attribute and you can set it to 'False', for example.
In a follow-up PR we can consider whether 'False' should be the default instead.

* refactor: don't provide format tool defaults
  • Loading branch information
alexeagle authored May 22, 2024
1 parent 7fddf83 commit 43971f9
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 64 deletions.
97 changes: 75 additions & 22 deletions docs/format.md

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

4 changes: 1 addition & 3 deletions example/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,7 @@ fetch_ktlint()

########################
# Optional: multitool provides defaults for some tools such as yamlfmt
# If you do not set up multitool, you will be forced to either set an explicit tool
# for languages that have a default, or set explicit False value, e.g.
# format_multirun(jsonnet = False)
# If you do not set up multitool, you must provide these tools yourself
load("@rules_multitool//multitool:multitool.bzl", "multitool")

multitool(
Expand Down
5 changes: 5 additions & 0 deletions example/tools/format/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,26 @@ format_multirun(
name = "format",
cc = "@llvm_toolchain_llvm//:bin/clang-format",
css = ":prettier",
go = "@aspect_rules_lint//format:gofumpt",
html = ":prettier",
# You can use standard gofmt instead of stricter gofumpt:
# go = "@go_sdk//:bin/gofmt",
java = ":java-format",
javascript = ":prettier",
jsonnet = "@aspect_rules_lint//format:jsonnetfmt",
kotlin = ":ktfmt",
markdown = ":prettier",
protocol_buffer = "//tools/lint:buf",
python = "//tools/lint:ruff",
rust = "@rules_rust//tools/rustfmt:upstream_rustfmt",
scala = ":scalafmt",
shell = "@aspect_rules_lint//format:shfmt",
sql = ":prettier",
starlark = "@buildifier_prebuilt//:buildifier",
swift = ":swiftformat",
terraform = "@aspect_rules_lint//format:terraform",
visibility = ["//:__subpackages__"],
yaml = "@aspect_rules_lint//format:yamlfmt",
)

format_test(
Expand Down
14 changes: 12 additions & 2 deletions format/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//format/private:formatter_binary.bzl", "BUILTIN_TOOL_LABELS")

package(default_visibility = ["//visibility:public"])

exports_files(glob(["*.bzl"]))

# Alias the multitools for strict repo visibility under bzlmod
[
alias(
name = v.split("/")[-1],
actual = v,
)
for v in BUILTIN_TOOL_LABELS.values()
]

bzl_library(
name = "defs",
srcs = ["defs.bzl"],
visibility = ["//visibility:public"],
deps = [
"//format/private:formatter_binary",
"@aspect_bazel_lib//lib:lists",
Expand All @@ -17,7 +28,6 @@ bzl_library(
bzl_library(
name = "repositories",
srcs = ["repositories.bzl"],
visibility = ["//visibility:public"],
deps = [
"@bazel_tools//tools/build_defs/repo:http.bzl",
"@bazel_tools//tools/build_defs/repo:utils.bzl",
Expand Down
Loading

0 comments on commit 43971f9

Please sign in to comment.