{"id":15629471,"url":"https://github.com/emicklei/dot","last_synced_at":"2025-05-14T19:07:12.825Z","repository":{"id":37269732,"uuid":"48131894","full_name":"emicklei/dot","owner":"emicklei","description":"Go package for writing descriptions using the Graphviz DOT and Mermaid language","archived":false,"fork":false,"pushed_at":"2025-03-10T05:49:17.000Z","size":202,"stargazers_count":286,"open_issues_count":0,"forks_count":19,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T15:07:08.989Z","etag":null,"topics":["dot","graphviz","mermaid"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emicklei.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-12-16T19:56:48.000Z","updated_at":"2025-03-31T16:47:31.000Z","dependencies_parsed_at":"2024-02-24T07:31:58.313Z","dependency_job_id":"e89a4cfb-d5c0-4c5d-8760-1cd4850230d8","html_url":"https://github.com/emicklei/dot","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emicklei%2Fdot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emicklei%2Fdot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emicklei%2Fdot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emicklei%2Fdot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emicklei","download_url":"https://codeload.github.com/emicklei/dot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254209859,"owners_count":22032897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dot","graphviz","mermaid"],"created_at":"2024-10-03T10:27:19.354Z","updated_at":"2025-05-14T19:07:09.791Z","avatar_url":"https://github.com/emicklei.png","language":"Go","funding_links":[],"categories":["Content"],"sub_categories":["Language Bindings"],"readme":"## dot - little helper package in Go for the graphviz dot language\n\n[![Go](https://github.com/emicklei/dot/actions/workflows/go.yml/badge.svg)](https://github.com/emicklei/dot/actions/workflows/go.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/emicklei/dot)](https://goreportcard.com/report/github.com/emicklei/dot)\n[![GoDoc](https://pkg.go.dev/badge/github.com/emicklei/dot)](https://pkg.go.dev/github.com/emicklei/dot)\n[![codecov](https://codecov.io/gh/emicklei/dot/branch/master/graph/badge.svg)](https://codecov.io/gh/emicklei/dot)\n\n[DOT language](http://www.graphviz.org/doc/info/lang.html)\n\n\tpackage main\n\t\n\timport (\n\t\t\"fmt\"\t\n\t\t\"github.com/emicklei/dot\"\n\t)\n\t\n\t// go run main.go | dot -Tpng  \u003e test.png \u0026\u0026 open test.png\n\t\n\tfunc main() {\n\t\tg := dot.NewGraph(dot.Directed)\n\t\tn1 := g.Node(\"coding\")\n\t\tn2 := g.Node(\"testing a little\").Box()\n\t\n\t\tg.Edge(n1, n2)\n\t\tg.Edge(n2, n1, \"back\").Attr(\"color\", \"red\")\n\t\n\t\tfmt.Println(g.String())\n\t}\n\nOutput\n\n\tdigraph {\n\t\tnode [label=\"coding\"]; n1;\n\t\tnode [label=\"testing a little\",shape=\"box\"]; n2;\n\t\tn1 -\u003e n2;\n\t\tn2 -\u003e n1 [color=\"red\", label=\"back\"];\n\t}\n\nChaining edges\n\n\tg.Node(\"A\").Edge(g.Node(\"B\")).Edge(g.Node(\"C\"))\n\t\n\tA -\u003e B -\u003e C\n\n\tg.Node(\"D\").BidirectionalEdge(g.Node(\"E\"))\n\n\tD \u003c-\u003e E\n\nSubgraphs\n\n\ts := g.Subgraph(\"cluster\")\n\ts.Attr(\"style\", \"filled\")\n\n\nInitializers\n\n\tg := dot.NewGraph(dot.Directed)\n\tg.NodeInitializer(func(n dot.Node) {\n\t\tn.Attr(\"shape\", \"rectangle\")\n\t\tn.Attr(\"fontname\", \"arial\")\n\t\tn.Attr(\"style\", \"rounded,filled\")\n\t})\n\n\tg.EdgeInitializer(func(e dot.Edge) {\n\t\te.Attr(\"fontname\", \"arial\")\n\t\te.Attr(\"fontsize\", \"9\")\n\t\te.Attr(\"arrowsize\", \"0.8\")\n\t\te.Attr(\"arrowhead\", \"open\")\n\t})\n\nHTML and Literal values\n\n\tnode.Attr(\"label\", Literal(`\"left-justified text\\l\"`))\n\tgraph.Attr(\"label\", HTML(\"\u003cB\u003eHi\u003c/B\u003e\"))\n\n## cluster example\n\n![](./doc/cluster.png)\n\n\tdi := dot.NewGraph(dot.Directed)\n\toutside := di.Node(\"Outside\")\n\n\t// A\n\tclusterA := di.Subgraph(\"Cluster A\", dot.ClusterOption{})\n\tinsideOne := clusterA.Node(\"one\")\n\tinsideTwo := clusterA.Node(\"two\")\n\t\n\t// B\n\tclusterB := di.Subgraph(\"Cluster B\", dot.ClusterOption{})\n\tinsideThree := clusterB.Node(\"three\")\n\tinsideFour := clusterB.Node(\"four\")\n\n\t// edges\n\toutside.Edge(insideFour).Edge(insideOne).Edge(insideTwo).Edge(insideThree).Edge(outside)\n\nSee also `ext/Subsystem` type for creating composition hierarchies.\n\n\n## record example\n\nSee `record_test.go#ExampleNode_NewRecordBuilder`.\n\n## About dot attributes\n\nhttps://graphviz.gitlab.io/doc/info/attrs.html\n\n## display your graph\n\n\tgo run main.go | dot -Tpng  \u003e test.png \u0026\u0026 open test.png\n\n## mermaid\n\nOutput a dot Graph using the [mermaid](https://mermaid-js.github.io/mermaid/#/README) syntax.\nOnly Graph and Flowchart are supported. See MermaidGraph and MermaidFlowchart.\n\n```\ng := dot.NewGraph(dot.Directed)\n...\nfmt.Println(dot.MermaidGraph(g, dot.MermaidTopToBottom))\n```\n\n### subgraphs in mermaid\n\n```mermaid\nflowchart LR;n8--\u003en3;subgraph one;n2(\"a1\");n3(\"a2\");n2--\u003en3;end;subgraph three;n8(\"c1\");n9(\"c2\");n8--\u003en9;end;subgraph two;n5(\"b1\");n6(\"b2\");n5--\u003en6;end;\n```\n\n### mermaid specific attributes\n\n|attr|type|description|\n|----|----|-----------|\n|link|Edge|examples are {--\u003e,-.-\u003e,--x,o--o}|\n|shape|Node|examples are {MermaidShapeRound,MermaidShapeCircle,MermaidShapeTrapezoid}\n|style|Node|example is fill:#90EE90|\n\n## extensions\n\nSee also package `dot/dotx` for types that can help in constructing complex graphs.\n\n![](./doc/TestExampleSubsystemSameGraph.png)\n\n### testing\n\n\tgo test -coverprofile=coverage.out ./...\n\tgo tool cover -html=coverage.out\n\n(c) 2015-2023, http://ernestmicklei.com. MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femicklei%2Fdot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femicklei%2Fdot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femicklei%2Fdot/lists"}