termdoc

package
v0.0.0-...-59817e7 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package termdoc contains string formatting functions for producing CLI documentation that can target both terminal and markdown output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdditionalHelpTopic

func AdditionalHelpTopic(name, short string, markdownContent string, format *mdfmt.Formatter) *cobra.Command

AdditionalHelpTopic creates a cobra command that will be surfaced as an "Additional Help Topic".

When run, the content will be formatted by the Formatter.

func AutoCodeFormat

func AutoCodeFormat() *codefmt.Formatter

AutoCodeFormat produces the default terminal code formatter.

func AutoMarkdownFormat

func AutoMarkdownFormat() *mdfmt.Formatter

AutoMarkdownFormat produces the default terminal markdown formatter.

func Code

func Code(s string) string

Code renders an inline Code block as Markdown if color output is disabled.

func CodeBlock

func CodeBlock(language, s string) string

CodeBlock renders a code block as Markdown if color output is disabled.

func Footer(s string) string

Footer renders a footer as Markdown if color output is disabled.

func HasLazyLongMessage

func HasLazyLongMessage(cmd *cobra.Command) bool

HasLazyLongMessage reports whether cmd's "long" message is produced lazily.

func Header(s string) string

Header renders a header as a Markdown h3 if color output is disabled.

func LazyAdditionalHelpTopic

func LazyAdditionalHelpTopic(name, short string, contentFunc func(cmd *cobra.Command, args []string) (string, error), format *mdfmt.Formatter) *cobra.Command

LazyAdditionalHelpTopic creates a cobra command that will be surfaced as an "Additional Help Topic".

The content is produced by the contentFunc when the command is called.

When run, the content will be formatted by the Formatter.

func OList

func OList(items ...string) string

OList renders an ordered list as Markdown if color output is disabled.

func TerminalWidth

func TerminalWidth(fallback int) int

TerminalWidth returns the width of the terminal, using fallback if it can't determine width.

func UList

func UList(defaultPrefix string, items ...string) string

UList renders an unordered list as Markdown if color output is disabled.

Types

This section is empty.

Directories

Path Synopsis
Package codefmt contains basic code reformatting functionality.
Package codefmt contains basic code reformatting functionality.
Package mdfmt contains basic markdown reformatting functionality.
Package mdfmt contains basic markdown reformatting functionality.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