1
0
mirror of https://github.com/github/choosealicense.com synced 2024-12-22 04:40:09 +01:00
choosealicense.com/script/generate-docs
2015-08-22 15:25:16 -04:00

37 lines
929 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 |meta|
puts "* `#{meta["name"]}` - #{meta["description"]}"
end
puts "\n#### Optional fields\n\n"
meta[false].each do |meta|
puts "* `#{meta["name"]}` - #{meta["description"]}"
end
puts "\n### Rules\n"
rules.each do |group, rules|
puts "\n#### #{group.capitalize}\n\n"
rules.each do |rule|
puts "* `#{rule["tag"]}` - #{rule["description"]}"
end
end