choosealicense.com/script/generate-docs

39 строки
978 B
Ruby
Executable File

#!/usr/bin/env ruby
# frozen_string_literal: true
# Usage: script/generate-docs
# Reads in the fields, meta, and rules YAML files and produces markdown output
# suitable for documenting in the project's README
require 'yaml'
fields = YAML.load_file('_data/fields.yml')
meta = YAML.load_file('_data/meta.yml')
rules = YAML.load_file('_data/rules.yml')
puts "\n### Fields\n\n"
fields.each do |field|
puts "* `#{field['name']}` - #{field['description']}"
end
puts "\n### YAML front matter\n"
meta = meta.group_by { |m| m['required'] }
puts "\n#### Required fields\n\n"
meta[true].each do |field|
puts "* `#{field['name']}` - #{field['description']}"
end
puts "\n#### Optional fields\n\n"
meta[false].each do |field|
puts "* `#{field['name']}` - #{field['description']}"
end
puts "\n### Rules\n"
rules.each do |group, group_rules|
puts "\n#### #{group.capitalize}\n\n"
group_rules.each do |rule|
puts "* `#{rule['tag']}` - #{rule['description']}"
end
end