apitome 0.0.8 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +5 -5
  2. data/MIT.LICENSE +2 -2
  3. data/README.md +99 -40
  4. data/app/assets/javascripts/apitome/application.js +16 -0
  5. data/app/assets/stylesheets/apitome/application.css +10 -0
  6. data/app/controllers/apitome/docs_controller.rb +83 -45
  7. data/app/helpers/apitome/docs_helper.rb +19 -0
  8. data/app/views/apitome/docs/_all_examples.html.erb +6 -2
  9. data/app/views/apitome/docs/_body.html.erb +1 -1
  10. data/app/views/apitome/docs/_curl.html.erb +1 -1
  11. data/app/views/apitome/docs/_endpoint.html.erb +4 -0
  12. data/app/views/apitome/docs/_example.html.erb +10 -6
  13. data/app/views/apitome/docs/_explanation.html.erb +3 -3
  14. data/app/views/apitome/docs/_headers.html.erb +6 -4
  15. data/app/views/apitome/docs/_navigation.html.erb +14 -10
  16. data/app/views/apitome/docs/_params.html.erb +4 -4
  17. data/app/views/apitome/docs/_query.html.erb +1 -1
  18. data/app/views/apitome/docs/_resource_explanation.html.erb +3 -0
  19. data/app/views/apitome/docs/_response_fields.html.erb +1 -1
  20. data/app/views/apitome/docs/_route.html.erb +1 -1
  21. data/app/views/apitome/docs/_status.html.erb +1 -1
  22. data/app/views/apitome/docs/index.html.erb +11 -6
  23. data/app/views/apitome/docs/show.html.erb +2 -1
  24. data/app/views/layouts/apitome/application.html.erb +4 -4
  25. data/config/locales/en.yml +14 -11
  26. data/config/locales/es.yml +14 -10
  27. data/lib/apitome.rb +5 -5
  28. data/lib/apitome/configuration.rb +36 -15
  29. data/lib/apitome/engine.rb +13 -7
  30. data/lib/apitome/exceptions.rb +5 -1
  31. data/lib/apitome/version.rb +1 -1
  32. data/lib/generators/apitome/install/POST_INSTALL +1 -1
  33. data/lib/generators/apitome/install/install_generator.rb +7 -8
  34. data/lib/generators/apitome/install/templates/initializer.rb +35 -13
  35. data/vendor/assets/javascripts/apitome/highlight.min.js +2 -1
  36. data/vendor/assets/stylesheets/apitome/highlight_themes/agate.css +108 -0
  37. data/vendor/assets/stylesheets/apitome/highlight_themes/androidstudio.css +66 -0
  38. data/vendor/assets/stylesheets/apitome/highlight_themes/arduino-light.css +88 -0
  39. data/vendor/assets/stylesheets/apitome/highlight_themes/arta.css +41 -126
  40. data/vendor/assets/stylesheets/apitome/highlight_themes/ascetic.css +31 -36
  41. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-cave-dark.css +83 -0
  42. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-cave-light.css +85 -0
  43. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-dune-dark.css +69 -0
  44. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-dune-light.css +69 -0
  45. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-estuary-dark.css +84 -0
  46. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-estuary-light.css +84 -0
  47. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-forest-dark.css +69 -0
  48. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-forest-light.css +69 -0
  49. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-heath-dark.css +69 -0
  50. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-heath-light.css +69 -0
  51. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-lakeside-dark.css +69 -0
  52. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-lakeside-light.css +69 -0
  53. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-plateau-dark.css +84 -0
  54. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-plateau-light.css +84 -0
  55. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-savanna-dark.css +84 -0
  56. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-savanna-light.css +84 -0
  57. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-seaside-dark.css +69 -0
  58. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-seaside-light.css +69 -0
  59. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-sulphurpool-dark.css +69 -0
  60. data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-sulphurpool-light.css +69 -0
  61. data/vendor/assets/stylesheets/apitome/highlight_themes/brown-paper.css +64 -0
  62. data/vendor/assets/stylesheets/apitome/highlight_themes/{brown_papersq.png → brown-papersq.png} +0 -0
  63. data/vendor/assets/stylesheets/apitome/highlight_themes/codepen-embed.css +60 -0
  64. data/vendor/assets/stylesheets/apitome/highlight_themes/color-brewer.css +71 -0
  65. data/vendor/assets/stylesheets/apitome/highlight_themes/dark.css +41 -81
  66. data/vendor/assets/stylesheets/apitome/highlight_themes/darkula.css +74 -0
  67. data/vendor/assets/stylesheets/apitome/highlight_themes/default.css +74 -110
  68. data/vendor/assets/stylesheets/apitome/highlight_themes/docco.css +97 -0
  69. data/vendor/assets/stylesheets/apitome/highlight_themes/dracula.css +76 -0
  70. data/vendor/assets/stylesheets/apitome/highlight_themes/far.css +46 -86
  71. data/vendor/assets/stylesheets/apitome/highlight_themes/foundation.css +88 -0
  72. data/vendor/assets/stylesheets/apitome/highlight_themes/github-gist.css +71 -0
  73. data/vendor/assets/stylesheets/apitome/highlight_themes/github.css +53 -81
  74. data/vendor/assets/stylesheets/apitome/highlight_themes/googlecode.css +48 -103
  75. data/vendor/assets/stylesheets/apitome/highlight_themes/grayscale.css +101 -0
  76. data/vendor/assets/stylesheets/apitome/highlight_themes/gruvbox-dark.css +108 -0
  77. data/vendor/assets/stylesheets/apitome/highlight_themes/gruvbox-light.css +108 -0
  78. data/vendor/assets/stylesheets/apitome/highlight_themes/hopscotch.css +83 -0
  79. data/vendor/assets/stylesheets/apitome/highlight_themes/hybrid.css +102 -0
  80. data/vendor/assets/stylesheets/apitome/highlight_themes/idea.css +40 -64
  81. data/vendor/assets/stylesheets/apitome/highlight_themes/ir-black.css +73 -0
  82. data/vendor/assets/stylesheets/apitome/highlight_themes/kimbie.dark.css +74 -0
  83. data/vendor/assets/stylesheets/apitome/highlight_themes/kimbie.light.css +74 -0
  84. data/vendor/assets/stylesheets/apitome/highlight_themes/magula.css +36 -87
  85. data/vendor/assets/stylesheets/apitome/highlight_themes/mono-blue.css +59 -0
  86. data/vendor/assets/stylesheets/apitome/highlight_themes/monokai-sublime.css +83 -0
  87. data/vendor/assets/stylesheets/apitome/highlight_themes/monokai.css +50 -94
  88. data/vendor/assets/stylesheets/apitome/highlight_themes/obsidian.css +88 -0
  89. data/vendor/assets/stylesheets/apitome/highlight_themes/paraiso-dark.css +72 -0
  90. data/vendor/assets/stylesheets/apitome/highlight_themes/paraiso-light.css +72 -0
  91. data/vendor/assets/stylesheets/apitome/highlight_themes/pojoaque.css +45 -66
  92. data/vendor/assets/stylesheets/apitome/highlight_themes/purebasic.css +96 -0
  93. data/vendor/assets/stylesheets/apitome/highlight_themes/qtcreator_dark.css +83 -0
  94. data/vendor/assets/stylesheets/apitome/highlight_themes/qtcreator_light.css +83 -0
  95. data/vendor/assets/stylesheets/apitome/highlight_themes/railscasts.css +106 -0
  96. data/vendor/assets/stylesheets/apitome/highlight_themes/rainbow.css +48 -77
  97. data/vendor/assets/stylesheets/apitome/highlight_themes/school-book.css +72 -0
  98. data/vendor/assets/stylesheets/apitome/highlight_themes/{school_book.png → school-book.png} +0 -0
  99. data/vendor/assets/stylesheets/apitome/highlight_themes/solarized-dark.css +84 -0
  100. data/vendor/assets/stylesheets/apitome/highlight_themes/solarized-light.css +84 -0
  101. data/vendor/assets/stylesheets/apitome/highlight_themes/sunburst.css +55 -111
  102. data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow-night-blue.css +75 -0
  103. data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow-night-bright.css +74 -0
  104. data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow-night-eighties.css +74 -0
  105. data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow-night.css +75 -0
  106. data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow.css +43 -20
  107. data/vendor/assets/stylesheets/apitome/highlight_themes/vs.css +50 -68
  108. data/vendor/assets/stylesheets/apitome/highlight_themes/xcode.css +55 -116
  109. data/vendor/assets/stylesheets/apitome/highlight_themes/xt256.css +92 -0
  110. data/vendor/assets/stylesheets/apitome/highlight_themes/zenburn.css +49 -84
  111. metadata +80 -65
  112. data/config/routes.rb +0 -4
  113. data/spec/apitome/configuration_spec.rb +0 -0
  114. data/spec/apitome/engine_spec.rb +0 -0
  115. data/spec/dummy/Rakefile +0 -7
  116. data/spec/dummy/config.ru +0 -15
  117. data/spec/dummy/config/application.rb +0 -16
  118. data/spec/dummy/config/boot.rb +0 -7
  119. data/spec/dummy/config/environment.rb +0 -5
  120. data/spec/dummy/config/environments/development.rb +0 -27
  121. data/spec/dummy/config/environments/test.rb +0 -29
  122. data/spec/dummy/config/initializers/apitome.rb +0 -44
  123. data/spec/dummy/config/routes.rb +0 -2
  124. data/spec/dummy/doc/api.md +0 -20
  125. data/spec/dummy/public/favicon.ico +0 -0
  126. data/spec/dummy/script/rails +0 -6
  127. data/vendor/assets/stylesheets/apitome/highlight_themes/brown_paper.css +0 -104
  128. data/vendor/assets/stylesheets/apitome/highlight_themes/ir_black.css +0 -104
  129. data/vendor/assets/stylesheets/apitome/highlight_themes/school_book.css +0 -111
  130. data/vendor/assets/stylesheets/apitome/highlight_themes/solarized_dark.css +0 -88
  131. data/vendor/assets/stylesheets/apitome/highlight_themes/solarized_light.css +0 -88
  132. data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow_night.css +0 -52
  133. data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow_night_blue.css +0 -52
  134. data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow_night_bright.css +0 -51
  135. data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow_night_eighties.css +0 -51
