Skip to content

Commit e39db41

Browse files
author
Phillip Wittrock
authored
Merge pull request #16 from pwittrock/master
Clean up docs generation
2 parents 5765d1a + c342968 commit e39db41

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

cmd/kubebuilder/docs/docs.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ kubebuilder docs
5757
}
5858

5959
var generateConfig bool
60-
var cleanup bool
60+
var cleanup, verbose bool
6161
var outputDir string
6262

6363
func AddDocs(cmd *cobra.Command) {
6464
docsCmd.Flags().BoolVar(&cleanup, "cleanup", true, "If true, cleanup intermediary files")
65+
docsCmd.Flags().BoolVar(&verbose, "verbose", true, "If true, use verbose output")
6566
docsCmd.Flags().BoolVar(&generateConfig, "generate-config", true, "If true, generate the docs/reference/config.yaml.")
6667
docsCmd.Flags().StringVar(&outputDir, "output-dir", filepath.Join("docs", "reference"), "Build docs into this directory")
6768
cmd.AddCommand(docsCmd)
@@ -109,9 +110,11 @@ func RunDocs(cmd *cobra.Command, args []string) {
109110
"-e", "OUTPUT="+outputDir,
110111
"gcr.io/kubebuilder/gendocs",
111112
)
112-
log.Println(strings.Join(c.Args, " "))
113-
c.Stderr = os.Stderr
114-
c.Stdout = os.Stdout
113+
if verbose {
114+
log.Println(strings.Join(c.Args, " "))
115+
c.Stderr = os.Stderr
116+
c.Stdout = os.Stdout
117+
}
115118
err = c.Run()
116119
if err != nil {
117120
log.Fatalf("error: %v\n", err)
@@ -125,9 +128,11 @@ func RunDocs(cmd *cobra.Command, args []string) {
125128
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir), "/manifest"),
126129
"gcr.io/kubebuilder/brodocs",
127130
)
128-
log.Println(strings.Join(c.Args, " "))
129-
c.Stderr = os.Stderr
130-
c.Stdout = os.Stdout
131+
if verbose {
132+
log.Println(strings.Join(c.Args, " "))
133+
c.Stderr = os.Stderr
134+
c.Stdout = os.Stdout
135+
}
131136
err = c.Run()
132137
if err != nil {
133138
log.Fatalf("error: %v\n", err)
@@ -143,4 +148,6 @@ func RunDocs(cmd *cobra.Command, args []string) {
143148
os.RemoveAll(filepath.Join(wd, outputDir, "build", "runbrodocs.sh"))
144149
os.RemoveAll(filepath.Join(wd, outputDir, "build", "node_modules", "marked", "Makefile"))
145150
}
151+
152+
fmt.Printf("Reference docs written to %s\n", filepath.Join(outputDir, "build", "index.html"))
146153
}

docs/creating_reference_documentation.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
## Build reference documentation
44

5-
You may build Kubernetes style reference documentation for your APIs to `docs/reference/build/index.html` by
6-
running `kubebuilder docs`.
5+
You may build Kubernetes style reference documentation for your APIs to `docs/reference/build/index.html`
6+
7+
8+
```go
9+
kubebuilder docs
10+
```
711

812
**Note:** There is currently an issue where building docs does not work if multiple versions of APIs for the
913
same group are defined.

0 commit comments

Comments
 (0)