mermaid 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +116 -12
- data/Rakefile +2 -2
- data/lib/mermaid/class_diagram_renderer.rb +45 -0
- data/lib/mermaid/element_renderers/edge_renderer.rb +19 -0
- data/lib/mermaid/element_renderers/node_renderer.rb +16 -0
- data/lib/mermaid/element_renderers/relationship_renderer.rb +24 -0
- data/lib/mermaid/element_renderers/slice_renderer.rb +16 -0
- data/lib/mermaid/element_renderers/state_renderer.rb +15 -0
- data/lib/mermaid/element_renderers/task_renderer.rb +15 -0
- data/lib/mermaid/element_renderers/transition_renderer.rb +17 -0
- data/lib/mermaid/flowchart_diagram_renderer.rb +23 -0
- data/lib/mermaid/gantt_diagram_renderer.rb +16 -0
- data/lib/mermaid/gitgraph_diagram_renderer.rb +113 -0
- data/lib/mermaid/pie_diagram_renderer.rb +16 -0
- data/lib/mermaid/state_diagram_renderer.rb +42 -0
- data/lib/mermaid/timeline_diagram_renderer.rb +29 -0
- data/lib/mermaid/version.rb +1 -1
- data/lib/mermaid.rb +20 -10
- data/sig/diagrams/base.rbs +8 -0
- data/sig/diagrams/class_diagram.rbs +18 -0
- data/sig/diagrams/elements/edge.rbs +16 -0
- data/sig/diagrams/elements/node.rbs +15 -0
- data/sig/diagrams/elements/relationship.rbs +17 -0
- data/sig/diagrams/elements/slice.rbs +16 -0
- data/sig/diagrams/elements/state.rbs +15 -0
- data/sig/diagrams/elements/task.rbs +17 -0
- data/sig/diagrams/elements/transition.rbs +16 -0
- data/sig/diagrams/flowchart_diagram.rbs +14 -0
- data/sig/diagrams/gantt_diagram.rbs +14 -0
- data/sig/diagrams/pie_diagram.rbs +14 -0
- data/sig/diagrams/state_diagram.rbs +18 -0
- data/sig/mermaid/base_diagram.rbs +31 -0
- data/sig/mermaid/state_diagram.rbs +26 -0
- metadata +168 -35
- data/lib/mermaid/base_diagram.rb +0 -13
- data/lib/mermaid/c4_diagram.rb +0 -9
- data/lib/mermaid/class_diagram.rb +0 -10
- data/lib/mermaid/er_diagram.rb +0 -9
- data/lib/mermaid/flowchart_diagram/link.rb +0 -46
- data/lib/mermaid/flowchart_diagram/node.rb +0 -36
- data/lib/mermaid/flowchart_diagram/parser.rb +0 -30
- data/lib/mermaid/flowchart_diagram.rb +0 -32
- data/lib/mermaid/gantt_diagram.rb +0 -9
- data/lib/mermaid/git_graph_diagram.rb +0 -9
- data/lib/mermaid/info_flow_diagram.rb +0 -9
- data/lib/mermaid/mindmap_diagram.rb +0 -9
- data/lib/mermaid/pie_diagram.rb +0 -9
- data/lib/mermaid/quadrant_diagram.rb +0 -10
- data/lib/mermaid/requirement_diagram.rb +0 -9
- data/lib/mermaid/sankey_diagram.rb +0 -9
- data/lib/mermaid/sequence_diagram.rb +0 -9
- data/lib/mermaid/state_diagram.rb +0 -9
- data/lib/mermaid/user_journey_diagram.rb +0 -10
- data/lib/mermaid/xy_diagram.rb +0 -10
@@ -1,30 +0,0 @@
|
|
1
|
-
module Mermaid
|
2
|
-
module FlowchartDiagram::Parser
|
3
|
-
def self.included(base)
|
4
|
-
base.extend(ClassMethods)
|
5
|
-
end
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def parse(input)
|
9
|
-
lines = input.split("\n")
|
10
|
-
_, direction = lines.shift.split
|
11
|
-
nodes = []
|
12
|
-
links = []
|
13
|
-
lines.each do |line|
|
14
|
-
if line =~ /^(\S+)(?:\[(.*)\]|\((.*)\)|\{(.*)\})/
|
15
|
-
id = $1
|
16
|
-
label = $2 || $3 || $4
|
17
|
-
shape = $2 ? 'box' : $3 ? 'round' : 'decision'
|
18
|
-
nodes << Node.new(id: id, label: label, shape: shape)
|
19
|
-
elsif line =~ /^(\S+)\s+-->(?:\|(.*)\|\s+)?(\S+)/
|
20
|
-
from = $1
|
21
|
-
label = $2
|
22
|
-
to = $3
|
23
|
-
links << Link.new(from: from, to: to, label: label)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
new(id: 'parsed', direction: direction, nodes: nodes, links: links)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mermaid
|
4
|
-
class FlowchartDiagram < BaseDiagram
|
5
|
-
include Parser
|
6
|
-
NAME = 'flowchart'
|
7
|
-
Direction = Types::String.default('LR').enum('LR', 'RL', 'TB', 'BT')
|
8
|
-
attribute :id, Types::String
|
9
|
-
attribute :direction, Direction
|
10
|
-
attribute :nodes, Types::Array.of(Node)
|
11
|
-
attribute :links, Types::Array.of(Link)
|
12
|
-
|
13
|
-
def generate
|
14
|
-
diagram = "#{NAME} #{direction}\n"
|
15
|
-
labeled_nodes = Set.new
|
16
|
-
links.each do |link|
|
17
|
-
from_node = nodes.find { |node| node.id == link.from }
|
18
|
-
to_node = nodes.find { |node| node.id == link.to }
|
19
|
-
from_node_already_labeled = !labeled_nodes.include?(from_node)
|
20
|
-
to_node_already_labeled = !labeled_nodes.include?(to_node)
|
21
|
-
diagram += " #{from_node.to_s(from_node_already_labeled)} -->#{link.label ? "|#{link.label}|" : ''} #{to_node.to_s(to_node_already_labeled)}\n"
|
22
|
-
labeled_nodes << from_node if from_node.label
|
23
|
-
labeled_nodes << to_node if to_node.label
|
24
|
-
end
|
25
|
-
diagram
|
26
|
-
end
|
27
|
-
|
28
|
-
def inspect
|
29
|
-
"#<#{self.class.name}: Nodes: #{nodes.size}, Links: #{links.size}>"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/lib/mermaid/pie_diagram.rb
DELETED