class ApiBlueprint::Collect::Renderer
Public Instance Methods
action_header(content)
click to toggle source
# File lib/api_blueprint/collect/renderer.rb, line 41 def action_header(content) "## Action: #{content}\n\n" end
code_block(content)
click to toggle source
# File lib/api_blueprint/collect/renderer.rb, line 67 def code_block(content) content.split("\n").collect { |line| " " * 4 + line }.join("\n") + "\n\n" end
description_header()
click to toggle source
# File lib/api_blueprint/collect/renderer.rb, line 45 def description_header "### Description:\n\n" end
example_header(content)
click to toggle source
# File lib/api_blueprint/collect/renderer.rb, line 57 def example_header(content) "#### Example: #{content}\n\n" end
example_subheader(content)
click to toggle source
# File lib/api_blueprint/collect/renderer.rb, line 61 def example_subheader(content) content = content.to_s.humanize + ':' if content.is_a?(Symbol) "##### #{content}\n\n" end
examples_header()
click to toggle source
# File lib/api_blueprint/collect/renderer.rb, line 53 def examples_header "### Examples:\n\n" end
parameter_table(params, level = 0)
click to toggle source
# File lib/api_blueprint/collect/renderer.rb, line 2 def parameter_table(params, level = 0) text = '' if level == 0 text += "#### Parameters:\n\n" text += "Name | Type | Description\n" text += "-----|------|---------|------------\n" end params.each do |name, info| comment = '' comment = "Params for each #{name.singularize}:" if info[:type] == 'array' text += "#{'[]' * level} #{name} | *#{info[:type]}*#{info[:example].present? ? " `Example: #{info[:example]}`" : ''} | #{comment}\n" if info[:type] == 'nested' || info[:type] == 'array' text += parameter_table(info[:params], level + 1) end end text += "\n" if level == 0 # text += "#### Parameters:\n\n" if level == 0 # text += params.collect do |name, info| # if info[:type] == 'nested' # "#{' ' * (level * 2)}- **#{name}**\n" + # parameter_table(info[:params], level + 1) # else # "#{' ' * (level * 2)}- **#{name}** (#{info[:type]}, `#{info[:example]}`)" # end # end.join("\n") # text += "\n\n" if level == 0 text end
resource_header(content)
click to toggle source
# File lib/api_blueprint/collect/renderer.rb, line 37 def resource_header(content) "# Resource: #{content}\n\n" end
signature(url, method)
click to toggle source
# File lib/api_blueprint/collect/renderer.rb, line 49 def signature(url, method) "#### Signature:\n\n**#{method}** `#{url}`\n\n" end