Skip to content

Commit

Permalink
Merge pull request #16 from pwittrock/master
Browse files Browse the repository at this point in the history
Clean up docs generation
  • Loading branch information
Phillip Wittrock committed Mar 21, 2018
2 parents 5765d1a + c342968 commit e39db41
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
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

0 comments on commit e39db41

Please sign in to comment.