-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2f3a98
commit 158210d
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule ExPlain.D2 do | ||
@moduledoc """ | ||
Module to convert data into D2 diagrams | ||
""" | ||
|
||
### ExPlain Diagram I Module backbone diagram | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
defmodule ExPlain.D2.Backbone do | ||
Check warning on line 1 in lib/d2/backbone.ex GitHub Actions / Static Analysis
|
||
def create_diagram(%{ | ||
name: module_name, | ||
public_functions: public_functions, | ||
private_functions: private_functions | ||
}) do | ||
classes = get_backbone_class() | ||
header = get_header_title(module_name) | ||
public_functions_boxes = get_public_functions_boxes(public_functions) | ||
private_functions_boxes = get_private_functions_boxes(private_functions) | ||
|
||
classes <> header <> public_functions_boxes <> private_functions_boxes | ||
end | ||
|
||
defp get_public_functions_boxes(public_functions) do | ||
for fun <- public_functions, into: "", do: "#{fun}.class: public \n" | ||
end | ||
|
||
defp get_private_functions_boxes(private_functions) do | ||
for fun <- private_functions, into: "", do: "#{fun}.class: private\n" | ||
end | ||
|
||
defp get_header_title(module_name) do | ||
""" | ||
explanation: |md | ||
# #{module_name} | ||
| | ||
grid-columns: 3 | ||
""" | ||
end | ||
|
||
defp get_backbone_class do | ||
""" | ||
classes: { | ||
public: { | ||
style: { | ||
stroke-width: 0 | ||
fill: "#85b4ff" | ||
shadow: true | ||
border-radius: 5 | ||
} | ||
} | ||
private: { | ||
style: { | ||
fill: "#fff585" | ||
stroke: "#F69E03" | ||
} | ||
} | ||
} | ||
""" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
defmodule ExPlain.ModuleUnit do | ||
Check warning on line 1 in lib/module_unit.ex GitHub Actions / Static Analysis
|
||
@doc """ | ||
Struct for module unit | ||
""" | ||
defstruct [:name, :public_functions, :private_functions] | ||
|
||
def new(name, public_functions \\ [], private_functions \\ []) do | ||
%__MODULE__{ | ||
name: name, | ||
public_functions: public_functions, | ||
private_functions: private_functions | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
defmodule ExPlainTest do | ||
use ExUnit.Case | ||
alias ExPlain.ModuleUnit | ||
|
||
test "create a module unit struct" do | ||
assert %ModuleUnit{name: "MyModule"} = ModuleUnit.new("MyModule") | ||
end | ||
end |