Documentation ¶
Overview ¶
Package embedutil provides utility functions for embedding documents in a Go binary and producing those documents in various formats
Index ¶
- func GenMarkdownCustom(cmd *cobra.Command, w io.Writer) error
- func SetUsageFormat(opts cobrautil.UsageFormatOptions)
- type Category
- type DocType
- type Document
- func LoadJSONSchema(key, title, name string, filesys fs.FS) *Document
- func LoadJSONSchemaBytes(key, title, name string, data []byte) *Document
- func LoadJSONSchemaString(key, title, name, data string) *Document
- func LoadMarkdown(key, title, name string, filesys fs.FS) *Document
- func LoadMarkdownBytes(key, title, name string, data []byte) *Document
- func LoadMarkdownString(key, title, name string, data string) *Document
- type Documentation
- type Encoding
- type Format
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenMarkdownCustom ¶
GenMarkdownCustom creates custom Markdown output. github.com/spf13/cobra/blob/main/doc/md_docs.go
func SetUsageFormat ¶
func SetUsageFormat(opts cobrautil.UsageFormatOptions)
SetUsageFormat sets common formatting for usage documentation.
Types ¶
type Category ¶
type Category struct { Key string // Key name for the category in kebab-case Title string // Readable name for the category (can include spaces) Docs []*Document // List of documents contained in the category }
Category is used to group documents
type DocType ¶
type DocType string
DocType represents an overarching area of documentation
const ( // TypeAll represents all types TypeAll DocType = "all" // TypeGeneral represents general documentation TypeGeneral DocType = "general" // TypeCommands represents CLI command documentation TypeCommands DocType = "commands" // TypeSchemas represents API schema documentation TypeSchemas DocType = "schemas" )
type Document ¶
type Document struct { Key string // Key name for the file in kebab-case Title string // Human-readable title for the document Contents []byte // Contents of the document // contains filtered or unexported fields }
Document represents an embedded document
func LoadJSONSchema ¶
LoadJSONSchema loads a JSON Schema definition into a Document name must be the path to the document in filesys
func LoadJSONSchemaBytes ¶
LoadJSONSchemaBytes loads JSON Schema definition bytes into a Document
func LoadJSONSchemaString ¶
LoadJSONSchemaString loads a JSON Schema definition string into a Document
func LoadMarkdown ¶
LoadMarkdown loads a markdown file into a Document name must be the path to the document in filesys
func LoadMarkdownBytes ¶
LoadMarkdownBytes loads markdown bytes into a Document
func LoadMarkdownString ¶
LoadMarkdownString loads a markdown string into a Document
func (*Document) ManpageExt ¶
ManpageExt produces the extension to be used for this document when represented as a manpage
func (*Document) RenderedName ¶
RenderedName produces the output file name of a document based on the format
type Documentation ¶
type Documentation struct { // Overall title for the documentation Title string // Root cobra.Command Command *cobra.Command // Categories stores a list of documentation sub-categories, // allowing organization of generated documentation // Ordering is obeyed in the indexer Categories []*Category }
Documentation configures how different genres of embedded documentation will be generated
func (*Documentation) FindDocument ¶
func (docs *Documentation) FindDocument(key string) *Document
FindDocument returns the Document with the requested key
type Encoding ¶
type Encoding string
Encoding represents an embedded document's encoding
const ( // EncodingMarkdown represents a Markdown-encoded document EncodingMarkdown Encoding = "md" // EncodingManpage represents a manpage document EncodingManpage Encoding = "man" // EncodingJSONSchema represents a JSON-encoded JSON Schema definition EncodingJSONSchema Encoding = "jsonschema" // EncodingCRD represents a YAML-encoded CustomResourceDefinition EncodingCRD Encoding = "crd" // EncodingHTML represents an HTML document EncodingHTML Encoding = "html" // EncodingRaw represents a raw document EncodingRaw Encoding = "raw" )
type Options ¶
type Options struct { Format Format // Output format Types []DocType // Documentation types to generate Index bool // Generate a documentation index file (format-dependent) Flat bool // Generate documentation in a flat directory structure }
Options stores configuration for rendering embedded documentation
func (*Options) TypeRequested ¶
TypeRequested checks if a type was requested from the options