Documentation
¶
Overview ¶
Package markdown provides advanced formatting and content enrichment for markdown generation.
Package markdown provides an extended API for generating markdown documentation from OPNsense configurations with configurable options.
Package markdown provides an extended API for generating markdown documentation from OPNsense configurations with configurable options.
Package markdown provides an extended API for generating markdown documentation from OPNsense configurations with configurable options.
Index ¶
- Constants
- Variables
- func CodeBlock(language, content string) string
- func FormatBoolean(value any) string
- func FormatBooleanWithUnset(value any) string
- func FormatUnixTimestamp(timestamp string) string
- func FormatValue(key string, value any) string
- func GetPowerModeDescription(mode string) string
- func IsTruthy(value any) bool
- func RenderBadge(badge Badge) string
- func RenderMarkdown(content string) (string, error)
- func Table(headers []string, rows [][]string) string
- func ValidateMarkdown(content string) error
- type Adapter
- func (a *Adapter) GenerateJSON(ctx context.Context, cfg *model.OpnSenseDocument) (string, error)
- func (a *Adapter) GenerateMarkdown(ctx context.Context, cfg *model.OpnSenseDocument, comprehensive bool) (string, error)
- func (a *Adapter) GenerateYAML(ctx context.Context, cfg *model.OpnSenseDocument) (string, error)
- type Badge
- func BadgeEnhanced() Badge
- func BadgeFail() Badge
- func BadgeInfo() Badge
- func BadgeInsecure() Badge
- func BadgeSecure() Badge
- func BadgeSuccess() Badge
- func BadgeWarning() Badge
- func InfoBadge() Badge
- func SecurityBadge(secure, enhanced bool) Badge
- func StatusBadge(success bool) Badge
- func WarningBadge() Badge
- type Format
- type Generator
- type HybridGenerator
- type Options
- type ReportBuilder
- type Theme
Constants ¶
const ( // FormatMarkdown represents markdown output format. FormatMarkdown = converter.FormatMarkdown // FormatJSON represents JSON output format. FormatJSON = converter.FormatJSON // FormatYAML represents YAML output format. FormatYAML = converter.FormatYAML )
const ( // ThemeAuto automatically detects the appropriate theme. ThemeAuto = converter.ThemeAuto // ThemeDark uses a dark terminal theme. ThemeDark = converter.ThemeDark // ThemeLight uses a light terminal theme. ThemeLight = converter.ThemeLight // ThemeNone disables styling for plain text output. ThemeNone = converter.ThemeNone )
Variables ¶
var ( // ErrUnsupportedFormat is returned when an unsupported output format is requested. ErrUnsupportedFormat = converter.ErrUnsupportedFormat // ErrNilConfiguration is returned when the input OPNsense configuration is nil. ErrNilConfiguration = converter.ErrNilConfiguration )
var ErrInvalidWrapWidth = converter.ErrInvalidWrapWidth
ErrInvalidWrapWidth indicates that the wrap width setting is invalid.
Functions ¶
func CodeBlock ¶
CodeBlock returns the given content wrapped in a fenced markdown code block, using the specified language for syntax highlighting. If language is empty, "text" is used as the default.
func FormatBoolean ¶
FormatBoolean formats a boolean value consistently using markdown checkboxes.
func FormatBooleanWithUnset ¶
FormatBooleanWithUnset formats a boolean value, showing "unset" for -1 values.
func FormatUnixTimestamp ¶
FormatUnixTimestamp converts a Unix timestamp string to an ISO 8601 formatted date.
func FormatValue ¶
FormatValue automatically detects the type of value and formats it appropriately. FormatValue returns a markdown-formatted string representation of the given value, choosing an appropriate format based on its type. Slices of structs are rendered as tables, other slices as lists, structs and maps as key-value pairs, and scalars as inline text or code blocks. Nil values are represented as a code block containing "nil".
func GetPowerModeDescription ¶
GetPowerModeDescription converts power management mode acronyms to their full descriptions.
func IsTruthy ¶
IsTruthy determines if a value represents a "true" or "enabled" state. Handles various formats: "1", "yes", "true", "on", "enabled", etc. Treats -1 as "unset" and returns false for it.
func RenderBadge ¶
RenderBadge returns a markdown-formatted string representing the given badge, combining its icon and bolded text.
func RenderMarkdown ¶
RenderMarkdown parses and renders markdown content to HTML using goldmark. Returns the rendered HTML string or an error if rendering fails.
func Table ¶
Table returns a markdown-formatted table using the provided headers and rows. If headers or rows are empty, it returns a message indicating no data is available.
func ValidateMarkdown ¶
ValidateMarkdown checks if the provided markdown content is syntactically valid. It returns an error if the content cannot be parsed as markdown.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter provides a simplified interface for generating documentation.
func NewAdapter ¶
NewAdapter creates a new adapter with the default markdown generator.
func (*Adapter) GenerateJSON ¶
GenerateJSON generates JSON documentation from an OPNsense configuration.
func (*Adapter) GenerateMarkdown ¶
func (a *Adapter) GenerateMarkdown( ctx context.Context, cfg *model.OpnSenseDocument, comprehensive bool, ) (string, error)
GenerateMarkdown generates markdown documentation from an OPNsense configuration.
func (*Adapter) GenerateYAML ¶
GenerateYAML generates YAML documentation from an OPNsense configuration.
type Badge ¶
Badge represents a colorized status badge with emoji and text.
func BadgeEnhanced ¶
func BadgeEnhanced() Badge
BadgeEnhanced returns a Badge representing an enhanced status with a sparkle emoji and purple color scheme.
func BadgeFail ¶
func BadgeFail() Badge
BadgeFail returns a Badge representing a failure status with a red icon and background.
func BadgeInfo ¶
func BadgeInfo() Badge
BadgeInfo returns a Badge representing informational status with an info icon and blue color scheme.
func BadgeInsecure ¶
func BadgeInsecure() Badge
BadgeInsecure returns a Badge representing an insecure status with a red color scheme and unlocked icon.
func BadgeSecure ¶
func BadgeSecure() Badge
BadgeSecure returns a Badge representing a secure status with a lock icon and green color scheme.
func BadgeSuccess ¶
func BadgeSuccess() Badge
BadgeSuccess returns a Badge representing a successful status with a checkmark icon and green colors.
func BadgeWarning ¶
func BadgeWarning() Badge
BadgeWarning returns a Badge representing a warning status with a warning icon and yellow color scheme.
func SecurityBadge ¶
SecurityBadge selects and returns a badge representing the security status. Returns an enhanced badge if enhanced is true, a secure badge if secure is true, or an insecure badge otherwise.
func StatusBadge ¶
StatusBadge returns a success badge if success is true, or a failure badge otherwise.
func WarningBadge ¶
func WarningBadge() Badge
WarningBadge returns a Badge representing a warning status.
type HybridGenerator ¶ added in v1.1.0
type HybridGenerator = converter.HybridGenerator
HybridGenerator provides programmatic markdown, JSON, and YAML generation.
func NewHybridGenerator
deprecated
added in
v1.1.0
func NewHybridGenerator(reportBuilder builder.ReportBuilder, logger *log.Logger) (*HybridGenerator, error)
NewHybridGenerator creates a new HybridGenerator with the specified builder.
Deprecated: use converter.NewHybridGenerator instead.
type Options ¶
Options contains configuration options for markdown generation.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns an Options value initialized with package defaults for markdown generation. The returned Options contains sensible defaults for formatting, wrap width, and theme selection used by the markdown package.
type ReportBuilder ¶ added in v1.1.0
type ReportBuilder = builder.ReportBuilder
ReportBuilder defines the interface for building markdown reports.