meduza
meduza copied to clipboard
🧜♀️ Zig codebase graph generator that emits a Mermaid class diagram.
:lizard: :mermaid: meduza
Zig codebase graph generator that emits a Mermaid class diagram.
:rocket: Usage
git clone https://github.com/tensorush/meduza.git
cd meduza/
zig build exe -- -h
:sparkles: Features
-
Generate either
.html,.md, or.mmdMermaid class diagram. -
Generate one diagram for each of your codebase's source directories.
-
Learn how to improve code readability from logged tips (enable with
-i). -
Convert
.mdor.mmddiagram to.svgwith Mermaid CLI (see CD pipeline). -
Generate a large diagram (
maxTextSize> 250'000) with Mermaid CLI (see CD pipeline). -
Click on types to go to respective code lines on the remote (GitHub Mermaid forbids this, though).
:world_map: Legend
---
title: Title (path/to/directory)
---
%%{
init: {
'theme': 'base',
'themeVariables': {
'fontSize': '18px',
'fontFamily': 'arial',
'lineColor': '#F6A516',
'primaryColor': '#28282B',
'primaryTextColor': '#F6A516'
}
}
}%%
classDiagram
class `file.zig` {
fld: T
test "tst"()
}
class Error["Error [err]"] {
Value
}
class Enum["Enum [enu]"] {
Value
+func(arg) E!R
}
class Union["Union [uni]"] {
fld: T
+func(arg) E!R
}
class Struct["Struct [str]"] {
fld: T
+func(arg) E!R
}
class Opaque["Opaque [opa]"] {
fld: T
+func(arg) E!R
}
`file.zig` <-- Error
`file.zig` <-- Enum
`file.zig` <-- Union
`file.zig` <-- Struct
`file.zig` <-- Opaque
| Type | Zig | Meduza |
|---|---|---|
| File | file.zig |
class file.zig {} |
| Error | const Error = error { Value, }; |
class Error["Error [err]"] { Value } |
| Enum | const Enum = enum { Value, }; |
class Enum["Enum [enu]"] { Value } |
| Union | const Union = union { fld: T, }; |
class Union["Union [uni]"] { fld: T } |
| Struct | const Struct = struct { fld: T, }; |
class Struct["Struct [str]"] { fld: T } |
| Opaque | const Opaque = opaque { fld: T, }; |
class Opaque["Opaque [opa]"] { fld: T } |
| Function | pub fn / fn func(arg) E!R {} |
+ / - func(arg) : E!R |
| Error union | error{Value}!struct { fld: T } |
error[Value]!struct [ fld: T ] |
| Test function | test "tst" {} |
test "tst"() |
| Type relation | B.zig: const A = enum { Value, }; |
B.zig <-- A |