@@ -1,9 +1,13 @@
1
1
  <% resources.each do |resource| %>
2
2
  <section class="example" id="<%= id_for(resource['name']) %>">
3
3
  <h1 class="resource-name"><%= resource['name'] %></h1>
4
+
5
+ <%= render partial: 'resource_explanation', locals: { explanation: resource['explanation'] } if resource['explanation'] %>
6
+
4
7
  <% resource['examples'].each do |example| %>
5
- <article id="<%= id_for(example['link'].gsub('.json', '')) %>">
6
- <%= render partial: 'example', locals: { example: set_example(example['link'].gsub('.json', '')) } %>
8
+ <% link = example['link'].gsub(/.json$/, '') %>
9
+ <article id="<%= id_for(link) %>">
10
+ <%= render partial: 'example', locals: { example: set_example(link).merge!(link: link) } %>
7
11
  </article>
8
12
  <% end %>
9
13
  </section>
@@ -1,4 +1,4 @@
1
1
  <section class="body">
2
- <h4><%= t(:body) %></h4>
2
+ <h4><%= t(:body, scope: :apitome) %></h4>
3
3
  <pre><code class="<%= type %>"><%= formatted_body(body, type) %></code></pre>
4
4
  </section>
@@ -1,4 +1,4 @@
1
1
  <section class="curl">
