debian-mirror-gitlab/lib/gitlab/usage/docs/helper.rb

61 lines
1.6 KiB
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# 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)
2021-04-17 20:07:23 +05:30
"### `#{name}`"
2021-03-11 19:13:27 +05:30
end
def render_description(object)
2021-04-17 20:07:23 +05:30
return 'Missing description' unless object[:description].present?
object[:description]
2021-03-11 19:13:27 +05:30
end
2021-04-29 21:17:54 +05:30
def render_object_schema(object)
"[Object JSON schema](#{object.json_schema_path})"
end
2021-04-17 20:07:23 +05:30
def render_yaml_link(yaml_path)
"[YAML definition](#{yaml_path})"
2021-03-11 19:13:27 +05:30
end
2021-04-17 20:07:23 +05:30
def render_status(object)
"Status: #{format(:status, object[:status])}"
end
2021-03-11 19:13:27 +05:30
2021-04-17 20:07:23 +05:30
def render_owner(object)
"Group: `#{object[:product_group]}`"
2021-03-11 19:13:27 +05:30
end
2021-04-17 20:07:23 +05:30
def render_tiers(object)
"Tiers:#{format(:tier, object[:tier])}"
2021-03-11 19:13:27 +05:30
end
2021-04-17 20:07:23 +05:30
def format(key, value)
Gitlab::Usage::Docs::ValueFormatter.format(key, value)
2021-03-11 19:13:27 +05:30
end
end
end
end
end