diff --git a/pkg/generate/docs.go b/pkg/generate/docs.go index 064fab1df6..895362214b 100644 --- a/pkg/generate/docs.go +++ b/pkg/generate/docs.go @@ -59,11 +59,13 @@ func DocForCommand(command *cobra.Command) (string, error) { if err := generateTitle(command, buf); err != nil { return "", errors.Wrap(err, "generating title") } + if err := rewriteFlags(command); err != nil { + return "", errors.Wrap(err, "rewriting flags") + } if err := writeSubcommands(command, buf); err != nil { return "", errors.Wrap(err, "writing subcommands") } - edited := removeHelpText(buf) - return rewriteFlags(command, edited), nil + return removeHelpText(buf), nil } // after every command, cobra automatically appends diff --git a/pkg/generate/docs_templates.go b/pkg/generate/docs_templates.go index 7e6bc94d34..f7f5048370 100644 --- a/pkg/generate/docs_templates.go +++ b/pkg/generate/docs_templates.go @@ -18,9 +18,6 @@ package generate var title = `--- title: "{{.Command}}" -linkTitle: "{{.Command}}" -weight: 1 -date: {{.Date}} description: > {{.Description}} --- diff --git a/pkg/generate/rewrite.go b/pkg/generate/rewrite.go index b289699903..e32825beb5 100644 --- a/pkg/generate/rewrite.go +++ b/pkg/generate/rewrite.go @@ -17,7 +17,7 @@ limitations under the License. package generate import ( - "strings" + "fmt" "github.com/spf13/cobra" ) @@ -30,42 +30,26 @@ type rewrite struct { // rewriteFlags rewrites flags that are dependent on operating system // for example, for `minikube start`, the description of --driver // outputs possible drivers for the operating system -func rewriteFlags(command *cobra.Command, contents string) string { +func rewriteFlags(command *cobra.Command) error { rewrites := map[string][]rewrite{ "start": []rewrite{{ - flag: "--driver", + flag: "driver", description: "Used to specify the driver to run kubernetes in. The list of available drivers depends on operating system.", }, { - flag: "--mount-string", + flag: "mount-string", description: "The argument to pass the minikube mount command on start.", }}, } rws, ok := rewrites[command.Name()] if !ok { - return contents + return nil } for _, r := range rws { - contents = rewriteFlag(contents, r.flag, r.description) - } - return contents -} - -func rewriteFlag(contents, flag, description string) string { - lines := strings.Split(contents, "\n") - for i, l := range lines { - if strings.Contains(l, flag) { - // docs start with a prefix of 6 spaces - replacement := " " - replacement += flag - // there are 36 spaces between the start of the flag name - // and the description - spacesBetween := 36 - len(flag) - for i := 0; i < spacesBetween; i++ { - replacement += " " - } - replacement += description - lines[i] = replacement + flag := command.Flag(r.flag) + if flag == nil { + return fmt.Errorf("--%s is not a valid flag for %s", r.flag, command.Name()) } + flag.Usage = r.description } - return strings.Join(lines, "\n") + return nil } diff --git a/site/content/en/docs/Reference/Commands/addons.md b/site/content/en/docs/Reference/Commands/addons.md index 53cb511426..ce54b0967e 100644 --- a/site/content/en/docs/Reference/Commands/addons.md +++ b/site/content/en/docs/Reference/Commands/addons.md @@ -1,8 +1,5 @@ --- title: "addons" -linkTitle: "addons" -weight: 1 -date: 2020-04-02 description: > Modify minikube's kubernetes addons --- diff --git a/site/content/en/docs/Reference/Commands/cache.md b/site/content/en/docs/Reference/Commands/cache.md index 4a0ced0fbc..d3e3cd1b9f 100644 --- a/site/content/en/docs/Reference/Commands/cache.md +++ b/site/content/en/docs/Reference/Commands/cache.md @@ -1,8 +1,5 @@ --- title: "cache" -linkTitle: "cache" -weight: 1 -date: 2020-04-02 description: > Add or delete an image from the local cache. --- diff --git a/site/content/en/docs/Reference/Commands/completion.md b/site/content/en/docs/Reference/Commands/completion.md index 872dc8fca4..38bec17318 100644 --- a/site/content/en/docs/Reference/Commands/completion.md +++ b/site/content/en/docs/Reference/Commands/completion.md @@ -1,8 +1,5 @@ --- title: "completion" -linkTitle: "completion" -weight: 1 -date: 2020-04-02 description: > Outputs minikube shell completion for the given shell (bash or zsh) --- diff --git a/site/content/en/docs/Reference/Commands/config.md b/site/content/en/docs/Reference/Commands/config.md index 81eb395045..2775a6e4ae 100644 --- a/site/content/en/docs/Reference/Commands/config.md +++ b/site/content/en/docs/Reference/Commands/config.md @@ -1,8 +1,5 @@ --- title: "config" -linkTitle: "config" -weight: 1 -date: 2020-04-02 description: > Modify minikube config --- diff --git a/site/content/en/docs/Reference/Commands/dashboard.md b/site/content/en/docs/Reference/Commands/dashboard.md index 23e3c39a95..e2aafc4e08 100644 --- a/site/content/en/docs/Reference/Commands/dashboard.md +++ b/site/content/en/docs/Reference/Commands/dashboard.md @@ -1,8 +1,5 @@ --- title: "dashboard" -linkTitle: "dashboard" -weight: 1 -date: 2020-04-02 description: > Access the kubernetes dashboard running within the minikube cluster --- diff --git a/site/content/en/docs/Reference/Commands/delete.md b/site/content/en/docs/Reference/Commands/delete.md index c025e6c244..f343bf524f 100644 --- a/site/content/en/docs/Reference/Commands/delete.md +++ b/site/content/en/docs/Reference/Commands/delete.md @@ -1,8 +1,5 @@ --- title: "delete" -linkTitle: "delete" -weight: 1 -date: 2020-04-02 description: > Deletes a local kubernetes cluster --- diff --git a/site/content/en/docs/Reference/Commands/docker-env.md b/site/content/en/docs/Reference/Commands/docker-env.md index e9e215e239..188051a6e1 100644 --- a/site/content/en/docs/Reference/Commands/docker-env.md +++ b/site/content/en/docs/Reference/Commands/docker-env.md @@ -1,8 +1,5 @@ --- title: "docker-env" -linkTitle: "docker-env" -weight: 1 -date: 2020-04-02 description: > Sets up docker env variables; similar to '$(docker-machine env)' --- diff --git a/site/content/en/docs/Reference/Commands/help.md b/site/content/en/docs/Reference/Commands/help.md index 7c4cc4b92a..717ec0445e 100644 --- a/site/content/en/docs/Reference/Commands/help.md +++ b/site/content/en/docs/Reference/Commands/help.md @@ -1,8 +1,5 @@ --- title: "help" -linkTitle: "help" -weight: 1 -date: 2020-04-02 description: > Help about any command --- diff --git a/site/content/en/docs/Reference/Commands/ip.md b/site/content/en/docs/Reference/Commands/ip.md index 1f6b4318e7..188312dad3 100644 --- a/site/content/en/docs/Reference/Commands/ip.md +++ b/site/content/en/docs/Reference/Commands/ip.md @@ -1,8 +1,5 @@ --- title: "ip" -linkTitle: "ip" -weight: 1 -date: 2020-04-02 description: > Retrieves the IP address of the running cluster --- diff --git a/site/content/en/docs/Reference/Commands/kubectl.md b/site/content/en/docs/Reference/Commands/kubectl.md index 3cc66801b3..6699f257a4 100644 --- a/site/content/en/docs/Reference/Commands/kubectl.md +++ b/site/content/en/docs/Reference/Commands/kubectl.md @@ -1,8 +1,5 @@ --- title: "kubectl" -linkTitle: "kubectl" -weight: 1 -date: 2020-04-02 description: > Run kubectl --- diff --git a/site/content/en/docs/Reference/Commands/logs.md b/site/content/en/docs/Reference/Commands/logs.md index 99ca38664a..097a87b3c4 100644 --- a/site/content/en/docs/Reference/Commands/logs.md +++ b/site/content/en/docs/Reference/Commands/logs.md @@ -1,8 +1,5 @@ --- title: "logs" -linkTitle: "logs" -weight: 1 -date: 2020-04-02 description: > Gets the logs of the running instance, used for debugging minikube, not user code. --- diff --git a/site/content/en/docs/Reference/Commands/mount.md b/site/content/en/docs/Reference/Commands/mount.md index f891009b77..afc671e778 100644 --- a/site/content/en/docs/Reference/Commands/mount.md +++ b/site/content/en/docs/Reference/Commands/mount.md @@ -1,8 +1,5 @@ --- title: "mount" -linkTitle: "mount" -weight: 1 -date: 2020-04-02 description: > Mounts the specified directory into minikube --- diff --git a/site/content/en/docs/Reference/Commands/node.md b/site/content/en/docs/Reference/Commands/node.md index 5ff4646afa..9aec995f71 100644 --- a/site/content/en/docs/Reference/Commands/node.md +++ b/site/content/en/docs/Reference/Commands/node.md @@ -1,8 +1,5 @@ --- title: "node" -linkTitle: "node" -weight: 1 -date: 2020-04-02 description: > Node operations --- diff --git a/site/content/en/docs/Reference/Commands/options.md b/site/content/en/docs/Reference/Commands/options.md index aea27a58b6..9536ffb349 100644 --- a/site/content/en/docs/Reference/Commands/options.md +++ b/site/content/en/docs/Reference/Commands/options.md @@ -1,8 +1,5 @@ --- title: "options" -linkTitle: "options" -weight: 1 -date: 2020-04-02 description: > Show a list of global command-line options (applies to all commands). --- diff --git a/site/content/en/docs/Reference/Commands/pause.md b/site/content/en/docs/Reference/Commands/pause.md index ee6598b95d..7a6bc5cbcb 100644 --- a/site/content/en/docs/Reference/Commands/pause.md +++ b/site/content/en/docs/Reference/Commands/pause.md @@ -1,8 +1,5 @@ --- title: "pause" -linkTitle: "pause" -weight: 1 -date: 2020-04-02 description: > pause containers --- diff --git a/site/content/en/docs/Reference/Commands/podman-env.md b/site/content/en/docs/Reference/Commands/podman-env.md index 72bda64e09..ab5e7769a8 100644 --- a/site/content/en/docs/Reference/Commands/podman-env.md +++ b/site/content/en/docs/Reference/Commands/podman-env.md @@ -1,8 +1,5 @@ --- title: "podman-env" -linkTitle: "podman-env" -weight: 1 -date: 2020-04-02 description: > Sets up podman env variables; similar to '$(podman-machine env)' --- diff --git a/site/content/en/docs/Reference/Commands/profile.md b/site/content/en/docs/Reference/Commands/profile.md index 79527f5c7f..8dc67629c6 100644 --- a/site/content/en/docs/Reference/Commands/profile.md +++ b/site/content/en/docs/Reference/Commands/profile.md @@ -1,8 +1,5 @@ --- title: "profile" -linkTitle: "profile" -weight: 1 -date: 2020-04-02 description: > Profile gets or sets the current minikube profile --- diff --git a/site/content/en/docs/Reference/Commands/service.md b/site/content/en/docs/Reference/Commands/service.md index 71ad7c1195..7b95e7b85e 100644 --- a/site/content/en/docs/Reference/Commands/service.md +++ b/site/content/en/docs/Reference/Commands/service.md @@ -1,8 +1,5 @@ --- title: "service" -linkTitle: "service" -weight: 1 -date: 2020-04-02 description: > Gets the kubernetes URL(s) for the specified service in your local cluster --- diff --git a/site/content/en/docs/Reference/Commands/ssh-key.md b/site/content/en/docs/Reference/Commands/ssh-key.md index 3b45143bd3..dba64aadbf 100644 --- a/site/content/en/docs/Reference/Commands/ssh-key.md +++ b/site/content/en/docs/Reference/Commands/ssh-key.md @@ -1,8 +1,5 @@ --- title: "ssh-key" -linkTitle: "ssh-key" -weight: 1 -date: 2020-04-02 description: > Retrieve the ssh identity key path of the specified cluster --- diff --git a/site/content/en/docs/Reference/Commands/ssh.md b/site/content/en/docs/Reference/Commands/ssh.md index 2a1ddc0f9f..d1d99ebe69 100644 --- a/site/content/en/docs/Reference/Commands/ssh.md +++ b/site/content/en/docs/Reference/Commands/ssh.md @@ -1,8 +1,5 @@ --- title: "ssh" -linkTitle: "ssh" -weight: 1 -date: 2020-04-02 description: > Log into or run a command on a machine with SSH; similar to 'docker-machine ssh' --- diff --git a/site/content/en/docs/Reference/Commands/start.md b/site/content/en/docs/Reference/Commands/start.md index 536e837b39..3e304014a1 100644 --- a/site/content/en/docs/Reference/Commands/start.md +++ b/site/content/en/docs/Reference/Commands/start.md @@ -1,8 +1,5 @@ --- title: "start" -linkTitle: "start" -weight: 1 -date: 2020-04-02 description: > Starts a local kubernetes cluster --- @@ -30,7 +27,7 @@ minikube start [flags] --apiserver-names stringArray A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine --apiserver-port int The apiserver listening port (default 8443) --auto-update-drivers If set, automatically updates drivers to the latest version. Defaults to true. (default true) - --driver Used to specify the driver to run kubernetes in. The list of available drivers depends on operating system. + --cache-images If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --driver=none. (default true) --container-runtime string The container runtime to be used (docker, crio, containerd). (default "docker") --cpus int Number of CPUs allocated to Kubernetes. (default 2) --cri-socket string The cri socket path to be used. @@ -42,7 +39,7 @@ minikube start [flags] --docker-env stringArray Environment variables to pass to the Docker daemon. (format: key=value) --docker-opt stringArray Specify arbitrary flags to pass to the Docker daemon. (format: key=value) --download-only If true, only download and cache files for later use - don't install or start anything. - --driver Used to specify the driver to run kubernetes in. The list of available drivers depends on operating system. + --driver string Used to specify the driver to run kubernetes in. The list of available drivers depends on operating system. --dry-run dry-run mode. Validates configuration, but does not mutate system state --embed-certs if true, will embed the certs in kubeconfig. --enable-default-cni Enable the default CNI plugin (/etc/cni/net.d/k8s.conf). Used in conjunction with "--network-plugin=cni". @@ -75,7 +72,7 @@ minikube start [flags] --kvm-qemu-uri string The KVM QEMU connection URI. (kvm2 driver only) (default "qemu:///system") --memory string Amount of RAM to allocate to Kubernetes (format: [], where unit = b, k, m or g). --mount This will start the mount daemon and automatically mount files into minikube. - --mount-string The argument to pass the minikube mount command on start. + --mount-string string The argument to pass the minikube mount command on start. (default "/Users:/minikube-host") --nat-nic-type string NIC Type used for host only network. One of Am79C970A, Am79C973, 82540EM, 82543GC, 82545EM, or virtio (virtualbox driver only) (default "virtio") --native-ssh Use native Golang SSH client (default true). Set to 'false' to use the command line 'ssh' command when accessing the docker machine. Useful for the machine drivers when they will not start with 'Waiting for SSH'. (default true) --network-plugin string The name of the network plugin. diff --git a/site/content/en/docs/Reference/Commands/status.md b/site/content/en/docs/Reference/Commands/status.md index 67da3ca3f4..fd1462f33d 100644 --- a/site/content/en/docs/Reference/Commands/status.md +++ b/site/content/en/docs/Reference/Commands/status.md @@ -1,8 +1,5 @@ --- title: "status" -linkTitle: "status" -weight: 1 -date: 2020-04-02 description: > Gets the status of a local kubernetes cluster --- diff --git a/site/content/en/docs/Reference/Commands/stop.md b/site/content/en/docs/Reference/Commands/stop.md index 21b7717fdb..08e190832b 100644 --- a/site/content/en/docs/Reference/Commands/stop.md +++ b/site/content/en/docs/Reference/Commands/stop.md @@ -1,8 +1,5 @@ --- title: "stop" -linkTitle: "stop" -weight: 1 -date: 2020-04-02 description: > Stops a running local kubernetes cluster --- diff --git a/site/content/en/docs/Reference/Commands/tunnel.md b/site/content/en/docs/Reference/Commands/tunnel.md index 4b2f73b544..72b73a316b 100644 --- a/site/content/en/docs/Reference/Commands/tunnel.md +++ b/site/content/en/docs/Reference/Commands/tunnel.md @@ -1,8 +1,5 @@ --- title: "tunnel" -linkTitle: "tunnel" -weight: 1 -date: 2020-04-02 description: > tunnel makes services of type LoadBalancer accessible on localhost --- diff --git a/site/content/en/docs/Reference/Commands/unpause.md b/site/content/en/docs/Reference/Commands/unpause.md index fc14d29c1a..3ae61076af 100644 --- a/site/content/en/docs/Reference/Commands/unpause.md +++ b/site/content/en/docs/Reference/Commands/unpause.md @@ -1,8 +1,5 @@ --- title: "unpause" -linkTitle: "unpause" -weight: 1 -date: 2020-04-02 description: > unpause Kubernetes --- diff --git a/site/content/en/docs/Reference/Commands/update-check.md b/site/content/en/docs/Reference/Commands/update-check.md index 0ac28ac4dc..c472068813 100644 --- a/site/content/en/docs/Reference/Commands/update-check.md +++ b/site/content/en/docs/Reference/Commands/update-check.md @@ -1,8 +1,5 @@ --- title: "update-check" -linkTitle: "update-check" -weight: 1 -date: 2020-04-02 description: > Print current and latest version number --- diff --git a/site/content/en/docs/Reference/Commands/update-context.md b/site/content/en/docs/Reference/Commands/update-context.md index cb3d1b1634..4e200a747b 100644 --- a/site/content/en/docs/Reference/Commands/update-context.md +++ b/site/content/en/docs/Reference/Commands/update-context.md @@ -1,8 +1,5 @@ --- title: "update-context" -linkTitle: "update-context" -weight: 1 -date: 2020-04-02 description: > Verify the IP address of the running cluster in kubeconfig. --- diff --git a/site/content/en/docs/Reference/Commands/version.md b/site/content/en/docs/Reference/Commands/version.md index ae8ffc28b3..4aeddee307 100644 --- a/site/content/en/docs/Reference/Commands/version.md +++ b/site/content/en/docs/Reference/Commands/version.md @@ -1,8 +1,5 @@ --- title: "version" -linkTitle: "version" -weight: 1 -date: 2020-04-02 description: > Print the version of minikube ---