Skip to content

Commit

Permalink
add @example_request_description and @example_response_description
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Pape committed Apr 24, 2012
1 parent 5d48894 commit 4ca9c06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/yard-rest/tags.rb
Expand Up @@ -6,9 +6,11 @@
YARD::Tags::Library.define_tag("Optional Arguments", :optional, :with_types_and_name)

YARD::Tags::Library.define_tag("Example Request", :example_request)
YARD::Tags::Library.define_tag("Example Request Description", :example_request_description)
YARD::Tags::Library.define_tag("Request Fields", :request_field, :with_types_and_name)

YARD::Tags::Library.define_tag("Example Response", :example_response)
YARD::Tags::Library.define_tag("Example Response Description", :example_response_description)
YARD::Tags::Library.define_tag("Response Fields", :response_field, :with_types_and_name)

YARD::Tags::Library.define_tag("Headers", :header, :with_name)
10 changes: 6 additions & 4 deletions templates/default/class/html/method_details_list.erb
Expand Up @@ -58,17 +58,19 @@
<h4>Examples</h4>
<% meth.tags(:example_request).each_with_index do |example_request, i| %>
<div class="example">
<% example_request_description = meth.tags(:example_request_description)[i] %>
<% example_response = meth.tags(:example_response)[i] %>
<span class="description"><%= example_request.text.gsub(/{.*}/, "")%></span>
<% example_response_description = meth.tags(:example_response_description)[i] %>
<span class="description"><%= (example_request_description.nil?) ? "" : example_request_description.text %></span>
<span class="hash request">
<strong class="type">Request</strong>
<%= example_request.text.match(/{.*}/).to_s%>
<%= (example_request.nil?) ? "" : example_request.text %>
</span>
<span class="hash response">
<strong class="type">Response</strong>
<%= example_response.text.match(/{.*}/).to_s%>
<%= (example_response.nil?) ? "" : example_response.text %>
</span>
<span class="description"><%= example_response.text.gsub(/{.*}/, "")%></span>
<span class="description"><%= (example_response_description.nil?) ? "" : example_response_description.text %></span>
</div>
<% end %>
</div>
Expand Down

0 comments on commit 4ca9c06

Please sign in to comment.