1
0
mirror of https://github.com/github/choosealicense.com synced 2024-12-21 20:30:10 +01:00
choosealicense.com/script/generate-docs

39 lines
978 B
Plaintext
Raw Normal View History

2015-08-22 15:25:16 -04:00
#!/usr/bin/env ruby
# frozen_string_literal: true
2017-03-26 17:19:44 -07:00
2015-08-22 15:25:16 -04:00
# 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'
2016-02-08 15:37:19 -05:00
fields = YAML.load_file('_data/fields.yml')
meta = YAML.load_file('_data/meta.yml')
rules = YAML.load_file('_data/rules.yml')
2015-08-22 15:25:16 -04:00
puts "\n### Fields\n\n"
fields.each do |field|
2016-02-08 15:37:19 -05:00
puts "* `#{field['name']}` - #{field['description']}"
2015-08-22 15:25:16 -04:00
end
puts "\n### YAML front matter\n"
2016-02-08 15:37:19 -05:00
meta = meta.group_by { |m| m['required'] }
2015-08-22 15:25:16 -04:00
puts "\n#### Required fields\n\n"
2016-02-08 15:37:19 -05:00
meta[true].each do |field|
puts "* `#{field['name']}` - #{field['description']}"
2015-08-22 15:25:16 -04:00
end
puts "\n#### Optional fields\n\n"
2016-02-08 15:37:19 -05:00
meta[false].each do |field|
puts "* `#{field['name']}` - #{field['description']}"
2015-08-22 15:25:16 -04:00
end
puts "\n### Rules\n"
2016-02-08 15:37:19 -05:00
rules.each do |group, group_rules|
2015-08-22 15:25:16 -04:00
puts "\n#### #{group.capitalize}\n\n"
2016-02-08 15:37:19 -05:00
group_rules.each do |rule|
puts "* `#{rule['tag']}` - #{rule['description']}"
2015-08-22 15:25:16 -04:00
end
end