2
- <h4><%= t(:curl) %></h4>
2
+ <h4><%= t(:curl, scope: :apitome) %></h4>
3
3
  <pre><%= request['curl'] %></pre>
4
4
  </section>
@@ -0,0 +1,4 @@
1
+ <section class="endpoint">
2
+ <h3><%= t(:endpoint, scope: :apitome) %></h3>
3
+ <pre><%= "#{method} #{endpoint}" %></pre>
4
+ </section>
@@ -1,11 +1,12 @@
1
1
  <h2><%= example['description'] %></h2>
2
2
 
3
3
  <%= render partial: 'apitome/docs/explanation', locals: {explaination: example['explanation']} if example['explanation'] %>
4
+ <%= render partial: 'apitome/docs/endpoint', locals: {method: example['http_method'], endpoint: example['route']} %>
4
5
  <%= render partial: 'apitome/docs/params', locals: {params: example['parameters']} if example['parameters'].size > 0 %>
5
6
 
6
7
  <% example['requests'].each_with_index do |request, index| %>
7
8
  <div id="<%= "request-#{index}" %>">
8
- <h3><%= t(:request) %></h3>
9
+ <h3><%= t(:request, scope: :apitome) %></h3>
9
10
  <div class="request">
10
11
  <%= render partial: 'apitome/docs/route', locals: {request: request, index: index} %>
