diff options
Diffstat (limited to 'lib/gitlab/usage/docs')
-rw-r--r-- | lib/gitlab/usage/docs/helper.rb | 64 | ||||
-rw-r--r-- | lib/gitlab/usage/docs/renderer.rb | 32 | ||||
-rw-r--r-- | lib/gitlab/usage/docs/templates/default.md.haml | 48 | ||||
-rw-r--r-- | lib/gitlab/usage/docs/value_formatter.rb | 28 |
4 files changed, 0 insertions, 172 deletions
diff --git a/lib/gitlab/usage/docs/helper.rb b/lib/gitlab/usage/docs/helper.rb deleted file mode 100644 index bfe674b945e..00000000000 --- a/lib/gitlab/usage/docs/helper.rb +++ /dev/null @@ -1,64 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Usage - module Docs - # Helper with functions to be used by HAML templates - module Helper - def auto_generated_comment - <<-MARKDOWN.strip_heredoc - --- - stage: Growth - group: Product Intelligence - info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers - --- - - <!--- - This documentation is auto generated by a script. - - Please do not edit this file directly, check generate_metrics_dictionary task on lib/tasks/gitlab/usage_data.rake. - ---> - MARKDOWN - end - - def render_name(name) - "### `#{name}`" - end - - def render_description(object) - return 'Missing description' unless object[:description].present? - - object[:description] - end - - def render_object_schema(object) - "[Object JSON schema](#{object.json_schema_path})" - end - - def render_yaml_link(yaml_path) - "[YAML definition](#{yaml_path})" - end - - def render_status(object) - "Status: #{format(:status, object[:status])}" - end - - def render_owner(object) - "Group: `#{object[:product_group]}`" - end - - def render_tiers(object) - "Tiers:#{format(:tier, object[:tier])}" - end - - def render_data_category(object) - "Data Category: `#{object[:data_category]}`" - end - - def format(key, value) - Gitlab::Usage::Docs::ValueFormatter.format(key, value) - end - end - end - end -end diff --git a/lib/gitlab/usage/docs/renderer.rb b/lib/gitlab/usage/docs/renderer.rb deleted file mode 100644 index 7a7c58005bb..00000000000 --- a/lib/gitlab/usage/docs/renderer.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Usage - module Docs - class Renderer - include Gitlab::Usage::Docs::Helper - DICTIONARY_PATH = Rails.root.join('doc', 'development', 'usage_ping') - TEMPLATE_PATH = Rails.root.join('lib', 'gitlab', 'usage', 'docs', 'templates', 'default.md.haml') - - def initialize(metrics_definitions) - @layout = Haml::Engine.new(File.read(TEMPLATE_PATH)) - @metrics_definitions = metrics_definitions.sort - end - - def contents - # Render and remove an extra trailing new line - @contents ||= @layout.render(self, metrics_definitions: @metrics_definitions).sub!(/\n(?=\Z)/, '') - end - - def write - filename = DICTIONARY_PATH.join('dictionary.md').to_s - - FileUtils.mkdir_p(DICTIONARY_PATH) - File.write(filename, contents) - - filename - end - end - end - end -end diff --git a/lib/gitlab/usage/docs/templates/default.md.haml b/lib/gitlab/usage/docs/templates/default.md.haml deleted file mode 100644 index 83a3a5b6698..00000000000 --- a/lib/gitlab/usage/docs/templates/default.md.haml +++ /dev/null @@ -1,48 +0,0 @@ -= auto_generated_comment - -:plain - # Metrics Dictionary - - This file is autogenerated, please do not edit directly. - - To generate these files from the GitLab repository, run: - - ```shell - bundle exec rake gitlab:usage_data:generate_metrics_dictionary - ``` - - The Metrics Dictionary is based on the following metrics definition YAML files: - - - [`config/metrics`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/config/metrics) - - [`ee/config/metrics`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/ee/config/metrics) - - Each table includes a `milestone`, which corresponds to the GitLab version when the metric - was released. - - <!-- vale off --> - <!-- Docs linting disabled after this line. --> - <!-- See https://docs.gitlab.com/ee/development/documentation/testing.html#disable-vale-tests --> - - ## Metrics Definitions - -\ -- metrics_definitions.each do |name, object| - - = render_name(name) - \ - = render_description(object.attributes) - - if object.has_json_schema? - \ - = render_object_schema(object) - \ - = render_yaml_link(object.yaml_path) - \ - = render_owner(object.attributes) - - if object.attributes[:data_category].present? - \ - = render_data_category(object.attributes) - \ - = render_status(object.attributes) - \ - = render_tiers(object.attributes) - \ diff --git a/lib/gitlab/usage/docs/value_formatter.rb b/lib/gitlab/usage/docs/value_formatter.rb deleted file mode 100644 index 379e5df4d52..00000000000 --- a/lib/gitlab/usage/docs/value_formatter.rb +++ /dev/null @@ -1,28 +0,0 @@ -# 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 |