Skip to content

Commit

Permalink
style: rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Aug 6, 2021
1 parent dd34949 commit 16fc721
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions script/docs/generate-configuration-docs.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby

require 'yaml'
require "yaml"

$stream = StringIO.new

Expand All @@ -10,7 +10,7 @@ def write string

def escape_backticks value
if value.is_a?(String)
value.gsub('`', '``')
value.gsub("`", "``")
else
value
end
Expand All @@ -24,14 +24,14 @@ def in_backticks value
end
end

docs_dir = File.expand_path('../../../docs', __FILE__)
environment_variable_file = File.join(docs_dir, 'configuration.yml')
docs_dir = File.expand_path("../../../docs", __FILE__)
environment_variable_file = File.join(docs_dir, "configuration.yml")
doc = YAML.load(File.read(environment_variable_file))

write "# Pact Broker Configuration\n\n"
# write "## Index"

# doc['groups'].each do | group |
# doc["groups"].each do | group |
# write "* #{group['title']}\n"

# group['vars'].each do | name, metadata |
Expand All @@ -42,43 +42,43 @@ def in_backticks value

write "\n"

doc['groups'].each do | group |
doc["groups"].each do | group |
write "<br/>\n\n"
write "## #{group['title']}\n\n<hr/>\n"
if group['comments']
write group['comments']
write "## #{group["title"]}\n\n<hr/>\n"
if group["comments"]
write group["comments"]
end
write "\n\n"

group['vars'].each do | name, metadata |
next if metadata['hidden']
group["vars"].each do | name, metadata |
next if metadata["hidden"]
write "### #{name}\n\n"
write "#{metadata['description']}\n\n"
write "#{metadata["description"]}\n\n"

write "**Required:** #{metadata['required'] || 'false'}<br/>" if metadata['required']
write "**Format:** #{metadata['format']}<br/>" if metadata['format']
write "**Default:** #{in_backticks(metadata['default'])}<br/>" if !metadata['default'].nil?
if metadata['allowed_values']
allowed_values = metadata['allowed_values'].collect{ |val| in_backticks(val) }.join(', ')
write "**Required:** #{metadata["required"] || "false"}<br/>" if metadata["required"]
write "**Format:** #{metadata["format"]}<br/>" if metadata["format"]
write "**Default:** #{in_backticks(metadata["default"])}<br/>" if !metadata["default"].nil?
if metadata["allowed_values"]
allowed_values = metadata["allowed_values"].collect{ |val| in_backticks(val) }.join(", ")
write "**Allowed values:** #{allowed_values}<br/>"
end
write "**Example:** #{in_backticks(metadata['example']) }<br/>" if metadata['example']
if metadata['examples']
allowed_values = metadata['examples'].collect{ |val| in_backticks(val) }.join(', ')
write "**Example:** #{in_backticks(metadata["example"]) }<br/>" if metadata["example"]
if metadata["examples"]
allowed_values = metadata["examples"].collect{ |val| in_backticks(val) }.join(", ")
write "**Examples:** #{allowed_values}<br/>"
end
write "**More information:** #{metadata['more_info']}<br/>" if metadata['more_info']
write "**More information:** #{metadata["more_info"]}<br/>" if metadata["more_info"]
write "\n"
end
end

File.open(File.join(docs_dir, 'CONFIGURATION.md'), "w") { |file| file << $stream.string }
File.open(File.join(docs_dir, "CONFIGURATION.md"), "w") { |file| file << $stream.string }

required_env_vars = []

doc['groups'].each do | group |
group['vars'].each do | name, metadata |
required_env_vars << name if metadata['required'] && !metadata['default']
doc["groups"].each do | group |
group["vars"].each do | name, metadata |
required_env_vars << name if metadata["required"] && !metadata["default"]
end
end

Expand Down

0 comments on commit 16fc721

Please sign in to comment.