11
12
  <%= render partial: 'apitome/docs/headers', locals: {request: request, index: index, headers: request['request_headers']} %>
@@ -14,12 +15,15 @@
14
15
  <%= render partial: 'apitome/docs/curl', locals: {request: request, index: index} if request['curl'] %>
15
16
  </div>
16
17
 
17
- <h3><%= t(:response) %></h3>
18
+ <h3><%= t(:response, scope: :apitome) %></h3>
18
19
  <div class="response">
19
- <%= render partial: 'apitome/docs/response_fields', locals: {params: example['response_fields']} if example['response_fields'].size > 0 %>
20
- <%= render partial: 'apitome/docs/status', locals: {request: request, index: index} %>
21
- <%= render partial: 'apitome/docs/headers', locals: {request: request, index: index, headers: request['response_headers']} %>
22
- <%= render partial: 'apitome/docs/body', locals: {request: request, index: index, body: request['response_body'], type: request['response_content_type']} if request['response_body'] %>
20
+ <%- if Apitome.configuration.simulated_response %>
21
+ <%= link_to('Simulated Response', simulated_path(example[:link])) if example[:link].present? %>
22
+ <%- end %>
23
+ <%= render partial: 'apitome/docs/response_fields', locals: {params: example['response_fields']} if example['response_fields'].size > 0 %>
24
+ <%= render partial: 'apitome/docs/status', locals: {request: request, index: index} %>
25
+ <%= render partial: 'apitome/docs/headers', locals: {request: request, index: index, headers: request['response_headers']} %>
26
+ <%= render partial: 'apitome/docs/body', locals: {request: request, index: index, body: request['response_body'], type: request['response_content_type']} if request['response_body'] %>
23
27
  </div>
24
28
  </div>
25
29
  <% end %>
@@ -1,3 +1,3 @@
1
- <p class="explanation">
2
- <%= raw example['explanation'] %>
3
- </p>
1
+ <div class="explanation">
2
+ <%= raw rendered_markdown(example['explanation'].strip_heredoc) %>
3
+ </div>
@@ -1,4 +1,6 @@
1
- <section class="headers">
2
- <h4><%= t(:headers) %></h4>
3
- <pre><code class="http"><%= headers.map{ |k,v| "#{k}: #{v}" }.join("\n") %></code></pre>
4
- </section>
1
+ <% unless headers.blank? %>
2
+ <section class="headers">
3
+ <h4><%= t(:headers, scope: :apitome) %></h4>
4
+ <pre><code class="http"><%= headers.map{ |k,v| "#{k}: #{v}" }.join("\n") %></code></pre>
5
+ </section>
6
+ <% end %>
@@ -1,25 +1,29 @@
1
1
  <ul class="nav sidenav">
