require 'travis/api/app' class Travis::Api::App class Endpoint # Generated API documentation. class Documentation < Endpoint set prefix: '/docs' enable :inline_templates # HTML view for [/endpoints](#/endpoints/). get '/' do content_type :html endpoints = Endpoints.endpoints erb :index, {}, :endpoints => endpoints.keys.sort.map { |k| endpoints[k] } end helpers do def icon_for(verb) # GET, POST, PATCH, PUT, DELETE" case verb when 'GET' then 'file' when 'POST' then 'edit' when 'PATCH' then 'wrench' when 'PUT' then 'share' when 'DELETE' then 'trash' else 'question-sign' end end def slug_for(route) return route['uri'] if route['verb'] == 'GET' route['verb'] + " " + route['uri'] end def docs_for(entry) markdown(entry['doc']). gsub('/, ''). gsub(/TODO:?/, 'TODO') end end end end end __END__ @@ index Travis API documentation

The Travis API

All the routes, just waiting for you to build something awesome.

<% endpoints.each do |endpoint| %>
<%= docs_for endpoint %> <% endpoint['routes'].each do |route| %>

<%= route['verb'] %> <%= route['uri'] %>

Required autorization scope: <%= route['scope'] %>

<%= docs_for route %>
<% end %>
<% end %>