formatters

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDirection = DirectionLR

DefaultDirection is the default layout direction for graphs.

Variables

This section is empty.

Functions

func BuildNodeNames

func BuildNodeNames(paths []string) map[string]string

BuildNodeNames returns stable, distinct display names for file paths. Paths that share the same base name are disambiguated by increasing path suffix depth.

func SupportedDirections added in v0.16.2

func SupportedDirections() string

SupportedDirections returns a list of all supported direction names.

func SupportedFormats

func SupportedFormats() string

SupportedFormats returns a list of all supported output format names.

Types

type Formatter

type Formatter interface {
	// Format converts a dependency graph to a formatted string representation.
	Format(g depgraph.FileDependencyGraph, opts RenderOptions) (string, error)
	// GenerateURL creates a shareable URL for the formatted output.
	// Returns the URL and true if supported, or ("", false) if not.
	GenerateURL(output string) (string, bool)
}

Formatter is the interface that all graph formatters must implement.

func NewFormatter

func NewFormatter(format string) (Formatter, error)

NewFormatter creates a Formatter for the provided output format string.

type GraphDirection added in v0.16.2

type GraphDirection string

GraphDirection represents the direction of the graph layout.

const (
	DirectionLR GraphDirection = "LR"
	DirectionRL GraphDirection = "RL"
	DirectionTB GraphDirection = "TB"
	DirectionBT GraphDirection = "BT"
)

func ParseDirection added in v0.16.2

func ParseDirection(s string) (GraphDirection, bool)

ParseDirection converts a string to GraphDirection.

func (GraphDirection) String added in v0.16.2

func (d GraphDirection) String() string

String returns the canonical string representation.

func (GraphDirection) StringLower added in v0.16.2

func (d GraphDirection) StringLower() string

StringLower returns the canonical string representation in lowercase.

type OutputFormat

type OutputFormat int

OutputFormat represents an output format type

const (
	OutputFormatDOT OutputFormat = iota
	OutputFormatMermaid
)

func ParseOutputFormat

func ParseOutputFormat(s string) (OutputFormat, bool)

ParseOutputFormat converts a string to OutputFormat

func (OutputFormat) String

func (f OutputFormat) String() string

String returns the string representation of the format

type RenderOptions

type RenderOptions struct {
	// Label is an optional title or label for the graph output.
	Label string
	// Direction is the layout direction for the graph.
	Direction GraphDirection
}

RenderOptions contains output-specific rendering options.

Jump to

Keyboard shortcuts

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