2
- <li>
3
- <% if Apitome.configuration.single_page %>
4
- <a href="#readme"><%= t(:readme) %></a>
5
- <% else %>
6
- <a href="<%= Apitome.configuration.mount_at %>"><%= t(:readme) %></a>
7
- <% end %>
8
- </li>
2
+ <% if Apitome.configuration.readme %>
3
+ <li>
4
+ <% if Apitome.configuration.single_page %>
5
+ <a href="#readme"><%= t(:readme, scope: :apitome) %></a>
6
+ <% else %>
7
+ <a href="<%= Apitome.configuration.mount_at %>"><%= t(:readme, scope: :apitome) %></a>
8
+ <% end %>
9
+ </li>
10
+ <% end %>
9
11
  <% resources.each do |resource| %>
10
12
  <li>
11
13
  <% if Apitome.configuration.single_page %>
12
- <a href="#<%= id_for(resource['examples'].first['link']) %>"><%= resource['name'] %></a>
14
+ <a href="#<%= id_for(resource['name']) %>"><%= resource['name'] %></a>
13
15
  <ul class="nav">
14
16
  <% resource['examples'].each do |example| %>
15
17
  <li><%= link_to example['description'], "##{id_for(example['link'])}" %></li>
16
18
  <% end %>
17
19
  </ul>
18
20
  <% else %>
19
- <li><%= link_to resource['name'], "#{Apitome.configuration.mount_at}/#{resource['examples'].first['link'].gsub(/\.json$/, '')}" %></li>
21
+ <%= link_to resource['name'], resource_link(resource), class: "#{link_active?(resource_link(resource)) ? 'active' : ''}" %>
20
22
  <ul class="nav">
21
23
  <% resource['examples'].each do |example| %>
22
- <li><%= link_to example['description'], "#{Apitome.configuration.mount_at}/#{example['link'].gsub(/\.json$/, '')}" %></li>
24
+ <li class="<%= link_active?(example_link(example)) ? 'active' : '' %>">
25
+ <%= link_to example['description'], example_link(example) %>
26
+ </li>
23
27
  <% end %>
24
28
  </ul>
25
29
  <% end %>
@@ -1,22 +1,22 @@
1
1
  <section class="params">
2
- <h3><%= t(:parameters) %></h3>
2
+ <h3><%= t(:parameters, scope: :apitome) %></h3>
3
3
  <div class="table-responsive">
4
4
  <table class="table table-bordered">
5
5
  <tr>
6
6
  <% param_headers(params).each do |title| %>
7
- <th><%= title %></th>
7
+ <th><%= title.titlecase %></th>
8
8
  <% end %>
9
9
  </tr>
10
10
  <% params.each do |param| %>
11
11
  <tr>
12
12
  <td class="name">
13
13
  <% if param['scope'] %>
14
- <%= "#{param['scope']}[#{param['name']}]" %>
14
+ <%= "#{format_scope(param['scope'])}[#{param['name']}]" %>
15
15
  <% else %>
16
16
  <%= param['name'] %>
17
17
  <% end %>
18
18
  <% if param['required'] %>
19
- <span class="label label-danger required">required</span>
19
+ <span class="label label-danger required"><%= t(:required, scope: :apitome) %></span>
20
20
  <% end %>
21
21
  </td>
22
22
  <td class="description"><%= param['description'] %></td>
@@ -1,4 +1,4 @@
1
1
  <section class="query-parameters">
