generators

package
v0.0.0-...-c4965f0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const JsonOutputFile = "manifest.json"

Variables

View Source
var (
	KubernetesVersion = flag.String("kubernetes-version", "", "Version of Kubernetes to generate docs for.")
	GenKubectlDir     = flag.String("gen-kubectl-dir", "generators", "Directory containing kubectl files")
)
View Source
var CategoryTemplate = `
# <strong>{{.Name}}</strong>
`
View Source
var CommandTemplate = `
------------

# {{.MainCommand.Name}}

{{.MainCommand.Example}}

{{.MainCommand.Description}}

### Usage

` + "`" + `$ {{.MainCommand.Usage}}` + "`" + `

{{if .MainCommand.Options}}

### Flags

Name | Shorthand | Default | Usage
---- | --------- | ------- | ----- {{range $option := .MainCommand.Options}}
{{$option.Name}} | {{$option.Shorthand}} | {{$option.DefaultValue}} | {{$option.Usage}} {{end}}
{{end}}
{{$mainCommandName := .MainCommand.Name}}
{{range $sub := .SubCommands}}
------------

## <em>{{$sub.Path}}</em>

{{$sub.Example}}

{{$sub.Description}}

### Usage

` + "`" + `$ {{$sub.Usage}}` + "`" + `

{{if $sub.Options}}

### Flags

Name | Shorthand | Default | Usage
---- | --------- | ------- | ----- {{range $option := $sub.Options}}
{{$option.Name}} | {{$option.Shorthand}} | {{$option.DefaultValue}} | {{$option.Usage}} {{end}}
{{end}}

{{end}}

`

Functions

func FormatCommand

func FormatCommand(c *Command)

func FormatDescription

func FormatDescription(input string) string

func FormatExample

func FormatExample(input string) string

func GenerateFiles

func GenerateFiles() error

func NormalizeSpec

func NormalizeSpec(spec *KubectlSpec)

func WriteCategoryFile

func WriteCategoryFile(c Category) error

func WriteCommandFile

func WriteCommandFile(manifest *Manifest, t *template.Template, params TopLevelCommand) error

func WriteCommandFiles

func WriteCommandFiles(manifest *Manifest, toc ToC, params KubectlSpec) error

func WriteManifest

func WriteManifest(manifest *Manifest) error

Types

type Category

type Category struct {
	Name     string   `yaml:",omitempty"`
	Commands []string `yaml:",omitempty"`
	Include  string   `yaml:",omitempty"`
}

type Command

type Command struct {
	Name             string   `yaml:",omitempty"`
	Path             string   `yaml:",omitempty"`
	Synopsis         string   `yaml:",omitempty"`
	Description      string   `yaml:",omitempty"`
	Options          Options  `yaml:",omitempty"`
	InheritedOptions Options  `yaml:"inherited_options,omitempty"`
	Example          string   `yaml:",omitempty"`
	SeeAlso          []string `yaml:"see_also,omitempty"`
	Usage            string   `yaml:",omitempty"`
}

func NewCommand

func NewCommand(c *cobra.Command, path string) *Command

type Commands

type Commands []*Command

func NewSubCommands

func NewSubCommands(c *cobra.Command, path string) Commands

Parse the Commands

func (Commands) Len

func (a Commands) Len() int

func (Commands) Less

func (a Commands) Less(i, j int) bool

func (Commands) Swap

func (a Commands) Swap(i, j int)

type Doc

type Doc struct {
	Filename string `json:"filename,omitempty"`
}

type KubectlSpec

type KubectlSpec struct {
	TopLevelCommandGroups []TopLevelCommands `yaml:",omitempty"`
}

func GetSpec

func GetSpec() KubectlSpec

func NewKubectlSpec

func NewKubectlSpec(c *cobra.Command) KubectlSpec

type Manifest

type Manifest struct {
	Docs      []Doc  `json:"docs,omitempty"`
	Title     string `json:"title,omitempty"`
	Copyright string `json:"copyright,omitempty"`
}

type Option

type Option struct {
	Name         string `yaml:",omitempty"`
	Shorthand    string `yaml:",omitempty"`
	DefaultValue string `yaml:"default_value,omitempty"`
	Usage        string `yaml:",omitempty"`
}

type Options

type Options []*Option

func NewOptions

func NewOptions(flags *pflag.FlagSet) Options

Parse the Options

func (Options) Len

func (a Options) Len() int

func (Options) Less

func (a Options) Less(i, j int) bool

func (Options) Swap

func (a Options) Swap(i, j int)

type ToC

type ToC struct {
	Categories []Category `yaml:",omitempty"`
}

type TopLevelCommand

type TopLevelCommand struct {
	MainCommand *Command `yaml:",omitempty"`
	SubCommands Commands `yaml:",omitempty"`
}

func NewTopLevelCommand

func NewTopLevelCommand(c *cobra.Command) TopLevelCommand

type TopLevelCommands

type TopLevelCommands struct {
	Group    string            `yaml:",omitempty"`
	Commands []TopLevelCommand `yaml:",omitempty"`
}

func NewTopLevelCommands

func NewTopLevelCommands(cs []*cobra.Command) TopLevelCommands

func (TopLevelCommands) Len

func (a TopLevelCommands) Len() int

func (TopLevelCommands) Less

func (a TopLevelCommands) Less(i, j int) bool

func (TopLevelCommands) Swap

func (a TopLevelCommands) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL