mirror of
https://github.com/github/choosealicense.com
synced 2024-12-22 21:00:10 +01:00
37 lines
929 B
Plaintext
37 lines
929 B
Plaintext
|
#!/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
|