1
0
mirror of https://github.com/github/choosealicense.com synced 2024-11-05 11:18:50 +01:00
choosealicense.com/script/generate-docs
2017-03-26 17:19:44 -07:00

39 lines
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