Skip to content

Commit 7722987

Browse files
committed
Update documentation for toolchain option dicts
Touched up documentation for the `scalafmt` and `scala_proto` toolchains.
1 parent b78f9a2 commit 7722987

File tree

4 files changed

+52
-13
lines changed

4 files changed

+52
-13
lines changed

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -930,19 +930,36 @@ parameter list, which is almost in complete correspondence with parameters from
930930
the previous macros. The `WORKSPACE` files in this repository also provide many
931931
examples.
932932

933-
### Replacing toolchain registration macros in `WORKSPACE`
933+
### Replacing toolchain registration macros
934934

935935
Almost all `rules_scala` toolchains configured using `scala_toolchains()` are
936-
automatically registered by `scala_register_toolchains()`. There are two
937-
toolchain macro replacements that require special handling.
936+
automatically registered by `scala_register_toolchains()`. The same is true for
937+
toolchains configured using the `scala_deps` module extension under Bzlmod.
938+
There are two toolchain macro replacements that require special handling.
938939

939940
The first is replacing `scala_proto_register_enable_all_options_toolchain()`
940-
with the following `scala_toolchains()` parameters:
941+
with the following:
941942

942943
```py
944+
# MODULE.bazel
945+
946+
scala_deps.scala_proto(
947+
"default_gen_opts" = [
948+
"flat_package",
949+
"grpc",
950+
"single_line_to_proto_string",
951+
],
952+
)
953+
954+
# WORKSPACE
943955
scala_toolchains(
944-
scala_proto = True,
945-
scala_proto_options = [],
956+
scala_proto = {
957+
"default_gen_opts": [
958+
"flat_package",
959+
"grpc",
960+
"single_line_to_proto_string",
961+
],
962+
},
946963
)
947964
```
948965

docs/phase_scalafmt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The extension provides a default configuration, but there are 2 ways to use
7575
a custom configuration:
7676

7777
- Put `.scalafmt.conf` at the root of your workspace
78-
- Pass `.scalafmt.conf` in via `scala_toolchains`:
78+
- Pass `.scalafmt.conf` into the toolchain configuration:
7979

8080
```py
8181
# MODULE.bazel

docs/scala_proto_library.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
11
# scala_proto_library
22

3-
To use this rule, you'll first need to add the following to your `WORKSPACE` file,
4-
which adds a few dependencies needed for ScalaPB:
3+
To use this rule, add the following configuration, which adds the dependencies
4+
needed for ScalaPB:
55

66
```py
7-
scala_toolchains(
8-
# Other toolchains settings...
9-
scala_proto = True,
10-
scala_proto_options = [
7+
# MODULE.bazel
8+
scala_deps.scala_proto(
9+
"default_gen_opts" = [
1110
"grpc",
1211
"flat_package",
1312
"scala3_sources",
1413
],
1514
)
15+
```
16+
17+
```py
18+
# WORKSPACE
19+
scala_toolchains(
20+
# Other toolchains settings...
21+
scala_proto = {
22+
"default_gen_opts": [
23+
"grpc",
24+
"flat_package",
25+
"scala3_sources",
26+
],
27+
},
28+
)
1629

1730
scala_register_toolchains()
1831
```
1932

33+
See the __scalapbc__ column of the [__ScalaPB: SBT Settings > Additional options
34+
to the generator__](
35+
https://scalapb.github.io/docs/sbt-settings#additional-options-to-the-generator
36+
) table for `default_gen_opts` values.
37+
2038
Then you can import `scala_proto_library` in any `BUILD` file like this:
2139

2240
```py

scala_proto/toolchains.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def setup_scala_proto_toolchains(
1616
See //scala/private:macros/toolchains_repo.bzl for details, especially the
1717
_SCALA_PROTO_TOOLCHAIN_BUILD string template.
1818
19+
See the `scalapbc` column of the "ScalaPB: SBT Settings > Additional options
20+
to the generator" table below for `default_gen_opts` values:
21+
- https://scalapb.github.io/docs/sbt-settings#additional-options-to-the-generator
22+
1923
Args:
2024
name: prefix for all generate toolchains
2125
default_gen_opts: parameters passed to the default generator

0 commit comments

Comments
 (0)