pseudomuto / protoc-gen-doc

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

proto-gen-doc in ci #409

Closed Sieboldianus closed 4 years ago

Sieboldianus commented 4 years ago

First, great project! I got my conversion from proto to markdown working locally with the docker run.

Now I am trying to set it up in our Gitlab CI job, and there's a problem I cannot figure out:

This line:

    - protoc-gen-doc --doc_out=. --doc_opt=protos/markdown_lbsn.tmpl,structure.md social.proto topical.proto spatial.proto temporal.proto interlinkage.proto

produces the following output:

31 $ protoc-gen-doc --doc_out=. --doc_opt=protos/markdown_lbsn.tmpl,structure.md social.proto topical.proto spatial.proto temporal.proto interlinkage.proto
32 flag provided but not defined: -doc_out
33 Usage of protoc-gen-doc:
34 This is a protoc plugin that is used to generate documentation from your protobuf files. Invocation is controlled by
35 using the doc_opt and doc_out options for protoc.
36 EXAMPLE: Generate HTML docs
37 protoc --doc_out=. --doc_opt=html,index.html protos/*.proto
38 EXAMPLE: Exclude file patterns
39 protoc --doc_out=. --doc_opt=html,index.html:google/*,somedir/* protos/*.proto
40 EXAMPLE: Use a custom template
41 protoc --doc_out=. --doc_opt=custom.tmpl,docs.txt protos/*.proto
42 See https://github.com/pseudomuto/protoc-gen-doc for more details.
43 FLAGS
44   -help
45      Show this help message
46   -version
47      Print the current version (1.3.0)
51 ERROR: Job failed: exit code 1

Why is the flag not defined? It states otherwise in the recommendations below. I tried different versions of these commands without success. I am using the official image. Here's my gitlab ci:

stages:
  - build
  - deploy

build-structure:
  stage: build
  image:
    name: pseudomuto/protoc-gen-doc
    # disable entrypoint so we can use git clone etc.
    entrypoint: [""]
  script:
    - apt-get -q -y update && apt-get -q -y install git
    - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab..../protobuf.git/
    - cp resources/proto-markdown-tmpl/markdown_lbsn.tmpl protos/
    - cp protobuf/lbsnstructure/* protos/
    - protoc-gen-doc --doc_out=. --doc_opt=protos/markdown_lbsn.tmpl,structure.md social.proto topical.proto spatial.proto temporal.proto interlinkage.proto
  artifacts:
    paths:
      - /out/structure.md
  only:
  - master
Sieboldianus commented 4 years ago

Finally solved it. This issue can be closed - maybe it'll help some people setup proto-gen-doc in gitlab ci. This is my final gitlabci.yml

stages:
  - build
  - deploy

build-structure:
  stage: build
  image:
    name: pseudomuto/protoc-gen-doc
    # disable entrypoint so we can use git clone etc.
    entrypoint: [""]
  script:
    - apt-get -q -y update && apt-get -q -y install git
    - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab..../protobuf.git/
    - cp resources/proto-markdown-tmpl/markdown_lbsn.tmpl protos/
    - cp protobuf/lbsnstructure/* protos/
    - bash /entrypoint.sh --doc_out=out/ --doc_opt=protos/markdown_lbsn.tmpl,structure.md social.proto topical.proto spatial.proto temporal.proto interlinkage.proto
  artifacts:
    paths:
      - /out/structure.md
  only:
  - master