templates/lib/tasks/doc_generator/template.erb in wd_sinatra-0.2.3 vs templates/lib/tasks/doc_generator/template.erb in wd_sinatra-0.2.4
- old
+ new
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
- <title>Bootstrap, from Twitter</title>
+ <title>Weasel Diesel - API documentation</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
@@ -73,11 +73,36 @@
<% api.doc.examples.each do |example| %>
<li><code><%= example %></code></li>
<% end %>
</ul>
<% end %>
- <%# TODO support for namespaced params %>
+
+ <h3>Input parameters description</h3>
+ <%# TODO support for nested namespaced params %>
+ <% api.params.namespaced_params.each do |params| %>
+ <div class='well'>
+ <h4>Namespace: <span style='font-style: italic'><%= params.space_name %></span></h4>
+ <div style='padding-left: 40px'>
+ <% [["Required", :list_required], ["Optional", :list_optional]].each do |label,rule_meth| %>
+ <% unless params.send(rule_meth).empty? %>
+ <h4><%= label %> Params</h4>
+ <ul>
+ <% params.send(rule_meth).each do |rule| %>
+ <li>
+ <span class='label notice'><%= rule.name %></span> of type <span class='label success'><%= rule.options[:type] || 'String' %></span>
+ <% if desc = (api.doc.params_doc[rule.name.to_sym] || rule.options[:doc]) %>
+ <%= desc %>
+ <% end %>
+ </li>
+ <% end %>
+ </ul>
+ <% end %>
+ <% end %>
+ </div>
+ </div>
+ <% end %>
+
<% [["Required", :required_rules], ["Optional", :optional_rules]].each do |label,rule_meth| %>
<% unless api.send(rule_meth).empty? %>
<h3><%= label %> Params</h3>
<ul>
<% api.send(rule_meth).each do |rule| %>
@@ -95,23 +120,26 @@
</li>
<% end %>
</ul>
<% end %>
<% end %>
+
</div>
<div>
<% if api.response.nodes.any? %>
<h3>Response description</h3>
- <% api.response.elements.each do |el| %>
- <%= el.to_html %>
- <% end %>
- <% api.response.arrays.each do |arr| %>
- <%= arr.to_html %>
- <% end %>
+ <div class='well'>
+ <% api.response.elements.each do |el| %>
+ <%= el.to_html %>
+ <% end %>
+ <% api.response.arrays.each do |arr| %>
+ <%= arr.to_html %>
+ <% end %>
+ </div>
</ul>
<h4>Response example</h4>
- <p><code><%= api.response.to_json %></code></p>
+ <div class='well'><code><%= api.response.to_json %></code></div>
<% end %>
</div>
</div>
<hr>