2
- <h4><%= t(:query_parameters) %></h4>
2
+ <h4><%= t(:query_parameters, scope: :apitome) %></h4>
3
3
  <pre><%= request['request_query_parameters'].map{ |k,v| "#{k}=#{v}" }.join("\n") %></pre>
4
4
  </section>
@@ -0,0 +1,3 @@
1
+ <article class="resource_explanation">
2
+ <%= raw rendered_markdown(explanation.strip_heredoc) %>
3
+ </article>
@@ -1,5 +1,5 @@
1
1
  <section class="params">
2
- <h3><%= t(:response_fields) %></h3>
2
+ <h3><%= t(:response_fields, scope: :apitome) %></h3>
3
3
  <div class="table-responsive">
4
4
  <table class="table table-bordered">
5
5
  <tr>
@@ -1,4 +1,4 @@
1
1
  <section class="route">
2
- <h4><%= t(:route) %></h4>
2
+ <h4><%= t(:route, scope: :apitome) %></h4>
3
3
  <pre><%= "#{request['request_method']} #{request['request_path']}" %></pre>
4
4
  </section>
@@ -1,4 +1,4 @@
1
1
  <section class="status">
2
- <h4><%= t(:status) %></h4>
2
+ <h4><%= t(:status, scope: :apitome) %></h4>
3
3
  <pre><code class="http"><%= request['response_status'] %></code></pre>
4
4
  </section>
@@ -1,6 +1,11 @@
1
- <section class="readme" id="readme">
2
- <article>
3
- <%= raw formatted_readme %>
4
- </article>
5
- </section>
6
- <%= render 'all_examples' if Apitome.configuration.single_page %>
1
+ <% if Apitome.configuration.readme %>
2
+ <section class="readme" id="readme">
3
+ <article>
4
+ <%= raw formatted_readme %>
5
+ </article>
6
+ </section>
7
+ <% end %>
8
+ <% if Apitome.configuration.single_page %>
9
+ <a href="#top" id="scroll-to-top" class="hidden btn btn-primary">Back to Top</a>
10
+ <% end %>
11
+ <%= render 'all_examples' if Apitome.configuration.single_page %>
@@ -1,2 +1,3 @@
1
1
  <h1 class="resource-name"><%= example['resource'] %></h1>
2
- <%= render 'example' %>
2
+ <%= render partial: 'resource_explanation', locals: { explanation: example['resource_explanation'] } if example['resource_explanation'] %>
3
+ <%= render partial: 'example', locals: { example: example.merge!(link: params[:path]) } %>
@@ -3,11 +3,11 @@
3
3
  <head>
4
4
  <title><%= Apitome.configuration.title %></title>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <%= stylesheet_link_tag Apitome.configuration.code_theme_url, media: 'all' %>
7
- <%= stylesheet_link_tag Apitome.configuration.css_override || 'apitome/application', media: 'all' %>
8
- <%= javascript_include_tag Apitome.configuration.js_override || 'apitome/application' %>
6
+ <%= stylesheet_link_tag Apitome.configuration.css_override || "apitome/application", media: "all" %>
7
+ <%= stylesheet_link_tag "apitome/highlight_themes/#{Apitome.configuration.code_theme}", media: "all" %>
8
+ <%= javascript_include_tag Apitome.configuration.js_override || "apitome/application" %>
9
9
  </head>
10
- <body class="<%= Apitome.configuration.single_page ? 'single-page' : '' %>">
10
+ <body class="<%= Apitome.configuration.single_page ? "single-page" : "" %>">
11
11
 
12
12
  <div class="container">
13
13
  <%= render 'header' %>
@@ -1,12 +1,15 @@
1
1
  en:
