Reference
stubs.gen.yaml
stubs generate reads stubs.gen.yaml, beside the workspace's stubs.yaml: the plugins to run, in order, on the
workspace's modules' files. stubs generate --template names another file. stubs init --from-buf writes one from a
buf.gen.yaml.
version: 1
clean: true
plugins:
- remote: stubs.dev/stubs/protobuf-go:v1.36.12
out: gen/go
options: [paths=source_relative]
- local: protoc-gen-es
out: gen/es
options: [target=ts]
- protoc: python
out: gen/python
managed:
enabled: true
override:
- file-option: go_package_prefix
value: github.com/acme/genstubs reads the file strictly, as it does stubs.yaml: an unknown key is an error.
version
The format: 1. Required.
clean
true empties each plugin's out directory before generating, so files a plugin no longer writes don't linger.
plugins
The plugins to run, in order: at least one. Each is exactly one of remote, local and protoc, with an out.
remote
One of the registry's curated plugins, run on the registry, by its name: the registry's host,
stubs and the plugin's name, optionally at a version after a colon, as in
stubs.dev/stubs/protobuf-go:v1.36.12. Without a version, the latest. stubs plugin list lists them.
local
A plugin on your machine: a program on your PATH, as in protoc-gen-go, or a path to one.
args
Arguments the local plugin is started with.
protoc
One of protoc's own generators, which stubs has built in, by the name protoc gives it, as in cpp, java,
python or csharp.
out
The directory the plugin writes into, relative to stubs.gen.yaml. Required.
options
The plugin's options, as in paths=source_relative, given to it joined with commas.
imports
true generates for the files the workspace's modules import as well, not only their own.
well-known-types
With imports, true generates for Google's well-known types too (google/protobuf/*.proto).
managed
Managed mode: stubs generate sets the language options in the files it generates for, such as java_package,
go_package and csharp_namespace, so your .proto files needn't, and files you don't own, such as a dependency's,
get options that suit your code. The files themselves aren't changed, and Google's well-known types are left as they
are. It works as Buf's managed mode does, with the same values, so code generated from a buf.gen.yaml in managed
mode comes out the same; stubs init --from-buf translates Buf's form, v1 or v2.
managed:
enabled: true
disable:
- module: stubs.dev/googleapis/googleapis
file-option: go_package
override:
- file-option: go_package_prefix
value: github.com/acme/gen
- file-option: java_package_prefix
value: net
path: acme/weatherenabled
true turns managed mode on. Without it, disable and override are refused.
disable
Options managed mode leaves as the files have them. Each rule has any of file-option, field-option, module,
path and field, and is about the files (and fields) all of them match; a rule with no option is about every
option.
override
Values other than managed mode's own. Each rule has one file-option or field-option and its value, with
module, path or field to narrow it. When several rules match a file, the last one wins.
file-option
One of the file options managed mode sets. With no rule about it, each gets the value in this table:
| Option | Without an override |
|---|---|
java_package | com. and the package: com.acme.weather.v1 |
java_package_prefix, java_package_suffix | What goes before and after the package in java_package |
java_multiple_files | true, before edition 2024 |
java_outer_classname | The file's name in PascalCase, then Proto: WeatherProto |
java_string_check_utf8 | Left as it is |
go_package | Left as it is, unless there's a go_package_prefix |
go_package_prefix | The prefix, then the file's directory; for a versioned package, ; and its last two parts: github.com/acme/gen/acme/weather/v1;weatherv1 |
csharp_namespace | The package in PascalCase: Acme.Weather.V1 |
csharp_namespace_prefix | What goes before it |
objc_class_prefix | The package's initials, less its version, made up to three with X: AWX |
php_namespace | The package in PascalCase, separated with \: Acme\Weather\V1 |
php_metadata_namespace | php_namespace, then \GPBMetadata |
php_metadata_namespace_suffix | What replaces GPBMetadata |
ruby_package | The package in PascalCase, separated with ::: Acme::Weather::V1 |
ruby_package_suffix | What goes after it |
swift_prefix | Left as it is |
cc_enable_arenas | Left as it is |
optimize_for | Left as it is: SPEED, CODE_SIZE or LITE_RUNTIME |
A file without a package gets none of the options made from one.
field-option
jstype, set on 64-bit integer fields: JS_NORMAL, JS_STRING or JS_NUMBER. Managed mode sets it only when an
override says so.
module
A module's name, as in stubs.dev/acme/weather: the rule is about that module's files, the workspace's own or a
dependency's.
path
A directory or a file, relative to the module's root, as the files import each other: acme/weather.
field
A field's full name, as in acme.weather.v1.Forecast.id, for a field-option rule.
value
An override's value: text, true or false for the options that are either, or an enum value's name.