Class: Konfig::Exporters::EnvVarsAsMarkdown
- Defined in:
- lib/konfig/exporters/env_vars_as_markdown.rb
Overview
This export will create a markdown document containing all configuration variables as defined the schema shown as environment variables.
Instance Method Summary collapse
-
#export ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength.
Methods inherited from Abstract
Constructor Details
This class inherits a constructor from Konfig::Exporters::Abstract
Instance Method Details
#export ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/konfig/exporters/env_vars_as_markdown.rb', line 14 def export contents = [] contents << "# #{[:title] || 'Environment Variables'}" contents << '' contents << ([:introduction] || 'This document contains all the environment variables which are available for this application.') contents << '' contents << '| Name | Type | Description | Default |' contents << '| ---- | ---- | ----------- | ------- |' path = [] @schema.groups.each do |group_name, group| path << group_name group.attributes.each do |name, attr| env_var = Sources::Environment.path_to_env_var(path + [name]) type = attr.array? ? "Array of #{attr.type}s" : attr.type.to_s.capitalize contents << "| `#{env_var}` | #{type} | #{attr.description} | #{attr.default} |" end path.pop end contents.join("\n") + "\n" end |