2
- body: Body
3
- curl: cURL
4
- headers: Headers
5
- parameters: Parameters
6
- query_parameters: Query Parameters
7
- readme: README
8
- request: Request
9
- response: Response
10
- response_fields: Response Fields
11
- route: Route
12
- status: Status
2
+ apitome:
3
+ body: Body
4
+ curl: cURL
5
+ endpoint: Endpoint
6
+ headers: Headers
7
+ parameters: Parameters
8
+ query_parameters: Query Parameters
9
+ readme: README
10
+ request: Request
11
+ required: required
12
+ response_fields: Response Fields
13
+ response: Response
14
+ route: Route
15
+ status: Status
@@ -1,11 +1,15 @@
1
1
  es:
2
- body: Cuerpo
3
- curl: cURL
4
- headers: Encabezados
5
- parameters: Parametros
6
- query_parameters: Parámetros de la consulta
7
- readme: LEEME
8
- request: Solicitud
9
- response: Respuesta
10
- route: Ruta
11
- status: Estado
2
+ apitome:
3
+ body: Cuerpo
4
+ curl: cURL
5
+ endpoint: Punto de llegada
6
+ headers: Encabezados
7
+ parameters: Parametros
8
+ query_parameters: Parámetros de la consulta
9
+ readme: LEEME
10
+ request: Solicitud
11
+ required: requerido
12
+ response_fields: Campos de respuesta
13
+ response: Respuesta
14
+ route: Ruta
15
+ status: Estado
data/lib/apitome.rb CHANGED
@@ -1,7 +1,7 @@
1
- require 'apitome/version'
2
- require 'apitome/exceptions'
3
- require 'apitome/configuration'
1
+ require "kramdown"
4
2
 
5
- require 'apitome/engine'
3
+ require "apitome/version"
4
+ require "apitome/exceptions"
5
+ require "apitome/configuration"
6
6
 
7
- require 'kramdown'
7
+ require "apitome/engine"
@@ -4,31 +4,52 @@ module Apitome
4
4
  class Configuration
5
5
  include Singleton
6
6
 
7
- cattr_accessor :mount_at, :root, :doc_path, :title, :layout, :code_theme, :css_override, :js_override, :readme, :single_page
8
- @@mount_at = "/api/docs"
9
- @@root = nil # will default to Rails.root if left unset
10
- @@doc_path = 'doc/api'
11
- @@title = 'Apitome Documentation'
12
- @@layout = 'apitome/application'
13
- @@code_theme = 'default'
7
+ cattr_accessor *[
8
+ :mount_at,
9
+ :root,
10
+ :doc_path,
11
+ :parent_controller,
12
+ :title,
13
+ :layout,
14
+ :code_theme,
15
+ :css_override,
16
+ :js_override,
17
+ :readme,
18
+ :single_page,
19
+ :url_formatter,
20
+ :remote_url,
21
+ :http_basic_authentication,
22
+ :precompile_assets,
23
+ :simulated_response,
24
+ ]
25
+
26
+ @@mount_at = "/api/docs"
27
+ @@root = nil # will default to Rails.root if left unset
28
+ @@doc_path = "doc/api"
29
+ @@parent_controller = "ActionController::Base"
30
+ @@title = "Apitome Documentation"
31
+ @@layout = "apitome/application"
32
+ @@code_theme = "default"
14
33
  @@css_override = nil
15
- @@js_override = nil
16
- @@readme = '../api.md'
17
- @@single_page = true
34
+ @@js_override = nil
35
+ @@readme = "../api.md"
36
+ @@single_page = true
37
+ @@url_formatter = -> (str) { str.gsub(/\.json$/, "").underscore.gsub(/[^0-9a-z]+/i, "-") }
38
+ @@remote_url = nil
39
+ @@http_basic_authentication = nil
40
+ @@precompile_assets = true
41
+ @@simulated_response = true
18
42
 
19
43
  def self.root=(path)
20
44
  @@root = Pathname.new(path.to_s) if path.present?
21
45
  end
22
-
23
- def self.code_theme_url
24
- "apitome/highlight_themes/#{@@code_theme}"
25
- end
26
46
  end
27
47
 
