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 |
# File 'lib/awsrm/generator/doc/resource.rb', line 6 def generate_doc resource_dir = __dir__ + '/../../resources/' resources = Dir.glob(resource_dir + '*').map do |file| File.basename(file, '.rb') end resources.sort! links = resources.map do |r| '[' + r.classify + '](#' + 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::#{r.classify}::FILTER_MAP") doc += ERB.new(resource_template, nil, '-').result(binding) end doc end |
.resource_template ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/awsrm/generator/doc/resource.rb', line 29 def resource_template template = <<-'EOF' ## <a name="<%= r %>">Awsrm::<%= r.classify %></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 |