debian-mirror-gitlab/lib/gitlab/kroki.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.4 KiB
Ruby
Raw Normal View History

2021-02-22 17:27:13 +05:30
# frozen_string_literal: true
2023-01-13 00:05:48 +05:30
require 'asciidoctor/extensions/asciidoctor_kroki/version'
2021-02-22 17:27:13 +05:30
require 'asciidoctor/extensions/asciidoctor_kroki/extension'
module Gitlab
# Helper methods for Kroki
module Kroki
BLOCKDIAG_FORMATS = %w[
2022-11-25 23:54:43 +05:30
blockdiag
seqdiag
actdiag
nwdiag
packetdiag
rackdiag
].freeze
2021-03-11 19:13:27 +05:30
DIAGRAMS_FORMATS = (::AsciidoctorExtensions::Kroki::SUPPORTED_DIAGRAM_NAMES - %w(mermaid)).freeze
DIAGRAMS_FORMATS_WO_PLANTUML = (DIAGRAMS_FORMATS - %w(plantuml)).freeze
2021-02-22 17:27:13 +05:30
# 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.
2021-03-11 19:13:27 +05:30
diagram_formats = if current_settings.plantuml_enabled
DIAGRAMS_FORMATS_WO_PLANTUML
else
DIAGRAMS_FORMATS
end
# Diagrams that require a companion container must be explicitly enabled from the settings
diagram_formats.select do |diagram_type|
current_settings.kroki_format_supported?(diagram_type)
2021-02-22 17:27:13 +05:30
end
end
end
end