apitome 0.0.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/MIT.LICENSE +2 -2
- data/README.md +99 -40
- data/app/assets/javascripts/apitome/application.js +16 -0
- data/app/assets/stylesheets/apitome/application.css +10 -0
- data/app/controllers/apitome/docs_controller.rb +83 -45
- data/app/helpers/apitome/docs_helper.rb +19 -0
- data/app/views/apitome/docs/_all_examples.html.erb +6 -2
- data/app/views/apitome/docs/_body.html.erb +1 -1
- data/app/views/apitome/docs/_curl.html.erb +1 -1
- data/app/views/apitome/docs/_endpoint.html.erb +4 -0
- data/app/views/apitome/docs/_example.html.erb +10 -6
- data/app/views/apitome/docs/_explanation.html.erb +3 -3
- data/app/views/apitome/docs/_headers.html.erb +6 -4
- data/app/views/apitome/docs/_navigation.html.erb +14 -10
- data/app/views/apitome/docs/_params.html.erb +4 -4
- data/app/views/apitome/docs/_query.html.erb +1 -1
- data/app/views/apitome/docs/_resource_explanation.html.erb +3 -0
- data/app/views/apitome/docs/_response_fields.html.erb +1 -1
- data/app/views/apitome/docs/_route.html.erb +1 -1
- data/app/views/apitome/docs/_status.html.erb +1 -1
- data/app/views/apitome/docs/index.html.erb +11 -6
- data/app/views/apitome/docs/show.html.erb +2 -1
- data/app/views/layouts/apitome/application.html.erb +4 -4
- data/config/locales/en.yml +14 -11
- data/config/locales/es.yml +14 -10
- data/lib/apitome.rb +5 -5
- data/lib/apitome/configuration.rb +36 -15
- data/lib/apitome/engine.rb +13 -7
- data/lib/apitome/exceptions.rb +5 -1
- data/lib/apitome/version.rb +1 -1
- data/lib/generators/apitome/install/POST_INSTALL +1 -1
- data/lib/generators/apitome/install/install_generator.rb +7 -8
- data/lib/generators/apitome/install/templates/initializer.rb +35 -13
- data/vendor/assets/javascripts/apitome/highlight.min.js +2 -1
- data/vendor/assets/stylesheets/apitome/highlight_themes/agate.css +108 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/androidstudio.css +66 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/arduino-light.css +88 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/arta.css +41 -126
- data/vendor/assets/stylesheets/apitome/highlight_themes/ascetic.css +31 -36
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-cave-dark.css +83 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-cave-light.css +85 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-dune-dark.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-dune-light.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-estuary-dark.css +84 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-estuary-light.css +84 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-forest-dark.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-forest-light.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-heath-dark.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-heath-light.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-lakeside-dark.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-lakeside-light.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-plateau-dark.css +84 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-plateau-light.css +84 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-savanna-dark.css +84 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-savanna-light.css +84 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-seaside-dark.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-seaside-light.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-sulphurpool-dark.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/atelier-sulphurpool-light.css +69 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/brown-paper.css +64 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/{brown_papersq.png → brown-papersq.png} +0 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/codepen-embed.css +60 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/color-brewer.css +71 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/dark.css +41 -81
- data/vendor/assets/stylesheets/apitome/highlight_themes/darkula.css +74 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/default.css +74 -110
- data/vendor/assets/stylesheets/apitome/highlight_themes/docco.css +97 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/dracula.css +76 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/far.css +46 -86
- data/vendor/assets/stylesheets/apitome/highlight_themes/foundation.css +88 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/github-gist.css +71 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/github.css +53 -81
- data/vendor/assets/stylesheets/apitome/highlight_themes/googlecode.css +48 -103
- data/vendor/assets/stylesheets/apitome/highlight_themes/grayscale.css +101 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/gruvbox-dark.css +108 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/gruvbox-light.css +108 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/hopscotch.css +83 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/hybrid.css +102 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/idea.css +40 -64
- data/vendor/assets/stylesheets/apitome/highlight_themes/ir-black.css +73 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/kimbie.dark.css +74 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/kimbie.light.css +74 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/magula.css +36 -87
- data/vendor/assets/stylesheets/apitome/highlight_themes/mono-blue.css +59 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/monokai-sublime.css +83 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/monokai.css +50 -94
- data/vendor/assets/stylesheets/apitome/highlight_themes/obsidian.css +88 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/paraiso-dark.css +72 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/paraiso-light.css +72 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/pojoaque.css +45 -66
- data/vendor/assets/stylesheets/apitome/highlight_themes/purebasic.css +96 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/qtcreator_dark.css +83 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/qtcreator_light.css +83 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/railscasts.css +106 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/rainbow.css +48 -77
- data/vendor/assets/stylesheets/apitome/highlight_themes/school-book.css +72 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/{school_book.png → school-book.png} +0 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/solarized-dark.css +84 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/solarized-light.css +84 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/sunburst.css +55 -111
- data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow-night-blue.css +75 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow-night-bright.css +74 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow-night-eighties.css +74 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow-night.css +75 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow.css +43 -20
- data/vendor/assets/stylesheets/apitome/highlight_themes/vs.css +50 -68
- data/vendor/assets/stylesheets/apitome/highlight_themes/xcode.css +55 -116
- data/vendor/assets/stylesheets/apitome/highlight_themes/xt256.css +92 -0
- data/vendor/assets/stylesheets/apitome/highlight_themes/zenburn.css +49 -84
- metadata +80 -65
- data/config/routes.rb +0 -4
- data/spec/apitome/configuration_spec.rb +0 -0
- data/spec/apitome/engine_spec.rb +0 -0
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/config.ru +0 -15
- data/spec/dummy/config/application.rb +0 -16
- data/spec/dummy/config/boot.rb +0 -7
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -27
- data/spec/dummy/config/environments/test.rb +0 -29
- data/spec/dummy/config/initializers/apitome.rb +0 -44
- data/spec/dummy/config/routes.rb +0 -2
- data/spec/dummy/doc/api.md +0 -20
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/vendor/assets/stylesheets/apitome/highlight_themes/brown_paper.css +0 -104
- data/vendor/assets/stylesheets/apitome/highlight_themes/ir_black.css +0 -104
- data/vendor/assets/stylesheets/apitome/highlight_themes/school_book.css +0 -111
- data/vendor/assets/stylesheets/apitome/highlight_themes/solarized_dark.css +0 -88
- data/vendor/assets/stylesheets/apitome/highlight_themes/solarized_light.css +0 -88
- data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow_night.css +0 -52
- data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow_night_blue.css +0 -52
- data/vendor/assets/stylesheets/apitome/highlight_themes/tomorrow_night_bright.css +0 -51
- 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
|
-
|
6
|
-
|
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,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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<%= render partial: 'apitome/docs/
|
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
|
-
<
|
2
|
-
<%= raw example['explanation'] %>
|
3
|
-
</
|
1
|
+
<div class="explanation">
|
2
|
+
<%= raw rendered_markdown(example['explanation'].strip_heredoc) %>
|
3
|
+
</div>
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
2
|
-
<
|
3
|
-
|
4
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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['
|
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
|
-
|
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
|
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"
|
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,6 +1,11 @@
|
|
1
|
-
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
</
|
6
|
-
|
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
|
7
|
-
<%= stylesheet_link_tag
|
8
|
-
<%= javascript_include_tag Apitome.configuration.js_override ||
|
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 ?
|
10
|
+
<body class="<%= Apitome.configuration.single_page ? "single-page" : "" %>">
|
11
11
|
|
12
12
|
<div class="container">
|
13
13
|
<%= render 'header' %>
|
data/config/locales/en.yml
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
en:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
data/config/locales/es.yml
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
es:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
2
|
-
require 'apitome/exceptions'
|
3
|
-
require 'apitome/configuration'
|
1
|
+
require "kramdown"
|
4
2
|
|
5
|
-
require
|
3
|
+
require "apitome/version"
|
4
|
+
require "apitome/exceptions"
|
5
|
+
require "apitome/configuration"
|
6
6
|
|
7
|
-
require
|
7
|
+
require "apitome/engine"
|
@@ -4,31 +4,52 @@ module Apitome
|
|
4
4
|
class Configuration
|
5
5
|
include Singleton
|
6
6
|
|
7
|
-
cattr_accessor
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
16
|
-
@@readme
|
17
|
-
@@single_page
|
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.
|
51
|
+
def self.configure
|
32
52
|
yield @@configuration
|
33
53
|
end
|
54
|
+
singleton_class.send(:alias_method, :setup, :configure)
|
34
55
|
end
|
data/lib/apitome/engine.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
9
|
-
|
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
|
-
|
14
|
-
if Apitome.configuration.mount_at.present?
|
21
|
+
if apitome.mount_at.present?
|
15
22
|
app.routes.prepend do
|
16
|
-
mount Apitome::Engine =>
|
23
|
+
mount Apitome::Engine => apitome.mount_at
|
17
24
|
end
|
18
25
|
end
|
19
26
|
end
|
20
|
-
|
21
27
|
end
|
22
28
|
end
|
data/lib/apitome/exceptions.rb
CHANGED
data/lib/apitome/version.rb
CHANGED
@@ -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/
|
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
|
-
|
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
|
-
|
21
|
-
|
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
|
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
|