digital-asset / daml

The Daml smart contract language
https://www.digitalasset.com/developers
Other
803 stars 204 forks source link

oneof types are not properly rendered with protoc-gen-doc #11761

Closed gerolf-da closed 2 years ago

gerolf-da commented 3 years ago

The current version of protoc-gen-doc we're using (1.1) doesn't support rendering oneof types. This was fixed in protoc-gen-doc 1.4 or later.

The oneof in commands.proto is currently rendered like this: image

cocreature commented 2 years ago

I pushed a branch with an attempt to https://github.com/digital-asset/daml/tree/bump-go-rules-docs

However, this currently fails to build:

bazel build //ledger-api/grpc-definitions:ledger-api-docs
INFO: Invocation ID: 764554f8-dcd4-4cb0-bee5-14c84ab9ee8a
DEBUG: /home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/rules_haskell/haskell/private/versions.bzl:60:10: WARNING: bazel version is too recent. Supported versions range from 2.1.0 to 4.1.0, but found: 4.2.1- (@non-git)
DEBUG: /home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/bazel_gazelle/internal/go_repository.bzl:209:18: com_github_pseudomuto_protokit: gazelle: /home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/com_github_pseudomuto_protokit/examples/jsonator: directory contains multiple proto packages. Gazelle can only generate a proto_library for one package.
DEBUG: /home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/bazel_gazelle/internal/go_repository.bzl:209:18: org_golang_google_protobuf: gazelle: /home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/external/org_golang_google_protobuf/cmd/protoc-gen-go/testdata/imports/test_b_1: directory contains multiple proto packages. Gazelle can only generate a proto_library for one package.
INFO: Analyzed target //ledger-api/grpc-definitions:ledger-api-docs (1 packages loaded, 26 targets configured).
INFO: Found 1 target...
ERROR: /home/moritz/daml/ledger-api/grpc-definitions/BUILD.bazel:244:10: ProtoGen ledger-api/grpc-definitions/ledger-api-docs-sources failed: (Exit 1): bash failed: error executing command
  (cd /home/moritz/.cache/bazel/_bazel_moritz/bb4e4404f889dc1b816f246b08c0d9ea/sandbox/linux-sandbox/343/execroot/com_github_digital_asset_daml && \
  exec env - \
  /nix/store/30wkf1yqkj6a95vfl1iwarwb37phc0f5-bash/bin/bash -c '/nix/store/haq92xsmm6vfhjbi7039d3mh91wd4vap-posix-toolchain/bin/mkdir -p bazel-out/k8-opt/bin/ledger-api/grpc-definitions/ledger-api-docs-sources && bazel-out/k8-opt/bin/external/com_google_protobuf/protoc --descriptor_set_in=bazel-out/k8-opt/bin/external/com_google_protobuf/duration_proto-descriptor-set.proto.bin:bazel-out/k8-opt/bin/external/go_googleapis/google/rpc/errdetails_proto-descriptor-set.proto.bin:bazel-out/k8-opt/bin/external/com_google_protobuf/any_proto-descriptor-set.proto.bin:bazel-out/k8-opt/bin/external/go_googleapis/google/rpc/status_proto-descriptor-set.proto.bin:bazel-out/k8-opt/bin/external/com_google_protobuf/descriptor_proto-descriptor-set.proto.bin:bazel-out/k8-opt/bin/external/com_google_protobuf/empty_proto-descriptor-set.proto.bin:bazel-out/k8-opt/bin/external/com_google_protobuf/timestamp_proto-descriptor-set.proto.bin:bazel-out/k8-opt/bin/external/com_google_protobuf/wrappers_proto-descriptor-set.proto.bin:bazel-out/k8-opt/bin/ledger-api/grpc-definitions/ledger_api_proto-descriptor-set.proto.bin --doc_out=ledger-api/grpc-definitions/rst_mmd.tmpl,docs.rst:bazel-out/k8-opt/bin/ledger-api/grpc-definitions/ledger-api-docs-sources --plugin=protoc-gen-doc=bazel-out/k8-opt/bin/external/com_github_pseudomuto_protoc_gen_doc/cmd/protoc-gen-doc/protoc-gen-doc_/protoc-gen-doc com/daml/ledger/api/v1/active_contracts_service.proto com/daml/ledger/api/v1/admin/config_management_service.proto com/daml/ledger/api/v1/admin/package_management_service.proto com/daml/ledger/api/v1/admin/participant_pruning_service.proto com/daml/ledger/api/v1/admin/party_management_service.proto com/daml/ledger/api/v1/command_completion_service.proto com/daml/ledger/api/v1/command_service.proto com/daml/ledger/api/v1/command_submission_service.proto com/daml/ledger/api/v1/commands.proto com/daml/ledger/api/v1/completion.proto com/daml/ledger/api/v1/event.proto com/daml/ledger/api/v1/experimental_features.proto com/daml/ledger/api/v1/ledger_configuration_service.proto com/daml/ledger/api/v1/ledger_identity_service.proto com/daml/ledger/api/v1/ledger_offset.proto com/daml/ledger/api/v1/package_service.proto com/daml/ledger/api/v1/testing/reset_service.proto com/daml/ledger/api/v1/testing/time_service.proto com/daml/ledger/api/v1/transaction.proto com/daml/ledger/api/v1/transaction_filter.proto com/daml/ledger/api/v1/transaction_service.proto com/daml/ledger/api/v1/value.proto com/daml/ledger/api/v1/version_service.proto')
Execution platform: @io_tweag_rules_nixpkgs//nixpkgs/platforms:host

Use --sandbox_debug to see verbose messages from the sandbox
panic: proto: extension number 65020 is already registered on message google.protobuf.FieldOptions
See https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict

goroutine 1 [running]:
google.golang.org/protobuf/reflect/protoregistry.glob..func1(0x7fd196a5f980, 0xc0000eb410, 0x8a78a0, 0xc000099550, 0xc0000eb410)
        external/org_golang_google_protobuf/reflect/protoregistry/registry.go:54 +0x25f
google.golang.org/protobuf/reflect/protoregistry.(*Types).RegisterExtension(0xc00009a540, 0x8af468, 0xc0000eb3f0, 0x0, 0x0)
        external/org_golang_google_protobuf/reflect/protoregistry/registry.go:552 +0x6ae
github.com/golang/protobuf/proto.RegisterExtension(...)
        external/com_github_golang_protobuf/proto/registry.go:279
github.com/pseudomuto/protoc-gen-doc/extensions/validator_field.init.0()
        external/com_github_pseudomuto_protoc_gen_doc/extensions/validator_field/validator_field.go:19 +0x127
--doc_out: protoc-gen-doc: Plugin failed with status code 2.
Target //ledger-api/grpc-definitions:ledger-api-docs failed to build
INFO: Elapsed time: 0.627s, Critical Path: 0.31s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully

This looks like somehow we are including multiple variations of the same proto but I don’t understand how. I tried to play around with how we include the googleapis which seems one potential culprit but not the only one.