Class: Awsrm::Generator::Doc::Resource
- Inherits:
-
Object
- Object
- Awsrm::Generator::Doc::Resource
- Defined in:
- lib/awsrm/generator/doc/resource.rb
Class Method Summary collapse
Class Method Details
.generate_doc ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/awsrm/generator/doc/resource.rb', line 6 def generate_doc inflector = Dry::Inflector.new resource_dir = __dir__ + '/../../resources/' resources = Dir.glob(resource_dir + '*').map do |file| File.basename(file, '.rb') end resources.sort! links = resources.map do |r| '[' + inflector.classify(r) + '](#' + r + ')' end header = <<-'EOF' # Resources <%= links.join("\n| ") %> EOF doc = ERB.new(header, nil, '-').result(binding) resources.each do |r| filter_map = Object.const_get("Awsrm::#{inflector.classify(r)}::FILTER_MAP") doc += ERB.new(resource_template, nil, '-').result(binding) end doc end |
.resource_template ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/awsrm/generator/doc/resource.rb', line 30 def resource_template template = <<-'EOF' ## <a name="<%= r %>">Awsrm::<%= inflector.classify(r) %></a> ### Filter | key | replaced filter | | - | - | <% filter_map.each do |k, v| %>| <%= k %> | <%= v.is_a?(Proc) ? '[`#<Proc>`](https://github.com/k1LoW/awsrm/blob/master/lib/awsrm/resources/' + r + '.rb)' : '`' + v + '`' %> | <% end %> EOF template end |