diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /lib/gitlab/kroki.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'lib/gitlab/kroki.rb')
-rw-r--r-- | lib/gitlab/kroki.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/gitlab/kroki.rb b/lib/gitlab/kroki.rb new file mode 100644 index 00000000000..8c5652fb766 --- /dev/null +++ b/lib/gitlab/kroki.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'asciidoctor/extensions/asciidoctor_kroki/extension' + +module Gitlab + # Helper methods for Kroki + module Kroki + BLOCKDIAG_FORMATS = %w[ + blockdiag + seqdiag + actdiag + nwdiag + packetdiag + rackdiag + ].freeze + # Diagrams that require a companion container are disabled for now + DIAGRAMS_FORMATS = ::AsciidoctorExtensions::Kroki::SUPPORTED_DIAGRAM_NAMES + .reject { |diagram_type| diagram_type == 'mermaid' || diagram_type == 'bpmn' || BLOCKDIAG_FORMATS.include?(diagram_type) } + DIAGRAMS_FORMATS_WO_PLANTUML = DIAGRAMS_FORMATS + .reject { |diagram_type| diagram_type == 'plantuml' } + + # Get the list of diagram formats that are currently enabled + # + # Returns an Array of diagram formats. + # If Kroki is not enabled, returns an empty Array. + def self.formats(current_settings) + return [] unless current_settings.kroki_enabled + + # If PlantUML is enabled, PlantUML diagrams will be processed by the PlantUML server. + # In other words, the PlantUML server has precedence over Kroki since both can process PlantUML diagrams. + if current_settings.plantuml_enabled + DIAGRAMS_FORMATS_WO_PLANTUML + else + DIAGRAMS_FORMATS + end + end + end +end |