dependgraph

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CMD = &cobra.Command{
	Use:   "dependgraph",
	Long:  "visualization dependendency graph output",
	Short: "visualization dependendency graph output",
	Run: func(cmd *cobra.Command, args []string) {
		g := make(dependgraph)

		for _, f := range args {
			err := g.ReadFile(f)
			if err != nil {
				panic(err)
			}
		}

		tmpFile, err := ioutil.TempDir("", "dependgraph-*.html")
		if err != nil {
			panic(err)
		}

		if err != nil {
			panic(err)
		}

		var graph GraphBuilder
		switch viper.GetString("graph") {
		case "avsd":
			graph = NewCryptoScapeAVSDFGraphBuilder()
		case "dracula":
			graph = NewDraculaGraph()
		default:
			panic(fmt.Sprintf("invalid error mode '%s'", viper.GetString("graph")))
		}

		err = RenderGraph(graph, &GraphPage{
			Edges: g.Edges(),
		})

		if err != nil {
			panic(err)
		}

		path := filepath.Join(tmpFile, "dependgraph.html")
		err = graph.Write(path)
		if err != nil {
			panic(err)
		}

		didStart := startBrowser(fmt.Sprintf("file://%s", path))
		if !didStart {
			fmt.Printf("visit this link to view the graph file://%s", path)
		}
	},
}

Functions

func RenderGraph

func RenderGraph(g GraphBuilder, page *GraphPage) error

Types

type CryptoScapeAVSDFGraphBuilder

type CryptoScapeAVSDFGraphBuilder struct {
	// contains filtered or unexported fields
}

func NewCryptoScapeAVSDFGraphBuilder

func NewCryptoScapeAVSDFGraphBuilder() *CryptoScapeAVSDFGraphBuilder

func (*CryptoScapeAVSDFGraphBuilder) Dependencies

func (s *CryptoScapeAVSDFGraphBuilder) Dependencies() error

func (*CryptoScapeAVSDFGraphBuilder) Graph

func (*CryptoScapeAVSDFGraphBuilder) Renderer

func (s *CryptoScapeAVSDFGraphBuilder) Renderer() error

func (*CryptoScapeAVSDFGraphBuilder) Write

func (s *CryptoScapeAVSDFGraphBuilder) Write(path string) error

type CryptoScapeAVSDFGraphBuilderData

type CryptoScapeAVSDFGraphBuilderData[T any] struct {
	Data T `json:"data"`
}

type CryptoScapeAVSDFGraphBuilderElements

type CryptoScapeAVSDFGraphBuilderElements struct {
	Edges []CryptoScapeAVSDFGraphBuilderData[CryptoScrapeAVSDFGraphBuilderEdge] `json:"edges"`
	Nodes []CryptoScapeAVSDFGraphBuilderData[CryptoScapeAVSDFGraphBuilderNode]  `json:"nodes"`
}

type CryptoScapeAVSDFGraphBuilderNode

type CryptoScapeAVSDFGraphBuilderNode struct {
	ID string `json:"id"`
}

type CryptoScrapeAVSDFGraphBuilderEdge

type CryptoScrapeAVSDFGraphBuilderEdge struct {
	Source string `json:"source"`
	Target string `json:"target"`
}

type DraculaGraphBuilder

type DraculaGraphBuilder struct {
	// contains filtered or unexported fields
}

func (*DraculaGraphBuilder) Dependencies

func (g *DraculaGraphBuilder) Dependencies() error

func (*DraculaGraphBuilder) Graph

func (g *DraculaGraphBuilder) Graph(page *GraphPage) error

func (*DraculaGraphBuilder) Renderer

func (g *DraculaGraphBuilder) Renderer() error

func (*DraculaGraphBuilder) Write

func (g *DraculaGraphBuilder) Write(path string) error

type GraphBuilder

type GraphBuilder interface {
	Graph(edges *GraphPage) error
	Write(string) error
	Renderer() error
	Dependencies() error
}

func NewDraculaGraph

func NewDraculaGraph() GraphBuilder

type GraphEdge

type GraphEdge struct {
	Key   string
	Value string
}

type GraphPage

type GraphPage struct {
	Edges []GraphEdge
}

Jump to

Keyboard shortcuts

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