diff --git a/Makefile b/Makefile index 020a1c8..dd72cdd 100644 --- a/Makefile +++ b/Makefile @@ -20,8 +20,7 @@ PROTOC_GEN_VALIDATE_PROTO=${SUBMODULES_DIR}/protoc-gen-validate GOOGLE_OPENAPI_PROTO=${SUBMODULES_DIR}/gnostic/openapiv3 PROTO_OPTION=-I. -I${SUBMODULES_DIR} -I${GOOGLEAPIS_PROTO} -I${GOOGLEPROTOBUF_PROTO} -I${PROTOC_GEN_VALIDATE_PROTO} -I${GOOGLE_OPENAPI_PROTO} PROTO_DOCS_OPTS=${PROTO_OPTION} \ - --plugin=protoc-gen-doc=${BIN_DIR}/protoc-gen-doc \ - --doc_out=./docs + --plugin=protoc-gen-doc=${BIN_DIR}/protoc-gen-doc # GO PROTOC_GO_OPTS=${PROTO_OPTION} \ @@ -112,23 +111,23 @@ clean/go: @rm -rf ${GEN_GO_DIR} .PHONY: release/go -release/go: proto docs +release/go: proto @echo "Publishing go client..." @rm -rf ${TMP_REPO_DIR} && mkdir -p ${TMP_REPO_DIR} @git clone ${REPO}-go.git ${TMP_REPO_DIR}/client-go @cd ${TMP_REPO_DIR}/client-go && git clean -fdx #&& git checkout main @cp $(PWD)/scripts/go/go.mod ${TMP_REPO_DIR}/client-go/go.mod - @cp $(PWD)/docs/README.md ${TMP_REPO_DIR}/client-go/README.md + #@cp $(PWD)/docs/README.md ${TMP_REPO_DIR}/client-go/README.md @cp $(PWD)/CHANGELOG.md ${TMP_REPO_DIR}/client-go/CHANGELOG.md - @cp -R $(PWD)/gen/go/src ${TMP_REPO_DIR}/client-go + @cp -R $(PWD)/gen/go ${TMP_REPO_DIR}/client-go + @rm -rf ${TMP_REPO_DIR}/client-go/**openapi**.* @$(eval NEXT_VERSION=$(shell test $(NEXT_VERSION) && echo $(NEXT_VERSION) || echo $(LAST_TAG))) @cd ${TMP_REPO_DIR}/client-go && git add . && git commit -m "bump(version): $(NEXT_VERSION)" && git tag -a $(NEXT_VERSION) -m '$(NEXT_VERSION)' && git push --tags origin main .PHONY: docs docs: @echo "Generating docs..." - @rm -rf docs && mkdir -p docs - @find proto -name '*.proto' -print0 | xargs -0 -I{} -P${CPUS} protoc ${PROTO_DOCS_OPTS} --doc_opt=markdown,README.md {} + find proto -name '*.proto' -printf '%h\0' | sort -zu | xargs -0 -I{} -P${CPUS} bash -c "d={}; protoc ${PROTO_DOCS_OPTS} --doc_opt=./scripts/markdown.tmpl,README.md:google/* --doc_out=hoguera/platform/"'$$d'" hoguera/platform/"'$$d'"/*.proto" LINT_PLUGIN=${BIN_DIR}/protoc-gen-lint @@ -143,7 +142,7 @@ fmt: @find proto -type f -name "*.proto" | xargs -I{} -P${CPUS} clang-format -i {} .PHONY: changelog -changelog: +changelog: docs @echo "Generating changelog..." @$(eval NEXT_VERSION=$(shell test $(NEXT_VERSION) && echo $(NEXT_VERSION) || echo $(LAST_TAG) | awk -F. '{print $$1"."$$2+1".0"}')) @test $NEXT_VERSION || (echo "NEXT_VERSION is not set"; exit 1) diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index e84b850..0000000 --- a/docs/README.md +++ /dev/null @@ -1,244 +0,0 @@ -# Protocol Documentation - - -## Table of Contents - -- [proto/api/v1/mobile.proto](#proto_api_v1_mobile-proto) - - [Animal](#platform-api-v1-Animal) - - [AnimalsRequest](#platform-api-v1-AnimalsRequest) - - [AnimalsResponse](#platform-api-v1-AnimalsResponse) - - [AreaRequest](#platform-api-v1-AreaRequest) - - [AreaResponse](#platform-api-v1-AreaResponse) - - [Location](#platform-api-v1-Location) - - [LocationRequest](#platform-api-v1-LocationRequest) - - [LocationResponse](#platform-api-v1-LocationResponse) - - [V1Response](#platform-api-v1-V1Response) - - - [Condition](#platform-api-v1-Condition) - - - [Bff](#platform-api-v1-Bff) - - [Internal](#platform-api-v1-Internal) - -- [Scalar Value Types](#scalar-value-types) - - - - -

