Skip to content

Commit ad090e6

Browse files
committed
man: move ctr.1, containerd-config to section 8, and fix generation
I missed this in my previous change: the ctr man page is also in Section 8, because it's considered an administrative tool, and containerd-config is related to containerd so updating these as well. This commit also fixes naming of the generated files, which was hard-coded to .1. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 9ba5ea2 commit ad090e6

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ endif
8888

8989
# Project binaries.
9090
COMMANDS=ctr containerd containerd-stress
91-
MANPAGES=ctr.1 containerd.8 containerd-config.1 containerd-config.toml.5
91+
MANPAGES=ctr.8 containerd.8 containerd-config.8 containerd-config.toml.5
9292

9393
ifdef BUILDTAGS
9494
GO_BUILDTAGS = ${BUILDTAGS}
@@ -214,15 +214,15 @@ mandir:
214214
@mkdir -p man
215215

216216
# Kept for backwards compatability
217-
genman: man/containerd.8 man/ctr.1
217+
genman: man/containerd.8 man/ctr.8
218218

219219
man/containerd.8: FORCE
220220
@echo "$(WHALE) $@"
221-
go run cmd/gen-manpages/main.go containerd man/
221+
go run cmd/gen-manpages/main.go $(@F) $(@D)
222222

223-
man/ctr.1: FORCE
223+
man/ctr.8: FORCE
224224
@echo "$(WHALE) $@"
225-
go run cmd/gen-manpages/main.go ctr man/
225+
go run cmd/gen-manpages/main.go $(@F) $(@D)
226226

227227
man/%: docs/man/%.md FORCE
228228
@echo "$(WHALE) $@"

cmd/gen-manpages/main.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io/ioutil"
2323
"os"
2424
"path/filepath"
25+
"strings"
2526

2627
"github.com/containerd/containerd/cmd/containerd/command"
2728
"github.com/containerd/containerd/cmd/ctr/app"
@@ -41,22 +42,28 @@ func run() error {
4142
"containerd": command.App(),
4243
"ctr": app.New(),
4344
}
44-
name := flag.Arg(0)
4545
dir := flag.Arg(1)
46-
app, ok := apps[name]
46+
47+
parts := strings.SplitN(flag.Arg(0), ".", 2)
48+
if len(parts) != 2 {
49+
return fmt.Errorf("invalid name '%s': name does not contain man page section", flag.Arg(0))
50+
}
51+
name, section := parts[0], parts[1]
52+
53+
appName, ok := apps[name]
4754
if !ok {
48-
return fmt.Errorf("Invalid application '%s'", name)
55+
return fmt.Errorf("invalid application '%s'", name)
4956
}
57+
5058
// clear out the usage as we use banners that do not display in man pages
51-
app.Usage = ""
52-
data, err := app.ToMan()
59+
appName.Usage = ""
60+
appName.ToMan()
61+
data, err := appName.ToMan()
5362
if err != nil {
5463
return err
5564
}
56-
if _, err := os.Stat(dir); os.IsNotExist(err) {
57-
os.Mkdir(dir, os.ModePerm)
58-
}
59-
if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.1", name)), []byte(data), 0644); err != nil {
65+
_ = os.MkdirAll(dir, os.ModePerm)
66+
if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.%s", name, section)), []byte(data), 0644); err != nil {
6067
return err
6168
}
6269
return nil
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# containerd-config 1 01/30/2018
1+
# containerd-config 8 01/30/2018
22

33
## NAME
44

@@ -38,4 +38,4 @@ Phil Estes <estesp@gmail.com>
3838

3939
## SEE ALSO
4040

41-
ctr(1), containerd(8), containerd-config.toml(5)
41+
ctr(8), containerd(8), containerd-config.toml(5)

docs/man/containerd-config.toml.5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ Phil Estes <estesp@gmail.com>
142142

143143
## SEE ALSO
144144

145-
ctr(1), containerd-config(1), containerd(8)
145+
ctr(8), containerd-config(8), containerd(8)

0 commit comments

Comments
 (0)