Skip to content

Commit

Permalink
Fixed encoding issue and stripped '#'
Browse files Browse the repository at this point in the history
  • Loading branch information
apraditya committed Dec 6, 2011
1 parent e6e8046 commit de59c0b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/method_doc.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def add_output(name, value)


def append_output(value) def append_output(value)
last_output_key = @outputs.last.keys[0] last_output_key = @outputs.last.keys[0]
@outputs.last[last_output_key] += value @outputs.last[last_output_key] += ERB::Util.html_escape(value)
end end


def get_binding def get_binding
Expand Down
14 changes: 10 additions & 4 deletions lib/resource_doc.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def parse_apidoc!
elsif line =~ /::output-end::/ elsif line =~ /::output-end::/
current_scope = :function current_scope = :function
elsif current_scope == :response elsif current_scope == :response
current_api_block.response += "#{line}" current_api_block.response += strip_line(line)
elsif current_scope == :request elsif current_scope == :request
current_api_block.request += "#{line}" current_api_block.request += strip_line(line)
elsif current_scope == :output elsif current_scope == :output
current_api_block.append_output "#{line}" current_api_block.append_output strip_line(line)
elsif current_scope == :class || current_scope == :function # check if we are looking at a api block elsif current_scope == :class || current_scope == :function # check if we are looking at a api block
# strip the # on the line # strip the # on the line
#line = line[1..line.length].lstrip.rstrip #line = line[1..line.length].lstrip.rstrip
Expand All @@ -83,7 +83,7 @@ def parse_apidoc!
end end
else else
# add line to block # add line to block
current_api_block.content << line current_api_block.content << strip_line(line)
end end
end end
lineno += 1 lineno += 1
Expand Down Expand Up @@ -116,5 +116,11 @@ def get_parsed_method(method_block)
File.open(File.join(File.dirname(__FILE__), '..', 'templates', '_resource_method.html.erb')).each { |line| template << line } File.open(File.join(File.dirname(__FILE__), '..', 'templates', '_resource_method.html.erb')).each { |line| template << line }
return ERB.new(template).result(method_block.get_binding) return ERB.new(template).result(method_block.get_binding)
end end

private
# strip the '#' on the line
def strip_line(line)
line[1..line.length]
end
end end
end end
2 changes: 1 addition & 1 deletion templates/_resource_method.html.erb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<% @outputs.each do |output| %> <% @outputs.each do |output| %>
<% output_format = output.keys.first %> <% output_format = output.keys.first %>
<div class="<%= (output == @outputs.first)? 'active' : '' %>" id="<%= output_format %>"> <div class="<%= (output == @outputs.first)? 'active' : '' %>" id="<%= output_format %>">
<pre class="prettyprint" ><%= raw output[output_format] %></pre> <pre class="prettyprint" ><%= output[output_format] %></pre>
</div> </div>
<% end %> <% end %>
</div> </div>
Expand Down

0 comments on commit de59c0b

Please sign in to comment.