Top

- -## proto/api/v1/mobile.proto - - - - - -### Animal -Animals - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| name | [string](#string) | | | -| in_danger | [bool](#bool) | | | -| description | [string](#string) | | | - - - - - - - - -### AnimalsRequest - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| location | [Location](#platform-api-v1-Location) | | | - - - - - - - - -### AnimalsResponse - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| animals | [Animal](#platform-api-v1-Animal) | repeated | | - - - - - - - - -### AreaRequest - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| location | [Location](#platform-api-v1-Location) | | | - - - - - - - - -### AreaResponse - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| name | [string](#string) | | | -| condition | [Condition](#platform-api-v1-Condition) | | | -| temperature | [float](#float) | | | -| distance | [double](#double) | | | - - - - - - - - -### Location -Location - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| longitude | [int32](#int32) | | | -| latitude | [int32](#int32) | | | -| name | [string](#string) | | | - - - - - - - - -### LocationRequest - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| ip | [string](#string) | | | - - - - - - - - -### LocationResponse - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| location | [Location](#platform-api-v1-Location) | | | - - - - - - - - -### V1Response -BFF - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| location | [Location](#platform-api-v1-Location) | | | -| nearest_aquatic_location | [AreaResponse](#platform-api-v1-AreaResponse) | | | -| animals | [Animal](#platform-api-v1-Animal) | repeated | | - - - - - - - - - - -### Condition -Area - -| Name | Number | Description | -| ---- | ------ | ----------- | -| GOOD | 0 | | -| MODERATE | 1 | | -| CONTAMINATED | 2 | | -| UNKNOWN | 3 | | -| RADIATION | 4 | | -| DANGER | 5 | | -| PROTECTED | 6 | | - - - - - - - - - -### Bff -BFF service - -| Method Name | Request Type | Response Type | Description | -| ----------- | ------------ | ------------- | ------------| -| GetV1 | [.google.protobuf.Empty](#google-protobuf-Empty) | [V1Response](#platform-api-v1-V1Response) | | - - - - -### Internal -Internal service - -| Method Name | Request Type | Response Type | Description | -| ----------- | ------------ | ------------- | ------------| -| GetAnimals | [AnimalsRequest](#platform-api-v1-AnimalsRequest) | [AnimalsResponse](#platform-api-v1-AnimalsResponse) | | -| GetArea | [AreaRequest](#platform-api-v1-AreaRequest) | [AreaResponse](#platform-api-v1-AreaResponse) | | -| GetLocation | [LocationRequest](#platform-api-v1-LocationRequest) | [LocationResponse](#platform-api-v1-LocationResponse) | | - - - - - -## Scalar Value Types - -| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | -| ----------- | ----- | --- | ---- | ------ | -- | -- | --- | ---- | -| double | | double | double | float | float64 | double | float | Float | -| float | | float | float | float | float32 | float | float | Float | -| int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) | -| uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) | -| sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required) | -| fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum | -| sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | -| sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum | -| bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | -| string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) | -| bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) | - diff --git a/proto/greenspace/api/v1/README.md b/proto/greenspace/api/v1/README.md new file mode 100644 index 0000000..1dd8aea --- /dev/null +++ b/proto/greenspace/api/v1/README.md @@ -0,0 +1,207 @@ +# Documentation + + + +## Reference + +[hoguera/platform/proto/greenspace/api/v1/mobile.proto](#hoguera/platform/proto/greenspace/api/v1/mobile.proto) +
+Click to show + +### Messages + - [Animal](#hoguera.platform.greenspace.api.v1.Animal) + - [AnimalsRequest](#hoguera.platform.greenspace.api.v1.AnimalsRequest) + - [CoastRequest](#hoguera.platform.greenspace.api.v1.CoastRequest) + - [CoastResponse](#hoguera.platform.greenspace.api.v1.CoastResponse) + - [LocationRequest](#hoguera.platform.greenspace.api.v1.LocationRequest) + - [LocationResponse](#hoguera.platform.greenspace.api.v1.LocationResponse) + - [V1Response](#hoguera.platform.greenspace.api.v1.V1Response) + +### Enums + - [Condition](#hoguera.platform.greenspace.api.v1.Condition) + + +
+ + + +## Services + + +
+ +### Bff +BFF service + +| Method Name | Description | +| ----------- | ------------| +| `GetV1`

