Skip to content

Commit

Permalink
Merge pull request #461 from pseudomuto/bump_go_protoc
Browse files Browse the repository at this point in the history
Update go, protoc, and drop resources script
  • Loading branch information
pseudomuto authored Oct 18, 2021
2 parents ab35ee6 + 89d7d93 commit 2dde019
Show file tree
Hide file tree
Showing 9 changed files with 592 additions and 219 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased](https://github.com/pseudomuto/protoc-gen-doc/compare/v1.5.0...master)

### Changed

* Escape special characters in markdown anchors [#460](https://github.com/pseudomuto/protoc-gen-doc/pull/460)
* Bump go to 1.17, protoc to 3.18.1, and leverage go:embed [#461](https://github.com/pseudomuto/protoc-gen-doc/pull/461)

## [v1.5.0](https://github.com/pseudomuto/protoc-gen-doc/compare/v1.4.1...v1.5.0)

* Add `source_relative` flag [#450](https://github.com/pseudomuto/protoc-gen-doc/pull/450)
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ RUN go mod download
COPY . ./
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o protoc-gen-doc ./cmd/protoc-gen-doc

FROM debian:jessie-slim AS final
LABEL maintainer="pseudomuto <[email protected]>" protoc_version="3.6.1"
FROM debian:bookworm-slim AS final
LABEL maintainer="pseudomuto <[email protected]>" protoc_version="3.18.1"

WORKDIR /

ADD https://github.com/google/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip ./
ADD https://github.com/google/protobuf/releases/download/v3.18.1/protoc-3.18.1-linux-x86_64.zip ./
RUN apt-get -q -y update && \
apt-get -q -y install unzip && \
unzip protoc-3.6.1-linux-x86_64.zip -d ./usr/local && \
rm protoc-3.6.1-linux-x86_64.zip && \
unzip protoc-3.18.1-linux-x86_64.zip -d ./usr/local && \
rm protoc-3.18.1-linux-x86_64.zip && \
apt-get remove --purge -y unzip && \
apt-get autoremove && \
rm -rf /var/lib/apt/lists/*
Expand Down
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ DOCKER_CMD=docker run --rm \

VERSION = $(shell cat version.go | sed -n 's/.*const VERSION = "\(.*\)"/\1/p')

resources.go: resources/*.tmpl resources/*.json
$(info Generating resources...)
@go run resources/main.go -in resources -out resources.go -pkg gendoc

fixtures/fileset.pb: fixtures/*.proto fixtures/generate.go
fixtures/fileset.pb: fixtures/*.proto fixtures/generate.go fixtures/nested/*.proto
$(info Generating fixtures...)
@cd fixtures && go generate

Expand All @@ -37,13 +33,13 @@ tmp/googleapis:
cp -r tmp/protocolbuffers/src/* tmp/googleapis/
rm -rf tmp/protocolbuffers

test: fixtures/fileset.pb resources.go
test: fixtures/fileset.pb
@go test -cover -race ./ ./cmd/... ./extensions/...

bench:
@go test -bench=.

build: resources.go
build:
@go build ./cmd/...

dist:
Expand Down
34 changes: 24 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
module github.com/pseudomuto/protoc-gen-doc

go 1.14
go 1.17

require (
github.com/Masterminds/semver v1.4.2 // indirect
github.com/Masterminds/sprig v2.15.0+incompatible
github.com/aokoli/goutils v1.0.1 // indirect
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b // indirect
github.com/envoyproxy/protoc-gen-validate v0.3.0-java
github.com/gogo/protobuf v1.1.1 // indirect
github.com/golang/protobuf v1.4.2
github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c // indirect
github.com/golang/protobuf v1.5.2
github.com/huandu/xstrings v1.0.0 // indirect
github.com/imdario/mergo v0.3.4 // indirect
github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0 // indirect
github.com/pseudomuto/protokit v0.2.0
github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1
golang.org/x/crypto v0.0.0-20180501155221-613d6eafa307 // indirect
golang.org/x/sync v0.0.0-20190412183630-56d357773e84 // indirect
google.golang.org/genproto v0.0.0-20181107211654-5fc9ac540362
gopkg.in/yaml.v2 v2.2.2 // indirect
github.com/stretchr/testify v1.6.1
google.golang.org/api v0.58.0
google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4
)

require (
cloud.google.com/go v0.94.1 // indirect
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678 // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/grpc v1.40.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
560 changes: 540 additions & 20 deletions go.sum

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ func (rt RenderType) renderer() (Processor, error) {
func (rt RenderType) template() ([]byte, error) {
switch rt {
case RenderTypeDocBook:
return fetchResource("docbook.tmpl")
return docbookTmpl, nil
case RenderTypeHTML:
return fetchResource("html.tmpl")
return htmlTmpl, nil
case RenderTypeJSON:
return nil, nil
case RenderTypeMarkdown:
return fetchResource("markdown.tmpl")
return markdownTmpl, nil
}

return nil, errors.New("Couldn't find template for render type")
Expand Down
50 changes: 11 additions & 39 deletions resources.go
Original file line number Diff line number Diff line change
@@ -1,44 +1,16 @@
// AUTOGENERATED CODE. DO NOT EDIT.

package gendoc

import (
"bytes"
"compress/gzip"
"encoding/base64"
"fmt"
"io"
_ "embed" // for including embedded resources
)

var embeddedResources = map[string]string{
"docbook.tmpl": "H4sIAAAAAAAA/+xZ3W/bNhB/z19BaC/bikodugDDQLvA7LnF0GZB3O2dls42MYrUSMqNoel/Hyiq+v5a7bhZkJcguvvxjryP39ESfnMfMnQAqajgM+cH95WDgPsioHw3c/74uHr5k/NmfoWJ1NRnML9CCGuqGcxvpdDCFwwthR+HwDXRVHDsWe0VQkkiCd8BcleUgUpTs1SBb1BGXRhKEveGhJCmlbVmdUQkQe4SlC9pZFZlJip2P4BSZJebLo0jGsycJHFXMWPWsGNNVj2+F3zX4XXIr9HRLXLfEbWiwAJVyLEmGwZoK0kIM4cwVjgsXGKfEaU4CVveSwWyZhsbMiZ2UsQR8gVTM+fHinGEsBFG4BvlJxro/cz53vFORrxyr8dBr5sQvQcSVCUIYSk+1SUIYeBaHufZabFnH7ohH48RDCPekw2wYUglk51A7DX2iL3WQbDeiKCxrlLftWoYPXil4If2jRnlfyHzB3hZ0SYkpqLzKrKP2DOw+bA9s8JEa8xvVuXfUh7APXJ/z+KmkBNAJMEnGgLnnwC2JGYabQlT8F2aYgijPVFUzZcFysVeIU0S4EGadraW7amltfgnYbE5jsHNc9nPKEmaei8D5GanJdXkK4PXE11PK/ZsqxV84WWdXXJD1ULBBr/ea+CGP8/PCDegNASo9DBCDteXIIfHQR9FTE6lkF+IGkHcxOEG5FdmmY4qG43RV2Katr2F4JpQTvmuYblU/Hc2s2kZp7MnxDrYq92gqqqyUHgcXu5OdC6my4I8Rm+vL0FvJ/KSOdv/gE5svM9OJae15aWaqqeN8oe+sV7/9VKUt/l585LBAVj/nMaUb4UMCRvsludJ/jzJnyf5k5rktb6fQj55jaxBHqj/Ze82Hn6Gd8zvD6D34nG8vHhwwrJnReOT/g7+jkFpNE5dd6AiwRVMgD44P+WpvAA55fFpMEkubdGIb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Ooz4aQqbf98VMrfAXbDig0fpgpgJhFkmCnA4oNDNSvXafvUtNG5KggnLYTu7svjYoR2s55OaR+dqsO9i6vxtEbUue/8CQAA//8z+wC/ohEAAA==",
}

func fetchResource(name string) ([]byte, error) {
raw, ok := embeddedResources[name]
if !ok {
return nil, fmt.Errorf("Could not find resource for '%s'", name)
}

compressed, err := base64.StdEncoding.DecodeString(raw)
if err != nil {
return nil, err
}

var out bytes.Buffer
buf := bytes.NewBuffer(compressed)

r, err := gzip.NewReader(buf)
if err != nil {
return nil, err
}

if _, err := io.Copy(&out, r); err != nil {
return nil, err
}

return out.Bytes(), nil
}
var (
//go:embed resources/docbook.tmpl
docbookTmpl []byte
//go:embed resources/html.tmpl
htmlTmpl []byte
//go:embed resources/markdown.tmpl
markdownTmpl []byte
//go:embed resources/scalars.json
scalarsJSON []byte
)
132 changes: 0 additions & 132 deletions resources/main.go

This file was deleted.

4 changes: 1 addition & 3 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ func NewTemplate(descs []*protokit.FileDescriptor) *Template {
}

func makeScalars() []*ScalarValue {
data, _ := fetchResource("scalars.json")

var scalars []*ScalarValue
json.Unmarshal(data, &scalars)
json.Unmarshal(scalarsJSON, &scalars)

return scalars
}
Expand Down

0 comments on commit 2dde019

Please sign in to comment.