Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-22.1: docs: generate swagger docs w/ bazel #79259

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/generated/bazel_targets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ documentation. Lines not beginning with // should be ignored.
//docs/generated/settings:settings_for_tenants
//docs/generated/sql
//docs/generated/sql/bnf
//docs/generated/swagger
26 changes: 26 additions & 0 deletions docs/generated/swagger/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@io_bazel_rules_go//go:def.bzl", "go_path")

genrule(
name = "swagger",
srcs = [
":swagger_go_path",
],
outs = ["spec.json"],
cmd = """
GO_REL_PATH=`dirname $(location @go_sdk//:bin/go)`
GO_ABS_PATH=`cd $$GO_REL_PATH && pwd`
env PATH=$$GO_ABS_PATH HOME=$(GENDIR) GOPATH=$$(cd $(location :swagger_go_path) && pwd) GO111MODULE=off \
$(location @com_github_go_swagger_go_swagger//cmd/swagger) generate spec -w $(location :swagger_go_path)/src/github.com/cockroachdb/cockroach/pkg --scan-models -t bazel -o $@
""",
exec_tools = [
"@com_github_go_swagger_go_swagger//cmd/swagger",
"@go_sdk//:bin/go",
],
)

go_path(
name = "swagger_go_path",
deps = [
"//pkg/server",
],
)
1 change: 1 addition & 0 deletions pkg/cmd/dev/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ var buildTargetMapping = map[string]string{
"short": "//pkg/cmd/cockroach-short:cockroach-short",
"staticcheck": "@co_honnef_go_tools//cmd/staticcheck:staticcheck",
"stress": stressTarget,
"swagger": "@com_github_go_swagger_go_swagger//cmd/swagger:swagger",
"workload": "//pkg/cmd/workload:workload",
}

Expand Down
1 change: 1 addition & 0 deletions pkg/gen/docs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ DOCS_SRCS = [
"//docs/generated/sql:functions.md",
"//docs/generated/sql:operators.md",
"//docs/generated/sql:window_functions.md",
"//docs/generated/swagger:spec.json",
"//docs/generated:eventlog.md",
"//docs/generated:logformats.md",
"//docs/generated:logging.md",
Expand Down