Request: [.google.protobuf.Empty](#google.protobuf.Empty)
Response: [V1Response](#google.protobuf.Empty) | | + + +
+ +### Internal +Internal service + +| Method Name | Description | +| ----------- | ------------| +| `GetAnimals`

Request: [AnimalsRequest](#hoguera.platform.greenspace.api.v1.AnimalsRequest)
Response: [Animal](#hoguera.platform.greenspace.api.v1.AnimalsRequest) | | +| `GetCoast`

Request: [CoastRequest](#hoguera.platform.greenspace.api.v1.CoastRequest)
Response: [CoastResponse](#hoguera.platform.greenspace.api.v1.CoastRequest) | | +| `GetLocation`

Request: [LocationRequest](#hoguera.platform.greenspace.api.v1.LocationRequest)
Response: [LocationResponse](#hoguera.platform.greenspace.api.v1.LocationRequest) | | + + + + + + +
+

Top

+ +## hoguera/platform/proto/greenspace/api/v1/mobile.proto + + + + + +### Animal +Animals + + +#### Fields + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| name | [string](#string) | | | +| in_danger | [bool](#bool) | | | +| description | [string](#string) | | | + + + + + + +### AnimalsRequest +*Description comment will be shown here (markdown supported)* + + +#### Fields + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| location | [LocationResponse](#hoguera.platform.greenspace.api.v1.LocationResponse) | | | + + + + + + +### CoastRequest +*Description comment will be shown here (markdown supported)* + + +#### Fields + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| location | [LocationResponse](#hoguera.platform.greenspace.api.v1.LocationResponse) | | | + + + + + + +### CoastResponse +*Description comment will be shown here (markdown supported)* + + +#### Fields + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| name | [string](#string) | | | +| condition | [Condition](#hoguera.platform.greenspace.api.v1.Condition) | | | +| temperature | [float](#float) | | | +| distance | [double](#double) | | | + + + + + + +### LocationRequest +*Description comment will be shown here (markdown supported)* + + +#### Fields + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| ip | [string](#string) | | | + + + + + + +### LocationResponse +Location + + +#### Fields + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| longitude | [int32](#int32) | | | +| latitude | [int32](#int32) | | | +| name | [string](#string) | | | + + + + + + +### V1Response +BFF + + +#### Fields + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| location | [LocationResponse](#hoguera.platform.greenspace.api.v1.LocationResponse) | | | +| nearest_aquatic_location | [CoastResponse](#hoguera.platform.greenspace.api.v1.CoastResponse) | | | +| animals | [Animal](#hoguera.platform.greenspace.api.v1.Animal) | repeated | | + + + + + + + + + +### Condition +Coast + + +
+Click to show + +| Name | Number | Description | +| ---- | ------ | ----------- | +| GOOD | 0 | | +| MODERATE | 1 | | +| CONTAMINATED | 2 | | +| UNKNOWN | 3 | | +| RADIATION | 4 | | +| DANGER | 5 | | +| PROTECTED | 6 | | + +
+ + + + + + + diff --git a/proto/greenspace/api/v1/mobile.proto b/proto/greenspace/api/v1/mobile.proto index 7acb993..6ce3e08 100644 --- a/proto/greenspace/api/v1/mobile.proto +++ b/proto/greenspace/api/v1/mobile.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -package platform.api.v1; +package hoguera.platform.greenspace.api.v1; -option go_package = "src/api/v1;mobile"; +option go_package = "greenspace/api/v1;mobile"; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; diff --git a/scripts/markdown.tmpl b/scripts/markdown.tmpl new file mode 100644 index 0000000..1676983 --- /dev/null +++ b/scripts/markdown.tmpl @@ -0,0 +1,127 @@ +# Documentation +
+ +{{/* ------ Overall Reference ------ */}} +## Reference +{{range .Files}} +{{$file_name := .Name}}[{{.Name}}](#{{.Name}}) +
+Click to show + +### Messages +{{range .Messages}} - [{{.LongName}}](#{{.FullName}}) +{{end}} +### Enums +{{range .Enums}} - [{{.LongName}}](#{{.FullName}}) +{{end}} +{{range .Extensions}} - [File-level Extensions](#{{$file_name}}-extensions) +{{end}} +
+{{end}} + +{{/* ------ Service and Methods ------ */}} +## Services +{{range .Files}} +{{range .Services}} +
+ +### {{.Name}} + +{{- if .Description}} +{{.Description}} +{{- else}} +*Description comment will be shown here* +{{- end}} + +| Method Name | Description | +| ----------- | ------------| +{{range .Methods -}} +| `{{.Name}}`

Request: [{{.RequestLongType}}](#{{.RequestFullType}})
Response: [{{.ResponseLongType}}](#{{.RequestFullType}}) | {{para .Description | replace "|" "\\|"}} | +{{end}} +{{end}} +{{end}} + +{{range .Files}} +{{$file_name := .Name}} +
+

Top

+ +## {{.Name}} +{{.Description}} + +{{/* ------ Messages ------ */}} +{{- range .Messages}} + + +### {{.LongName}} + +{{- if .Description}} +{{.Description}} +{{- else}} +*Description comment will be shown here (markdown supported)* +{{- end}} + +{{if .HasFields}} +#### Fields + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +{{range .Fields -}} + | {{.Name}} | [{{.LongType}}](#{{.FullType}}) | {{.Label}} | {{para .Description | replace "|" "\\|"}}{{if .DefaultValue}} Default: {{.DefaultValue}}{{end}} | +{{end}} +{{end}} + +{{if .HasExtensions}} +| Extension | Type | Base | Number | Description | +| --------- | ---- | ---- | ------ | ----------- | +{{range .Extensions -}} + | {{.Name}} | {{.LongType}} | {{.ContainingLongType}} | {{.Number}} | {{para .Description | replace "|" "\\|"}}{{if .DefaultValue}} Default: {{.DefaultValue}}{{end}} | +{{end}} +{{end}} + +{{- end}} + +{{/* ------ Enums ------ */}} +{{range .Enums}} + + +### {{.LongName}} + +{{- if .Description}} +{{.Description}} +{{- else}} +*Description comment will be shown here (markdown supported)* +{{- end}} + +{{$lengths := len .Values}}{{if gt $lengths 5}} +
+Click to show + +| Name | Number | Description | +| ---- | ------ | ----------- | +{{range .Values -}} + | {{.Name}} | {{.Number}} | {{para .Description | replace "|" "\\|"}} | +{{end}} +
+{{else}} +| Name | Number | Description | +| ---- | ------ | ----------- | +{{range .Values -}} + | {{.Name}} | {{.Number}} | {{para .Description | replace "|" "\\|"}} | +{{end}} +{{end}} + +{{end}} + +{{if .HasExtensions}} +
+ +### File-level Extensions +| Extension | Type | Base | Number | Description | +| --------- | ---- | ---- | ------ | ----------- | +{{range .Extensions -}} + | {{.Name}} | {{.LongType}} | {{.ContainingLongType}} | {{.Number}} | {{para .Description | replace "|" "\\|"}}{{if .DefaultValue}} Default: `{{.DefaultValue}}`{{end}} | +{{end}} +{{end}} + +{{end}}