From ff615dbc4d01b0115e4658ee1a0ed6809b5f88ae Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Wed, 10 May 2017 18:24:32 -0700 Subject: [PATCH] Add scripts and targets for manpages and yamldocs Signed-off-by: Tibor Vass --- .gitignore | 4 ++++ Makefile | 16 +++++++++++++--- docker.Makefile | 12 +++++++++++- man/generate.sh => scripts/docs/generate-man.sh | 10 ++++++++++ scripts/docs/generate-yaml.sh | 5 +++++ scripts/test/unit-with-coverage | 2 +- 6 files changed, 44 insertions(+), 5 deletions(-) rename man/generate.sh => scripts/docs/generate-man.sh (53%) create mode 100755 scripts/docs/generate-yaml.sh diff --git a/.gitignore b/.gitignore index 09d363d1ce..fa99439ac8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,9 @@ /build/ cli/winresources/rsrc_386.syso cli/winresources/rsrc_amd64.syso +/man/man1/ +/man/man5/ +/man/man8/ +/docs/yaml/gen/ coverage.txt profile.out diff --git a/Makefile b/Makefile index b9180d4e02..dda6df868f 100644 --- a/Makefile +++ b/Makefile @@ -6,17 +6,17 @@ all: binary # remove build artifacts .PHONY: clean clean: - rm -rf ./build/* cli/winresources/rsrc_* + rm -rf ./build/* cli/winresources/rsrc_* ./man/man[1-9] docs/yaml/gen # run go test # the "-tags daemon" part is temporary .PHONY: test test: - ./scripts/test/unit $(shell go list ./... | grep -v /vendor/) + ./scripts/test/unit $(shell go list ./... | grep -v '/vendor/') .PHONY: test-coverage test-coverage: - ./scripts/test/unit-with-coverage + ./scripts/test/unit-with-coverage $(shell go list ./... | grep -v '/vendor/') .PHONY: lint lint: @@ -44,6 +44,16 @@ vendor: vendor.conf vndr 2> /dev/null scripts/validate/check-git-diff vendor +## generate man pages from go source and markdown +.PHONY: manpages +manpages: + scripts/dos/generate-man.sh + +## generate documentation YAML files consumed by docs repo +.PHONY: yamldocs +yamldocs: + scripts/docs/generate-yaml.sh + cli/compose/schema/bindata.go: cli/compose/schema/data/*.json go generate github.com/docker/cli/cli/compose/schema diff --git a/docker.Makefile b/docker.Makefile index 765b3a6f96..1e5319bb23 100644 --- a/docker.Makefile +++ b/docker.Makefile @@ -69,4 +69,14 @@ vendor: build_docker_image vendor.conf docker run -ti --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make vendor dynbinary: build_cross_image - docker run --rm $(ENVVARS) $(MOUNTS) $(CROSS_IMAGE_NAME) make dynbinary + docker run -ti --rm $(ENVVARS) $(MOUNTS) $(CROSS_IMAGE_NAME) make dynbinary + +## generate man pages from go source and markdown +.PHONY: manpages +manpages: build_docker_image + docker run -ti --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make manpages + +## Generate documentation YAML files consumed by docs repo +.PHONY: yamldocs +yamldocs: build_docker_image + docker run -ti --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make yamldocs diff --git a/man/generate.sh b/scripts/docs/generate-man.sh similarity index 53% rename from man/generate.sh rename to scripts/docs/generate-man.sh index 905b2d7baf..e955130559 100755 --- a/man/generate.sh +++ b/scripts/docs/generate-man.sh @@ -7,6 +7,16 @@ set -eu mkdir -p ./man/man1 +MD2MAN_REPO=github.com/cpuguy83/go-md2man +MD2MAN_COMMIT=$(grep -F "$MD2MAN_REPO" vendor.conf | cut -d' ' -f2) + +( + go get -d "$MD2MAN_REPO" + cd "$GOPATH"/src/"$MD2MAN_REPO" + git checkout "$MD2MAN_COMMIT" &> /dev/null + go install "$MD2MAN_REPO" +) + # Generate man pages from cobra commands go build -o /tmp/gen-manpages ./man /tmp/gen-manpages --root . --target ./man/man1 diff --git a/scripts/docs/generate-yaml.sh b/scripts/docs/generate-yaml.sh new file mode 100755 index 0000000000..c322071bcf --- /dev/null +++ b/scripts/docs/generate-yaml.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +go build -o build/yaml-docs-generator github.com/docker/cli/docs/yaml +mkdir docs/yaml/gen +build/yaml-docs-generator --root $(pwd) --target $(pwd)/docs/yaml/gen diff --git a/scripts/test/unit-with-coverage b/scripts/test/unit-with-coverage index 9073e2daf6..8c599b43ff 100755 --- a/scripts/test/unit-with-coverage +++ b/scripts/test/unit-with-coverage @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eu -o pipefail -for pkg in $(go list ./... | grep -v /vendor/); do +for pkg in $@; do ./scripts/test/unit \ -cover \ -coverprofile=profile.out \