apidocs 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -3
- data/app/controllers/apidocs/apidocs_controller.rb +12 -13
- data/app/views/apidocs/apidocs/index.html.erb +16 -12
- data/app/views/layouts/apidocs/application.html.erb +23 -22
- data/config/routes.rb +0 -1
- data/lib/apidocs.rb +2 -2
- data/lib/apidocs/version.rb +1 -1
- metadata +8 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23ce21f1585d8d57c49827f01a859ada6c85a8a9
|
4
|
+
data.tar.gz: f188f609d02c9f7b576ee0e2465c098552fddf87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b72c69640d2092773e8e33a184a13ece507ec10561271102e6c37780b5dae3c425a2bd0f67635a9ced1901fb5157136a082b3188f4803e8eb555f828f04e3aa2
|
7
|
+
data.tar.gz: be363524935efb6957511d522d12d05aed221c2c96b91129ec0eff9df72d8e00da454e7a65e22a11e681f6760b4eec09f1b780e1d2a41c873ab55e2a18f5a1ec
|
data/README.md
CHANGED
@@ -1,18 +1,30 @@
|
|
1
|
-
|
1
|
+
APIDOCS
|
2
2
|
=======
|
3
3
|
|
4
|
-
Generates and serves
|
4
|
+
Generates on fly and serves RDoc documentation out of your controllers actions.
|
5
|
+
|
6
|
+
Implemented as rails engine
|
5
7
|
|
6
8
|
Installation
|
7
9
|
=======
|
10
|
+
Apidocs works with Rails 3.2 onwards. You can add it to your Gemfile with:
|
11
|
+
|
12
|
+
```gem 'apidocs'```
|
13
|
+
|
14
|
+
Run the bundle command to install it.
|
8
15
|
|
9
16
|
Add ```mount Apidocs::Engine => "/apidocs"``` to your applications ```routes.rb```
|
10
17
|
|
11
18
|
Configuration
|
12
19
|
=======
|
13
20
|
|
21
|
+
For better safety, in configuration file there is a MD5 hash of password used instead of actual password.
|
22
|
+
To generate it for your configuration use Digest::MD5.hexdigest('YOUR-PASSWORD-HERE').
|
23
|
+
It can be done in irb after requiring 'digest/md5'.
|
24
|
+
|
14
25
|
Apidocs.configure do |config|
|
15
|
-
config.regex_filter =
|
26
|
+
config.regex_filter = /\A\/api/ # filter routes
|
16
27
|
config.http_username = 'admin' # optional http basic authorization
|
17
28
|
config.http_password = '5ebe2294ecd0e0f08eab7690d2a6ee69' # md5 hash for password
|
29
|
+
config.app_name = 'Test APP' # application name
|
18
30
|
end
|
@@ -3,10 +3,10 @@ require_dependency "apidocs/application_controller"
|
|
3
3
|
module Apidocs
|
4
4
|
class ApidocsController < ApplicationController
|
5
5
|
before_action :authenticate
|
6
|
+
before_action :clean_cache, if: -> { Rails.env.development? }
|
6
7
|
|
7
8
|
def index
|
8
9
|
@routes = routes_rdoc
|
9
|
-
|
10
10
|
if params[:search]
|
11
11
|
@searchinput = params[:search]
|
12
12
|
end
|
@@ -14,20 +14,10 @@ module Apidocs
|
|
14
14
|
if params[:path]
|
15
15
|
@route = routes_rdoc[params[:path]]
|
16
16
|
else
|
17
|
-
|
18
|
-
h = RDoc::Markup::ToHtml.new(RDoc::Options.new)
|
19
|
-
@intro = h.convert(Rails.root.join('API.rdoc').read)
|
20
|
-
rescue
|
21
|
-
@intro = "Please put API.rdoc into "+Rails.root.to_s
|
22
|
-
end
|
17
|
+
@intro = intro_rdoc
|
23
18
|
end
|
24
19
|
end
|
25
20
|
|
26
|
-
def flush
|
27
|
-
Rails.cache.delete("routes_rdoc_html")
|
28
|
-
redirect_to :back
|
29
|
-
end
|
30
|
-
|
31
21
|
private
|
32
22
|
|
33
23
|
def routes_rdoc
|
@@ -37,6 +27,12 @@ module Apidocs
|
|
37
27
|
end
|
38
28
|
end
|
39
29
|
|
30
|
+
def intro_rdoc
|
31
|
+
RDoc::Markup::ToHtml.new(RDoc::Options.new).convert(Rails.root.join('API.rdoc').read)
|
32
|
+
rescue
|
33
|
+
""
|
34
|
+
end
|
35
|
+
|
40
36
|
def authenticate
|
41
37
|
if Apidocs.configuration.http_username && Apidocs.configuration.http_password
|
42
38
|
authenticate_or_request_with_http_basic do |u, p|
|
@@ -44,6 +40,9 @@ module Apidocs
|
|
44
40
|
end
|
45
41
|
end
|
46
42
|
end
|
43
|
+
|
44
|
+
def clean_cache
|
45
|
+
Rails.cache.delete("routes_rdoc_html")
|
46
|
+
end
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
@@ -1,18 +1,22 @@
|
|
1
1
|
<% content_for :nav do %>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
<ul id="search-list" class="list-unstyled">
|
3
|
+
<% @routes.each do |path, route| %>
|
4
|
+
<li><%= link_to path, root_path(path: path), class: 'nav-button', title: path %></li>
|
5
|
+
<% end %>
|
6
|
+
</ul>
|
7
7
|
<% end %>
|
8
|
+
|
8
9
|
<% if @intro %>
|
9
|
-
|
10
|
+
<%= @intro.html_safe %>
|
10
11
|
<% end %>
|
12
|
+
|
11
13
|
<% if @route %>
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
<% @route.each do |r| %>
|
15
|
+
|
16
|
+
<h3 class="action-name">
|
17
|
+
<%= r[:verb] %> <%= r[:path] %>
|
18
|
+
</h3>
|
19
|
+
|
20
|
+
<%= r[:html_comment].html_safe %>
|
21
|
+
<% end %>
|
18
22
|
<% end%>
|
@@ -1,33 +1,34 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
<title
|
3
|
+
<head>
|
4
|
+
<title><%= Apidocs.configuration.app_name %> API</title>
|
5
5
|
<%= stylesheet_link_tag "apidocs/application", media: "all" %>
|
6
6
|
<%= javascript_include_tag "apidocs/application" %>
|
7
7
|
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
8
|
+
</head>
|
10
9
|
|
11
|
-
<
|
12
|
-
<
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
<body>
|
11
|
+
<div class="container">
|
12
|
+
<div class="row">
|
13
|
+
<nav class="navbar navbar-default" role="navigation">
|
14
|
+
<%= link_to "#{Apidocs.configuration.app_name} API", root_path, class: 'navbar-brand' %>
|
15
|
+
</nav>
|
16
|
+
|
17
|
+
<div class="col-md-3">
|
18
|
+
<div class="row">
|
19
|
+
<form class="col-md-12" role="search">
|
20
|
+
<div class="form-group">
|
21
|
+
<input type="text" value='<%= @searchinput %>' class="form-control" id="search-input" placeholder="Filter">
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<nav><%= yield(:nav) %></nav>
|
19
25
|
</form>
|
26
|
+
</div>
|
20
27
|
</div>
|
21
|
-
|
22
|
-
|
23
|
-
<div class="col-md-2">
|
24
|
-
<nav><%= yield(:nav) %></nav>
|
25
|
-
</div>
|
26
|
-
<div class="col-md-10">
|
27
|
-
<article id="main-content"><%= yield %></article>
|
28
|
+
<div class="col-md-9">
|
29
|
+
<article id="main-content"><%= yield %></article>
|
28
30
|
</div>
|
31
|
+
</div>
|
29
32
|
</div>
|
30
|
-
|
31
|
-
</div>
|
32
|
-
</body>
|
33
|
+
</body>
|
33
34
|
</html>
|
data/config/routes.rb
CHANGED
data/lib/apidocs.rb
CHANGED
@@ -9,7 +9,7 @@ module Apidocs
|
|
9
9
|
# generate_html entry point for on fly document generation
|
10
10
|
def generate_html
|
11
11
|
FileUtils.rm_rf(Rails.root.join('tmp/apidocs'))
|
12
|
-
options = ["app/controllers", "--op=#{Rails.root.join('tmp/apidocs')}"]
|
12
|
+
options = [Rails.root.join("app/controllers").to_s, "--op=#{Rails.root.join('tmp/apidocs')}"]
|
13
13
|
|
14
14
|
self.store = RDoc::Store.new
|
15
15
|
|
@@ -73,7 +73,7 @@ module Apidocs
|
|
73
73
|
end
|
74
74
|
|
75
75
|
class Configuration
|
76
|
-
attr_accessor :regex_filter, :http_username, :http_password
|
76
|
+
attr_accessor :regex_filter, :http_username, :http_password, :app_name
|
77
77
|
def initialize
|
78
78
|
@regex_filter = /.*/
|
79
79
|
end
|
data/lib/apidocs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apidocs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Hubert Łępicki
|
8
|
+
- Dominika Kruk
|
7
9
|
- Vladimir Motsak
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
13
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: rails
|
@@ -66,22 +68,10 @@ dependencies:
|
|
66
68
|
- - ">="
|
67
69
|
- !ruby/object:Gem::Version
|
68
70
|
version: '0'
|
69
|
-
|
70
|
-
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
description: On Fly RDoc generation
|
71
|
+
description: Rails engine that will generate and serve docs for your APIs if you documented
|
72
|
+
your controllers using RDoc
|
84
73
|
email:
|
74
|
+
- hubert.lepicki@gmail.com
|
85
75
|
- vmotsak@gmail.com
|
86
76
|
executables: []
|
87
77
|
extensions: []
|
@@ -105,7 +95,7 @@ files:
|
|
105
95
|
- lib/apidocs/engine.rb
|
106
96
|
- lib/apidocs/version.rb
|
107
97
|
- lib/tasks/apidocs_tasks.rake
|
108
|
-
homepage: http://github.com/
|
98
|
+
homepage: http://github.com/hubertlepicki/apidocs
|
109
99
|
licenses:
|
110
100
|
- MIT
|
111
101
|
metadata: {}
|