1
0
mirror of https://github.com/github/choosealicense.com synced 2024-12-23 05:10:11 +01:00
choosealicense.com/script/generate-docs
2016-02-08 15:37:19 -05:00

37 lines
947 B
Ruby
Executable File

#!/usr/bin/env ruby
# 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