Packwerk Mermaid
This is a simple gem for a project using packwerk to generate a Mermaid diagram. When you generate the output, you can get a diagram that looks like this:
---
title: App Name
---
flowchart TD
0("Nelson Hamill") --> 1("Msgr. Cynthia Dickens");
0 --> 2("Adell Friesen MD");
2 --> 3("Cortez Purdy");
2 --> 4("Renaldo Collier");
2 --> 5("Titus Schamberger");
2 --> 6("Efren Kuhlman");
2 --> 7("Osvaldo Legros Esq.");
2 --> 8("Byron Hammes");
6 --> 9("Carlo Nolan DDS");
3 --> 9;
1 --> 2;
10("Mayola Kovacek") --> 2;
10 --> 1;
10 --> 5;
10 --> 6;
Installation
Add this line to your application's Gemfile:
gem 'packwerk_mermaid'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install packwerk_mermaid
Usage
There is no CLI, but it's easy enough to write a Ruby script and run it like so:
require "packwerk_mermaid"
require "packwerk_mermaid/packwerk_flowchart"
configuration = PackwerkMermaid.configure do |config|
config.mermaid_title = 'Title of my Diagram'
config.mermaid_text_type = 'text'
config.mermaid_shape_style = 'rectangle_rounded'
config.packwerk_directory = '.'
config.packwerk_package_name_mapping = {
'.' => 'root',
'packs/cli' => 'CLI',
}
config.packwerk_package_name_callback = lambda { |name| name.gsub('packs/', '') }
config.packwerk_packages_hidden = [
'packs/utilities',
'packs/legacy_service',
]
config.packwerk_package_name_callback = lambda { |node_name, parent_node_name| should_show?(node_name) }
end
PackwerkMermaid::PackwerkFlowchart.new(configuration).generate
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/bwillis/packwerk_mermaid. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the PackwerkMermaid project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.