protoc-gen-doc icon indicating copy to clipboard operation
protoc-gen-doc copied to clipboard

buf skips 'duplicate' files when invoked with multiple proto files

Open alexanderjophus opened this issue 4 years ago • 3 comments

I have the following structure

proto
- gen
  - doc
  - js
- idl
  - service1
    - service1.proto
  - service2
    - service2.proto

I have the following buf.yaml

version: v1beta1
name: buf.build/company/project
deps:
  - buf.build/beta/googleapis
build:
  roots:
    - proto/idl

and buf.gen.yaml

version: v1beta1
plugins:
  - name: grpc-web
    out: proto/gen/js
    opt: import_style=commonjs+dts,mode=grpcwebtext
  - name: doc
    out: proto/gen/doc
    opt: markdown,proto.md

The following error occurs

Warning: Duplicate generated file name "proto.md". Buf will continue without error here and drop the second occurrence of this file, but please raise an issue with the maintainer of the plugin.

With the js plugin (and go/swagger/others) a subdirectory is created per service and the service.js or service.pb.gois placed within that directory, however with the doc plugin no subdirectory is made leading to the duplicate files above.

Is there an option to use the subdirectory the .proto file was found in as the output like the other plugins?

alexanderjophus avatar Jun 25 '21 12:06 alexanderjophus

@trelore you need to specify strategy all:

version: v1beta1
plugins:
  - name: doc
    out: gen/doc
    strategy: all

Gr1N avatar Jul 05 '21 16:07 Gr1N

Thanks! That works as a workaround, however as far as I can tell it combines all the md files into one unordered list, as we have a lot of microservices it'd be amazing to have them all in their own directory or saved as individual files.

alexanderjophus avatar Jul 07 '21 10:07 alexanderjophus

Thanks! That works as a workaround, however as far as I can tell it combines all the md files into one unordered list, as we have a lot of microservices it'd be amazing to have them all in their own directory or saved as individual files.

This setup works for me:

-- buf.gen.yaml

version: v1
plugins:
  - name: doc
    out: docs
    opt: markdown,README.md,source_relative
    strategy: all

The documentation of each service resides on its own directory:

├── docs
│   ├── cards
│   │   └── v1
│   │       └── README.md
│   ├── checkout
│   │   └── v1
│   │       └── README.md

nghiant3223 avatar Oct 26 '23 08:10 nghiant3223