Skip to content

Commit

Permalink
Add command docs and job to check it (#211)
Browse files Browse the repository at this point in the history
* add command docs

Signed-off-by: cpanato <ctadeu@gmail.com>

* add job to check command doc

Signed-off-by: cpanato <ctadeu@gmail.com>

* avoid dynamic docs and expand the path later

Signed-off-by: cpanato <ctadeu@gmail.com>

Signed-off-by: cpanato <ctadeu@gmail.com>
  • Loading branch information
cpanato authored Sep 19, 2022
1 parent 0d2238d commit 2d923ec
Show file tree
Hide file tree
Showing 17 changed files with 470 additions and 10 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,27 @@ jobs:
version: v1.13.0
args: -v ci

check-docs:
name: check-docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v3
with:
go-version-file: './go.mod'
check-latest: true

- name: generate docs
run: |
go build -o cr-bin ./cr/main.go
./cr-bin doc-gen
git_status="$(git status --porcelain)"
if [[ ${git_status} ]]; then
echo -e 'Documentation is outdated. Please update the docs\n'
echo "${git_status}"
exit 1
fi
golangci:
name: lint
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ chart-releaser
/dist
/vendor
.vscode
/cr-bin
51 changes: 51 additions & 0 deletions cr/cmd/docGen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright The Helm Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
"fmt"

"github.com/MakeNowJust/heredoc"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

var generateDocsCmd = &cobra.Command{
Use: "doc-gen",
Short: "Generate documentation",
Long: heredoc.Doc(`
Generate documentation for all commands
to the 'docs' directory.`),
Hidden: true,
RunE: generateDocs,
}

func generateDocs(cmd *cobra.Command, args []string) error {
fmt.Println("Generating docs...")

err := doc.GenMarkdownTree(rootCmd.Root(), "doc")
if err != nil {
return err
}

fmt.Println("Done.")
return nil
}

func init() {
rootCmd.AddCommand(generateDocsCmd)

rootCmd.DisableAutoGenTag = true
}
10 changes: 1 addition & 9 deletions cr/cmd/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
package cmd

import (
"path/filepath"

"github.com/helm/chart-releaser/pkg/config"
"github.com/helm/chart-releaser/pkg/packager"
"github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -55,15 +52,10 @@ func getRequiredPackageArgs() []string {
}

func init() {
dir, err := homedir.Dir()
if err != nil {
panic(err)
}

rootCmd.AddCommand(packageCmd)
packageCmd.Flags().StringP("package-path", "p", ".cr-release-packages", "Path to directory with chart packages")
packageCmd.Flags().Bool("sign", false, "Use a PGP private key to sign this package")
packageCmd.Flags().String("key", "", "Name of the key to use when signing")
packageCmd.Flags().String("keyring", filepath.Join(dir, ".gnupg", "pubring.gpg"), "Location of a public keyring")
packageCmd.Flags().String("keyring", "~/.gnupg/pubring.gpg", "Location of a public keyring")
packageCmd.Flags().String("passphrase-file", "", "Location of a file which contains the passphrase for the signing key. Use '-' in order to read from stdin")
}
26 changes: 26 additions & 0 deletions doc/cr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## cr

Helm Chart Repos on Github Pages

### Synopsis


Create Helm chart repositories on GitHub Pages by uploading Chart packages
and Chart metadata to GitHub Releases and creating a suitable index file


### Options

```
--config string Config file (default is $HOME/.cr.yaml)
-h, --help help for cr
```

### SEE ALSO

* [cr completion](cr_completion.md) - Generate the autocompletion script for the specified shell
* [cr index](cr_index.md) - Update Helm repo index.yaml for the given GitHub repo
* [cr package](cr_package.md) - Package Helm charts
* [cr upload](cr_upload.md) - Upload Helm chart packages to GitHub Releases
* [cr version](cr_version.md) - Print version information

30 changes: 30 additions & 0 deletions doc/cr_completion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## cr completion

Generate the autocompletion script for the specified shell

### Synopsis

Generate the autocompletion script for cr for the specified shell.
See each sub-command's help for details on how to use the generated script.


### Options

```
-h, --help help for completion
```

### Options inherited from parent commands

```
--config string Config file (default is $HOME/.cr.yaml)
```

### SEE ALSO

* [cr](cr.md) - Helm Chart Repos on Github Pages
* [cr completion bash](cr_completion_bash.md) - Generate the autocompletion script for bash
* [cr completion fish](cr_completion_fish.md) - Generate the autocompletion script for fish
* [cr completion powershell](cr_completion_powershell.md) - Generate the autocompletion script for powershell
* [cr completion zsh](cr_completion_zsh.md) - Generate the autocompletion script for zsh

49 changes: 49 additions & 0 deletions doc/cr_completion_bash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## cr completion bash

Generate the autocompletion script for bash

### Synopsis

Generate the autocompletion script for the bash shell.

This script depends on the 'bash-completion' package.
If it is not installed already, you can install it via your OS's package manager.

To load completions in your current shell session:

source <(cr completion bash)

To load completions for every new session, execute once:

#### Linux:

cr completion bash > /etc/bash_completion.d/cr

#### macOS:

cr completion bash > $(brew --prefix)/etc/bash_completion.d/cr

You will need to start a new shell for this setup to take effect.


```
cr completion bash
```

### Options

```
-h, --help help for bash
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--config string Config file (default is $HOME/.cr.yaml)
```

### SEE ALSO

* [cr completion](cr_completion.md) - Generate the autocompletion script for the specified shell

40 changes: 40 additions & 0 deletions doc/cr_completion_fish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## cr completion fish

Generate the autocompletion script for fish

### Synopsis

Generate the autocompletion script for the fish shell.

To load completions in your current shell session:

cr completion fish | source

To load completions for every new session, execute once:

cr completion fish > ~/.config/fish/completions/cr.fish

You will need to start a new shell for this setup to take effect.


```
cr completion fish [flags]
```

### Options

```
-h, --help help for fish
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--config string Config file (default is $HOME/.cr.yaml)
```

### SEE ALSO

* [cr completion](cr_completion.md) - Generate the autocompletion script for the specified shell

37 changes: 37 additions & 0 deletions doc/cr_completion_powershell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## cr completion powershell

Generate the autocompletion script for powershell

### Synopsis

Generate the autocompletion script for powershell.

To load completions in your current shell session:

cr completion powershell | Out-String | Invoke-Expression

To load completions for every new session, add the output of the above command
to your powershell profile.


```
cr completion powershell [flags]
```

### Options

```
-h, --help help for powershell
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--config string Config file (default is $HOME/.cr.yaml)
```

### SEE ALSO

* [cr completion](cr_completion.md) - Generate the autocompletion script for the specified shell

51 changes: 51 additions & 0 deletions doc/cr_completion_zsh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## cr completion zsh

Generate the autocompletion script for zsh

### Synopsis

Generate the autocompletion script for the zsh shell.

If shell completion is not already enabled in your environment you will need
to enable it. You can execute the following once:

echo "autoload -U compinit; compinit" >> ~/.zshrc

To load completions in your current shell session:

source <(cr completion zsh); compdef _cr cr

To load completions for every new session, execute once:

#### Linux:

cr completion zsh > "${fpath[1]}/_cr"

#### macOS:

cr completion zsh > $(brew --prefix)/share/zsh/site-functions/_cr

You will need to start a new shell for this setup to take effect.


```
cr completion zsh [flags]
```

### Options

```
-h, --help help for zsh
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--config string Config file (default is $HOME/.cr.yaml)
```

### SEE ALSO

* [cr completion](cr_completion.md) - Generate the autocompletion script for the specified shell

44 changes: 44 additions & 0 deletions doc/cr_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## cr index

Update Helm repo index.yaml for the given GitHub repo

### Synopsis


Update a Helm chart repository index.yaml file based on a the
given GitHub repository's releases.


```
cr index [flags]
```

### Options

```
-b, --git-base-url string GitHub Base URL (only needed for private GitHub) (default "https://api.github.com/")
-r, --git-repo string GitHub repository
-u, --git-upload-url string GitHub Upload URL (only needed for private GitHub) (default "https://uploads.github.com/")
-h, --help help for index
-i, --index-path string Path to index file (default ".cr-index/index.yaml")
-o, --owner string GitHub username or organization
-p, --package-path string Path to directory with chart packages (default ".cr-release-packages")
--pages-branch string The GitHub pages branch (default "gh-pages")
--pages-index-path string The GitHub pages index path (default "index.yaml")
--pr Create a pull request for index.yaml against the GitHub Pages branch (must not be set if --push is set)
--push Push index.yaml to the GitHub Pages branch (must not be set if --pr is set)
--release-name-template string Go template for computing release names, using chart metadata (default "{{ .Name }}-{{ .Version }}")
--remote string The Git remote used when creating a local worktree for the GitHub Pages branch (default "origin")
-t, --token string GitHub Auth Token (only needed for private repos)
```

### Options inherited from parent commands

```
--config string Config file (default is $HOME/.cr.yaml)
```

### SEE ALSO

* [cr](cr.md) - Helm Chart Repos on Github Pages

Loading

0 comments on commit 2d923ec

Please sign in to comment.