pseudomuto / protoc-gen-doc

Documentation generator plugin for Google Protocol Buffers
MIT License
2.59k stars 462 forks source link

issue while trying the example #441

Open HassenMak opened 3 years ago

HassenMak commented 3 years ago

Hello all,

I am quite new in Go and Protoc. I want to test your library but I am facing issues while running the example.

I cloned the repository and I cd to the "/examples" folder. Then I executed: protoc --doc_out=./doc --doc_opt=html,index.html proto/*.proto - as mentioned in the readme.

However I am receiving this error: google/api/annotations.proto: File not found. github.com/mwitkow/go-proto-validators/validator.proto: File not found. proto/Booking.proto:9:1: Import "google/api/annotations.proto" was not found or had errors. proto/Booking.proto:10:1: Import "github.com/mwitkow/go-proto-validators/validator.proto" was not found or had errors.

I understood that this is due to the imports in the example proto files. I tried by using -I and include thirdparty, I tried to move to other folders and to understand what is happening, but wasn't I able to succeed. Is there someone who can help/enlighten me please?

Thanks in advance.

HassenMak commented 3 years ago

By the way, having same issue while using the docker image

HassenMak commented 3 years ago

I think I understood: In the protoc command, there is a need to add the path of any proto files mentioned (even the ones in the import statements). So need something like that: protoc -I=$PATH1 -I=$PATH2 -I=$PATH3 --doc_out=./doc --doc_opt=html,index.html proto/*.proto

where:

So if we want to try your sample, are we supposed to clone the googleapis repo?

christianloth commented 2 years ago

i am having the same issue. please help

ralucado commented 2 years ago

Same issue here, it is not well documented, @pseudomuto

pseudomuto commented 2 years ago

There are some make targets that handle fetching the googleapis stuff. Do you have issues running either make examples or make docker_test?

gedw99 commented 1 year ago

@pseudomuto

its almost working... Amd looking at whats wrong.. the make file is excellent btw..

make build/examples
Building binary...
Making examples...
/bin/sh: bin/protoc: cannot execute binary file
make: *** [Makefile:42: build/examples] Error 126
gedw99 commented 1 year ago

ok problem is obvious. its pulling linux protoc.

we can change the make file to check OS and pull the right bin..

gedw99 commented 1 year ago

@pseudomuto now works

protoc-gen-doc % make build
Building binary...
apple@x-MacBook-Pro-2 protoc-gen-doc % make build/examples
Building binary...
Fetching googleapis...
Cloning into 'tmp/googleapis'...
remote: Enumerating objects: 5668, done.
remote: Counting objects: 100% (5668/5668), done.
remote: Compressing objects: 100% (2974/2974), done.
remote: Total 5668 (delta 3465), reused 3385 (delta 2578), pack-reused 0
Receiving objects: 100% (5668/5668), 6.21 MiB | 5.83 MiB/s, done.
Resolving deltas: 100% (3465/3465), done.
Updating files: 100% (4944/4944), done.
Cloning into 'tmp/protocolbuffers'...
remote: Enumerating objects: 2314, done.
remote: Counting objects: 100% (2314/2314), done.
remote: Compressing objects: 100% (1820/1820), done.
remote: Total 2314 (delta 913), reused 767 (delta 394), pack-reused 0
Receiving objects: 100% (2314/2314), 5.26 MiB | 4.14 MiB/s, done.
Resolving deltas: 100% (913/913), done.
Updating files: 100% (2090/2090), done.
Making examples...
apple@x-MacBook-Pro-2 protoc-gen-doc % 
gedw99 commented 1 year ago

we need a nasty if else in the make file.

then suggest using go-getter as a tool as its universal ... can use the same pattern as here for tooling that is golang based: https://github.com/pseudomuto/pseudocms/blob/main/tools.go

here is the basic pseudo code...

OS = $(shell uname -s)
ARCH = $(shell uname -m)

bin/protoc1: ## Install protoc to ./bin
    @mkdir -p ./bin
    go-getter "https://github.com/bufbuild/buf/releases/download/v1.15.1/buf-$(OS)-$(ARCH)" ./bin/buf
    chmod +x ./bin/buf

    go-getter https://github.com/protocolbuffers/protobuf/releases/download/v22.3/protoc-22.3-osx-universal_binary.zip ./bin/protoc