Welcome to mirror list, hosted at ThFree Co, Russian Federation.

value_formatter.rb « docs « usage « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 379e5df4d522a6ff6c9e339e38657ade862253a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

module Gitlab
  module Usage
    module Docs
      class ValueFormatter
        def self.format(key, value)
          return '' unless value.present?

          case key
          when :key_path
            "**`#{value}`**"
          when :data_source
            value.to_s.capitalize
          when :product_group, :product_category, :status
            "`#{value}`"
          when :introduced_by_url
            "[Introduced by](#{value})"
          when :distribution, :tier
            Array(value).map { |tier| " `#{tier}`" }.join(',')
          else
            value
          end
        end
      end
    end
  end
end