-
Notifications
You must be signed in to change notification settings - Fork 2.1k
docs: include required tools in source tree #4903
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,38 +2,22 @@ | |
|
|
||
| set -eu | ||
|
|
||
| : "${MD2MAN_VERSION=v2.0.6}" | ||
| : "${GO_MD2MAN:=go-md2man}" | ||
|
|
||
| export GO111MODULE=auto | ||
|
|
||
| function clean { | ||
| rm -rf "$buildir" | ||
| } | ||
|
|
||
| buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX) | ||
| trap clean EXIT | ||
| if ! command -v "$GO_MD2MAN" > /dev/null; then | ||
| ( | ||
| set -x | ||
| go build -mod=vendor -modfile=vendor.mod -o ./build/tools/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we have this check; perhaps I should even consider using a regular I'll leave that as a follow up I think |
||
| ) | ||
| GO_MD2MAN=$(realpath ./build/tools/go-md2man) | ||
| fi | ||
|
|
||
| mkdir -p man/man1 | ||
| ( | ||
| set -x | ||
| cp -r . "$buildir/" | ||
| cd "$buildir" | ||
| # init dummy go.mod | ||
| ./scripts/vendor init | ||
| # install go-md2man and copy man/tools.go in root folder | ||
| # to be able to fetch the required dependencies | ||
| go mod edit -modfile=vendor.mod -require=github.com/cpuguy83/go-md2man/v2@${MD2MAN_VERSION} | ||
| cp man/tools.go . | ||
| # update vendor | ||
| ./scripts/vendor update | ||
| # build gen-manpages | ||
| go build -mod=vendor -modfile=vendor.mod -tags manpages -o /tmp/gen-manpages ./man/generate.go | ||
| # build go-md2man | ||
| go build -mod=vendor -modfile=vendor.mod -o /tmp/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2 | ||
| go run -mod=vendor -modfile=vendor.mod -tags manpages ./man/generate.go --root "." --target "./man/man1" | ||
| ) | ||
|
|
||
| mkdir -p man/man1 | ||
| (set -x ; /tmp/gen-manpages --root "." --target "$(pwd)/man/man1") | ||
|
|
||
| ( | ||
| cd man | ||
| for FILE in *.md; do | ||
|
|
@@ -45,6 +29,9 @@ mkdir -p man/man1 | |
| continue | ||
| fi | ||
| mkdir -p "./man${num}" | ||
| (set -x ; /tmp/go-md2man -in "$FILE" -out "./man${num}/${name}") | ||
| ( | ||
| set -x ; | ||
| "$GO_MD2MAN" -in "$FILE" -out "./man${num}/${name}" | ||
| ) | ||
| done | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # This script is used to coerce certain commands which rely on the presence of | ||
| # a go.mod into working with our repository. It works by creating a fake | ||
| # go.mod, running a specified command (passed via arguments), and removing it | ||
| # when the command is finished. This script should be dropped when this | ||
| # repository is a proper Go module with a permanent go.mod. | ||
|
|
||
| set -e | ||
|
|
||
| SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| ROOTDIR="$(cd "${SCRIPTDIR}/.." && pwd)" | ||
|
|
||
| if test -e "${ROOTDIR}/go.mod"; then | ||
| { | ||
| scriptname=$(basename "$0") | ||
| cat >&2 <<- EOF | ||
| $scriptname: WARN: go.mod exists in the repository root! | ||
| $scriptname: WARN: Using your go.mod instead of our generated version -- this may misbehave! | ||
| EOF | ||
| } >&2 | ||
| else | ||
| set -x | ||
|
|
||
| tee "${ROOTDIR}/go.mod" >&2 <<- EOF | ||
| module github.com/docker/cli | ||
| go 1.23.0 | ||
| EOF | ||
|
Comment on lines
+25
to
+29
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should/could this instead be something like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh! Didn't do this one yet, might do so in a follow-up |
||
| trap 'rm -f "${ROOTDIR}/go.mod"' EXIT | ||
| fi | ||
|
|
||
| GO111MODULE=on GOTOOLCHAIN=local "$@" | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turned out I needed the
tools.goafter all (don't ask!) 🙈 😂