28
48
  mattr_accessor :configuration
29
49
  @@configuration = Configuration
30
50
 
31
- def self.setup
51
+ def self.configure
32
52
  yield @@configuration
33
53
  end
54
+ singleton_class.send(:alias_method, :setup, :configure)
34
55
  end
@@ -1,22 +1,28 @@
1
1
  module Apitome
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace Apitome
4
+ apitome = Apitome.configuration
4
5
 
5
- config.assets.precompile += %w( apitome/*.css apitome/*.js )
6
+ routes do
7
+ root to: "docs#index"
8
+ get "/simulate/*path", to: "docs#simulate", as: :simulated if apitome.simulated_response
9
+ get "/*path", to: "docs#show" unless Apitome.configuration.single_page
10
+ end
6
11
 
7
12
  initializer :assets, group: :all do |app|
8
- # default the root if it's not set
9
- Apitome.configuration.root ||= app.root
13
+ apitome.root ||= app.root
14
+
15
+ config.assets.precompile += ["apitome/*.css", "apitome/*.js"]
16
+ config.assets.paths << root.join("assets", "stylesheets").to_s
17
+ config.assets.paths << root.join("assets", "javascripts").to_s
10
18
  end
11
19
 
12
20
  config.after_initialize do |app|
13
- # prepend routes so a catchall doesn't get in the way
14
- if Apitome.configuration.mount_at.present?
21
+ if apitome.mount_at.present?
15
22
  app.routes.prepend do
16
- mount Apitome::Engine => Apitome.configuration.mount_at
23
+ mount Apitome::Engine => apitome.mount_at
17
24
  end
18
25
  end
19
26
  end
20
-
21
27
  end
22
28
  end
@@ -1,3 +1,7 @@
1
1
  module Apitome
2
- class FileNotFound < Exception; end
2
+ class Error < StandardError
3
+ end
4
+
5
+ class FileNotFoundError < Apitome::Error
6
+ end
3
7
  end
@@ -1,3 +1,3 @@
1
1
  module Apitome
2
- VERSION = "0.0.8"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,4 +1,4 @@
1
1
  +============================================================================+
2
2
  Congratulations! Apitome was successfully installed.
3
3
 
4
- Documentation and more can be found at: https://github.com/modeset/apitome
4
+ Documentation and more can be found at: https://github.com/jejacks0n/apitome
@@ -5,10 +5,8 @@ module Apitome
5
5
 
6
6
  desc "Installs the Apitome initializer and markdown file into your application."
7
7
 
8
- class_option :assets, type: :boolean,
9
- aliases: "-a",
10
- default: false,
11
- desc: "Install the javascript and stylesheet assets to /public"
8
+ class_option :assets, type: :boolean, default: false,
9
+ aliases: "-a", desc: "Install the javascript and stylesheet assets to /public"
12
10
 
13
11
  def copy_initializers
14
12
  copy_file "templates/initializer.rb", "config/initializers/apitome.rb"
@@ -17,14 +15,15 @@ module Apitome
17
15
 
18
16
  def copy_assets
19
17
  return unless options[:assets]
20
- copy_file "../../../../app/assets/javascripts/apitome/bundle.js", "public/javascripts/apitome/application.js"
21
- copy_file "../../../../app/assets/stylesheets/apitome/bundle.css", "public/stylesheets/apitome/application.css"
18
+ @asset_root = "../../../../app/assets"
19
+
20
+ copy_file "#{@asset_root}/javascripts/apitome/bundle.js", "public/javascripts/apitome/application.js"
21
+ copy_file "#{@asset_root}/stylesheets/apitome/bundle.css", "public/stylesheets/apitome/application.css"
22
22
  end
23
23
 
24
- def display_readme
24
+ def display_post_install
25
25
  readme "POST_INSTALL" if behavior == :invoke
26
26
  end
27
-
28
27
  end
29
28
  end
30
29
  end