switch to cli-docs-tool for yaml docs generation

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
switch to cli-docs-tool and validate yamldocs

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2022-02-25 17:11:04 +01:00
parent 76a2a1945f
commit a650f4ddd0
16 changed files with 162 additions and 683 deletions

View File

@ -1,8 +1,34 @@
#!/usr/bin/env bash
# Generate yaml for docker/cli reference docs
set -eu -o pipefail
mkdir -p docs/yaml/gen
set -eu
GO111MODULE=off go build -o build/yaml-docs-generator github.com/docker/cli/docs/yaml
build/yaml-docs-generator --root "$(pwd)" --target "$(pwd)/docs/yaml/gen"
: "${CLI_DOCS_TOOL_VERSION=v0.3.1}"
export GO111MODULE=auto
function clean {
rm -rf "$buildir"
}
buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
trap clean EXIT
(
set -x
cp -r . "$buildir/"
cd "$buildir"
# init dummy go.mod
./scripts/vendor init
# install cli-docs-tool and copy docs/tools.go in root folder
# to be able to fetch the required depedencies
go mod edit -modfile=vendor.mod -require=github.com/docker/cli-docs-tool@${CLI_DOCS_TOOL_VERSION}
cp docs/tools.go .
# update vendor
./scripts/vendor update
# build docsgen
go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate.go
)
mkdir -p docs/yaml
set -x
/tmp/docsgen --source "$(pwd)/docs/reference/commandline" --target "$(pwd)/docs/yaml"

View File

@ -5,7 +5,7 @@ set -eu
TYP=$1
usage() {
echo "usage: ./scripts/vendor <update|validate|outdated>"
echo "usage: ./scripts/vendor <init|update|validate|outdated>"
exit 1
}
@ -13,12 +13,14 @@ if [ -z "$TYP" ]; then
usage
fi
# create dummy go.mod, see comment in vendor.mod
cat > go.mod <<EOL
init() {
# create dummy go.mod, see comment in vendor.mod
cat > go.mod <<EOL
module github.com/docker/cli
go 1.16
EOL
}
update() {
(set -x ; go mod tidy -modfile=vendor.mod; go mod vendor -modfile=vendor.mod)
@ -42,14 +44,20 @@ outdated() {
}
case $TYP in
"init")
init
;;
"update")
init
update
;;
"validate")
init
update
validate
;;
"outdated")
init
outdated
;;
*)