Merge pull request #4140 from thaJeztah/man_man_man

man: move ctr.1 and containerd-config to section 8
This commit is contained in:
Phil Estes 2020-04-03 11:02:41 -04:00 committed by GitHub
commit 1512f0dc29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 18 deletions

View File

@ -88,7 +88,7 @@ endif
# Project binaries.
COMMANDS=ctr containerd containerd-stress
MANPAGES=ctr.1 containerd.8 containerd-config.1 containerd-config.toml.5
MANPAGES=ctr.8 containerd.8 containerd-config.8 containerd-config.toml.5
ifdef BUILDTAGS
GO_BUILDTAGS = ${BUILDTAGS}
@ -214,15 +214,15 @@ mandir:
@mkdir -p man
# Kept for backwards compatability
genman: man/containerd.8 man/ctr.1
genman: man/containerd.8 man/ctr.8
man/containerd.8: FORCE
@echo "$(WHALE) $@"
go run cmd/gen-manpages/main.go containerd man/
go run cmd/gen-manpages/main.go $(@F) $(@D)
man/ctr.1: FORCE
man/ctr.8: FORCE
@echo "$(WHALE) $@"
go run cmd/gen-manpages/main.go ctr man/
go run cmd/gen-manpages/main.go $(@F) $(@D)
man/%: docs/man/%.md FORCE
@echo "$(WHALE) $@"

View File

@ -22,6 +22,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/containerd/containerd/cmd/containerd/command"
"github.com/containerd/containerd/cmd/ctr/app"
@ -41,22 +42,28 @@ func run() error {
"containerd": command.App(),
"ctr": app.New(),
}
name := flag.Arg(0)
dir := flag.Arg(1)
app, ok := apps[name]
if !ok {
return fmt.Errorf("Invalid application '%s'", name)
parts := strings.SplitN(flag.Arg(0), ".", 2)
if len(parts) != 2 {
return fmt.Errorf("invalid name '%s': name does not contain man page section", flag.Arg(0))
}
name, section := parts[0], parts[1]
appName, ok := apps[name]
if !ok {
return fmt.Errorf("invalid application '%s'", name)
}
// clear out the usage as we use banners that do not display in man pages
app.Usage = ""
data, err := app.ToMan()
appName.Usage = ""
appName.ToMan()
data, err := appName.ToMan()
if err != nil {
return err
}
if _, err := os.Stat(dir); os.IsNotExist(err) {
os.Mkdir(dir, os.ModePerm)
}
if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.1", name)), []byte(data), 0644); err != nil {
_ = os.MkdirAll(dir, os.ModePerm)
if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.%s", name, section)), []byte(data), 0644); err != nil {
return err
}
return nil

View File

@ -1,4 +1,4 @@
# containerd-config 1 01/30/2018
# containerd-config 8 01/30/2018
## NAME
@ -38,4 +38,4 @@ Phil Estes <estesp@gmail.com>
## SEE ALSO
ctr(1), containerd(8), containerd-config.toml(5)
ctr(8), containerd(8), containerd-config.toml(5)

View File

@ -142,4 +142,4 @@ Phil Estes <estesp@gmail.com>
## SEE ALSO
ctr(1), containerd-config(1), containerd(8)
ctr(8), containerd-config(8), containerd(8)