1
0
mirror of https://github.com/github/choosealicense.com synced 2024-11-13 06:58:53 +01:00
choosealicense.com/script/generate-docs

39 lines
978 B
Plaintext
Raw Normal View History

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