Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions cmd/kubebuilder/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ kubebuilder docs
}

var generateConfig bool
var cleanup bool
var cleanup, verbose bool
var outputDir string

func AddDocs(cmd *cobra.Command) {
docsCmd.Flags().BoolVar(&cleanup, "cleanup", true, "If true, cleanup intermediary files")
docsCmd.Flags().BoolVar(&verbose, "verbose", true, "If true, use verbose output")
docsCmd.Flags().BoolVar(&generateConfig, "generate-config", true, "If true, generate the docs/reference/config.yaml.")
docsCmd.Flags().StringVar(&outputDir, "output-dir", filepath.Join("docs", "reference"), "Build docs into this directory")
cmd.AddCommand(docsCmd)
Expand Down Expand Up @@ -109,9 +110,11 @@ func RunDocs(cmd *cobra.Command, args []string) {
"-e", "OUTPUT="+outputDir,
"gcr.io/kubebuilder/gendocs",
)
log.Println(strings.Join(c.Args, " "))
c.Stderr = os.Stderr
c.Stdout = os.Stdout
if verbose {
log.Println(strings.Join(c.Args, " "))
c.Stderr = os.Stderr
c.Stdout = os.Stdout
}
err = c.Run()
if err != nil {
log.Fatalf("error: %v\n", err)
Expand All @@ -125,9 +128,11 @@ func RunDocs(cmd *cobra.Command, args []string) {
"-v", fmt.Sprintf("%s:%s", filepath.Join(wd, outputDir), "/manifest"),
"gcr.io/kubebuilder/brodocs",
)
log.Println(strings.Join(c.Args, " "))
c.Stderr = os.Stderr
c.Stdout = os.Stdout
if verbose {
log.Println(strings.Join(c.Args, " "))
c.Stderr = os.Stderr
c.Stdout = os.Stdout
}
err = c.Run()
if err != nil {
log.Fatalf("error: %v\n", err)
Expand All @@ -143,4 +148,6 @@ func RunDocs(cmd *cobra.Command, args []string) {
os.RemoveAll(filepath.Join(wd, outputDir, "build", "runbrodocs.sh"))
os.RemoveAll(filepath.Join(wd, outputDir, "build", "node_modules", "marked", "Makefile"))
}

fmt.Printf("Reference docs written to %s\n", filepath.Join(outputDir, "build", "index.html"))
}
8 changes: 6 additions & 2 deletions docs/creating_reference_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

## Build reference documentation

You may build Kubernetes style reference documentation for your APIs to `docs/reference/build/index.html` by
running `kubebuilder docs`.
You may build Kubernetes style reference documentation for your APIs to `docs/reference/build/index.html`


```go
kubebuilder docs
```

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