generators

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const JSONOutputFile = "manifest.json"

Variables

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}}
{{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}}

`
View Source
var GenPulsarctlDir = flag.String("gen-pulsarctl-dir", "site/gen-pulsarctldocs/generators",
	"Directory containing pulsarctl files")
View Source
var PulsarVersion = flag.String("pulsar-version", "", "Version of Pulsar to generate docs for.")

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()

func NormalizeSpec

func NormalizeSpec(spec *PulsarctlSpec)

func WriteCategoryFile

func WriteCategoryFile(c Category)

func WriteCommandFile

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

func WriteCommandFiles

func WriteCommandFiles(manifest *Manifest, toc ToC, params PulsarctlSpec)

func WriteManifest

func WriteManifest(manifest *Manifest)

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 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 PulsarctlSpec

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

func GetSpec

func GetSpec() PulsarctlSpec

func NewPulsarctlSpec

func NewPulsarctlSpec(c *cobra.Command) PulsarctlSpec

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 {
	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