31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/documentary/view/helpers.rb', line 31
def endpoint_blocks
io = StringIO.new
io.puts '## Endpoints'
io.puts new_line
docblocks.endpoints.each do |endpoint|
io.puts "### #{endpoint.title}"
io.puts new_line
io.puts endpoint.notes if endpoint.notes
io.puts new_line
io.puts '#### Enpoint URL'
io.puts new_line
io.puts start_code_block
io.puts "#{endpoint.verb} #{endpoint.endpoint}"
io.puts end_code_block
if endpoint.information
io.puts '#### Endpoint Information'
io.puts new_line
endpoint.information.each do |key, value|
io.puts "* **#{key.titleize}**: #{value}"
end
end
if endpoint.params
io.puts new_line
io.puts '#### Parameters'
io.puts new_line
io.puts 'Name | Required | Description'
io.puts '-------- | -------- | -----------'
endpoint.params.each do |param|
io.puts "#{param.keys.first} | #{param['required']} | #{param['notes'].strip}"
end
end
if endpoint.example_request
io.puts new_line
io.puts '#### Example Request'
io.puts new_line
io.puts start_code_block
io.puts "#{endpoint.verb} #{endpoint.example_request.strip}"
io.puts end_code_block
end
if endpoint.example_response
io.puts new_line
io.puts '#### Example Response'
io.puts new_line
io.puts start_code_block
io.puts JSON.pretty_generate(endpoint.example_response)
io.puts end_code_block
end
end
io.string
end
|