Skip to content

Commit 19d2040

Browse files
authored
Revert Markdown TOC (#255)
1 parent 7b55b72 commit 19d2040

1 file changed

Lines changed: 23 additions & 50 deletions

File tree

README.md

Lines changed: 23 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
1-
<!-- vscode-markdown-toc -->
2-
* 1. [`WORKSPACE` Boilerplate](#WORKSPACEBoilerplate)
3-
* 2. [Gazelle Setup](#GazelleSetup)
4-
* 3. [Gazelle Configuration](#GazelleConfiguration)
5-
* 3.1. [Build Directives](#BuildDirectives)
6-
* 3.2. [YAML Configuration](#YAMLConfiguration)
7-
* 4. [Running Gazelle](#RunningGazelle)
8-
* 5. [Build Rules](#BuildRules)
9-
* 5.1. [proto_compile](#proto_compile)
10-
* 5.2. [proto_plugin](#proto_plugin)
11-
* 5.3. [proto_compiled_sources](#proto_compiled_sources)
12-
* 5.4. [proto_compile_assets](#proto_compile_assets)
13-
* 5.5. [The `output_mappings` attribute](#Theoutput_mappingsattribute)
14-
* 6. [Repository Rules](#RepositoryRules)
15-
* 7. [proto_repository](#proto_repository)
16-
* 8. [proto_gazelle](#proto_gazelle)
17-
* 9. [golden_filegroup](#golden_filegroup)
18-
* 10. [Plugin Implementations](#PluginImplementations)
19-
* 11. [Rule Implementations](#RuleImplementations)
20-
* 12. [+/- of golang implementations](#-ofgolangimplementations)
21-
* 13. [+/- of starlark implementations](#-ofstarlarkimplementations)
22-
23-
<!-- vscode-markdown-toc-config
24-
numbering=true
25-
autoSave=true
26-
/vscode-markdown-toc-config -->
27-
<!-- /vscode-markdown-toc -->
28-
291
# `rules_proto (v2)`
302

313
[![Build status](https://badge.buildkite.com/5980cc1d55f96e721bd9a7bd5dc1e40a096a7c30bc13117910.svg?branch=master)](https://buildkite.com/bazel/stackb-rules-proto)
@@ -75,12 +47,12 @@ Bazel starlark rules for building protocol buffers +/- gRPC :sparkles:.
7547
- [proto_gazelle](#proto_gazelle)
7648
- [Plugin Implementations](#plugin-implementations)
7749
- [Rule Implementations](#rule-implementations)
78-
- [Writing Custom Plugins & Rules](#writing_custom_plugins___rules)
50+
- [Writing Custom Plugins & Rules](#writing-custom-plugins-and-rules)
7951
- [History of this repository](#history)
8052

8153
# Getting Started
8254

83-
## 1. <a name='WORKSPACEBoilerplate'></a>`WORKSPACE` Boilerplate
55+
## `WORKSPACE` Boilerplate
8456

8557
```python
8658
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
@@ -178,7 +150,7 @@ protobuf_core_deps()
178150
> This brings in `@com_google_protobuf` and friends if you don't already have
179151
> them.
180152
181-
## 2. <a name='GazelleSetup'></a>Gazelle Setup
153+
## Gazelle Setup
182154

183155
```python
184156
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
@@ -203,12 +175,12 @@ gazelle(
203175
204176
---
205177

206-
## 3. <a name='GazelleConfiguration'></a>Gazelle Configuration
178+
## Gazelle Configuration
207179

208180
The gazelle extension can be configured using "build directives" and/or a YAML
209181
file.
210182

211-
### 3.1. <a name='BuildDirectives'></a>Build Directives
183+
### Build Directives
212184

213185
Gazelle is configured by special comments in BUILD files called _directives_.
214186

@@ -274,7 +246,7 @@ Let's unpack this a bit:
274246
> suppress the language entirely, use
275247
> `gazelle:proto_language cpp enabled false`.
276248
277-
### 3.2. <a name='YAMLConfiguration'></a>YAML Configuration
249+
### YAML Configuration
278250

279251
You can also configure the extension using a YAML file. This is semantically
280252
similar to adding gazelle directives to the root `BUILD` file; the YAML
@@ -333,7 +305,7 @@ gazelle(
333305
)
334306
```
335307

336-
## 4. <a name='RunningGazelle'></a>Running Gazelle
308+
## Running Gazelle
337309

338310
Now that we have the `WORKSPACE` setup and gazelle configured, we can run
339311
gazelle:
@@ -415,7 +387,7 @@ extensions should not _claim_ the same load namespace, so in order to prevent
415387
potential conflicts with other possible gazelle extensions, using the name
416388
`@rules_cc//cc:defs.bzl%cc_library` is undesirable.
417389

418-
## 5. <a name='BuildRules'></a>Build Rules
390+
## Build Rules
419391

420392
The core of `stackb/rules_proto` contains two build rules:
421393

@@ -424,7 +396,7 @@ The core of `stackb/rules_proto` contains two build rules:
424396
| `proto_compile` | Executes the `protoc` tool. |
425397
| `proto_plugin` | Provides static `protoc` plugin-specific configuration. |
426398

427-
### 5.1. <a name='proto_compile'></a>proto_compile
399+
### proto_compile
428400

429401
Example:
430402

@@ -466,7 +438,7 @@ Takeaways:
466438
extension provided by [bazel-gazelle] is responsible for generating
467439
`proto_library`.
468440

469-
### 5.2. <a name='proto_plugin'></a>proto_plugin
441+
### proto_plugin
470442

471443
`proto_plugin` primarily provides the plugin tool executable. The example seen
472444
above is the simplest case where the plugin is builtin to `protoc` itself; no
@@ -479,7 +451,7 @@ for this is narrow. Generally it is preferred to say
479451
`# gazelle:proto_plugin foo option bar` such that the option can be interpreted
480452
during a gazelle run.
481453

482-
### 5.3. <a name='proto_compiled_sources'></a>proto_compiled_sources
454+
### proto_compiled_sources
483455

484456
`proto_compiled_sources` is used when you prefer to check the generated files
485457
into source control. This may be necessary for legacy reasons, during an initial
@@ -504,7 +476,7 @@ will be committed under source control. `3.` is used to prevent drift: if a
504476
developer modifies `thing.proto` and neglects to run the `.update` the test will
505477
fail in CI.
506478

507-
### 5.4. <a name='proto_compile_assets'></a>proto_compile_assets
479+
### proto_compile_assets
508480

509481
The macro `proto_compile_assets` aggregates a list of dependencies (which
510482
provide `ProtoCompileInfo`) into a single runnable target that copies files in
@@ -526,7 +498,7 @@ proto_compile_assets(
526498
)
527499
```
528500

529-
### 5.5. <a name='Theoutput_mappingsattribute'></a>The `output_mappings` attribute
501+
### The `output_mappings` attribute
530502

531503
Consider the following rule within the package `example/thing`:
532504

@@ -604,9 +576,9 @@ the actual output location does not match the desired location. This can occur
604576
if the proto `package` statement does not match the Bazel package path, or in
605577
special circumstances specific to the plugin itself (like `go_package`).
606578

607-
## 6. <a name='RepositoryRules'></a>Repository Rules
579+
## Repository Rules
608580

609-
## 7. <a name='proto_repository'></a>proto_repository
581+
## proto_repository
610582

611583
From an implementation standpoint, this is very similar to the `go_repository`
612584
rule. Both can download external files and then run the gazelle generator over
@@ -722,7 +694,7 @@ imports. Therefore, when gazelle is preparing a `go_library` rule and finds a
722694
To take advantage of this mechanism in the default workspace, use the
723695
`proto_gazelle` rule.
724696

725-
## 8. <a name='proto_gazelle'></a>proto_gazelle
697+
## proto_gazelle
726698

727699
`proto_gazelle` is not a repository rule: it's just like the typical `gazelle`
728700
rule, but with extra deps resolution superpowers. But, we discuss it here since
@@ -757,7 +729,7 @@ figure out the import dependency tree spanning `@bazelapis`, `@remoteapis`,
757729

758730
This works for any `proto_language`, with any set of custom protoc plugins.
759731

760-
## 9. <a name='golden_filegroup'></a>golden_filegroup
732+
## golden_filegroup
761733

762734
`golden_filegroup` is a utility macro for golden file testing. It works like a
763735
native filegroup, but adds `.update` and `.test` targets. Example:
@@ -786,7 +758,7 @@ golden_filegroup(
786758
)
787759
```
788760

789-
## 10. <a name='PluginImplementations'></a>Plugin Implementations
761+
## Plugin Implementations
790762

791763
The plugin name is an opaque string, but by convention they are maven-esqe
792764
artifact identifiers that follow a GitHub org/repo/plugin_name convention.
@@ -821,7 +793,7 @@ artifact identifiers that follow a GitHub org/repo/plugin_name convention.
821793
| [stackb:grpc.js:protoc-gen-grpc-js](pkg/plugin/stackb/grpc_js/protoc-gen-grpc-js.go) |
822794
| [stephenh:ts-proto:protoc-gen-ts-proto](pkg/plugin/stephenh/ts-proto/protoc-gen-ts-proto.go) |
823795

824-
## 11. <a name='RuleImplementations'></a>Rule Implementations
796+
## Rule Implementations
825797

826798
The rule name is an opaque string, but by convention they are maven-esqe
827799
artifact identifiers that follow a GitHub org/repo/rule_name convention.
@@ -847,13 +819,14 @@ artifact identifiers that follow a GitHub org/repo/rule_name convention.
847819
Please consult the `example/` directory and unit tests for more additional
848820
detail.
849821

850-
# Writing Custom Plugins & Rules
822+
823+
# Writing Custom Plugins and Rules
851824

852825
Custom plugin implementations and rule implementations can be written in golang
853826
or starlark. Golang implementations are statically compiled into the final
854827
`gazelle_binary` whereas starlark plugins are evaluated at gazelle runtime.
855828

856-
## 12. <a name='-ofgolangimplementations'></a>+/- of golang implementations
829+
## +/- of golang implementations
857830

858831
- `+` Full power of a statically compiled language, the golang stdlib, and
859832
external dependencies.
@@ -867,7 +840,7 @@ or starlark. Golang implementations are statically compiled into the final
867840
Until a dedicated tutorial is available, please consult the source code for
868841
examples.
869842

870-
## 13. <a name='-ofstarlarkimplementations'></a>+/- of starlark implementations
843+
## +/- of starlark implementations
871844

872845
- `+` More familiar to developer with starlark experience but not golang.
873846
- `+` Easier setup (*.star files in your gazelle repository)

0 commit comments

Comments
 (0)