apidocs 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/app/assets/javascripts/apidocs/apidocs.js +9 -0
- data/app/assets/javascripts/apidocs/application.js +15 -0
- data/app/assets/javascripts/apidocs/jquery.fastLiveFilter.js +63 -0
- data/app/assets/stylesheets/apidocs/apidocs.css.scss +22 -0
- data/app/assets/stylesheets/apidocs/{application.css → application.css.scss} +0 -0
- data/app/assets/stylesheets/apidocs/custom.css.scss +1 -0
- data/app/controllers/apidocs/apidocs_controller.rb +24 -1
- data/app/views/apidocs/apidocs/index.html.erb +17 -16
- data/app/views/layouts/apidocs/application.html.erb +25 -6
- data/config/initializers/clean_up_rdoc_cache.rb +1 -0
- data/config/routes.rb +1 -0
- data/lib/apidocs.rb +5 -9
- data/lib/apidocs/version.rb +1 -1
- metadata +56 -9
- data/Rakefile +0 -29
- data/app/assets/stylesheets/apidocs/apidocs.css +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bfe483d12b61ff4f45099d88d9c8718f821174d
|
4
|
+
data.tar.gz: 582aaeb27ea6b21ddf24123401431dcb1e2f04aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f466a7b4fa9578aa603d39e1b19c833ee8f4063625bce6a03fc36d196aa208d21f6854eb729f6997fae0cd037d276064f19ef7bb1fb397ec57603986db8c7611
|
7
|
+
data.tar.gz: e50172ab4831f655fe508f9416241af2767968d8aaf560361832ef5353f69d4c8fbab3b498a722fc9102cb86234af52aaeaf2d359463d04b1f2bddbe8724c70f
|
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/**
|
2
|
+
* fastLiveFilter jQuery plugin 1.0.3
|
3
|
+
*
|
4
|
+
* Copyright (c) 2011, Anthony Bush
|
5
|
+
* License: <http://www.opensource.org/licenses/bsd-license.php>
|
6
|
+
* Project Website: http://anthonybush.com/projects/jquery_fast_live_filter/
|
7
|
+
**/
|
8
|
+
|
9
|
+
jQuery.fn.fastLiveFilter = function(list, options) {
|
10
|
+
// Options: input, list, timeout, callback
|
11
|
+
options = options || {};
|
12
|
+
list = jQuery(list);
|
13
|
+
var input = this;
|
14
|
+
var lastFilter = '';
|
15
|
+
var timeout = options.timeout || 0;
|
16
|
+
var callback = options.callback || function() {};
|
17
|
+
|
18
|
+
var keyTimeout;
|
19
|
+
|
20
|
+
// NOTE: because we cache lis & len here, users would need to re-init the plugin
|
21
|
+
// if they modify the list in the DOM later. This doesn't give us that much speed
|
22
|
+
// boost, so perhaps it's not worth putting it here.
|
23
|
+
var lis = list.children();
|
24
|
+
var len = lis.length;
|
25
|
+
var oldDisplay = len > 0 ? lis[0].style.display : "block";
|
26
|
+
callback(len); // do a one-time callback on initialization to make sure everything's in sync
|
27
|
+
|
28
|
+
input.change(function() {
|
29
|
+
// var startTime = new Date().getTime();
|
30
|
+
var filter = input.val().toLowerCase();
|
31
|
+
var li, innerText;
|
32
|
+
var numShown = 0;
|
33
|
+
for (var i = 0; i < len; i++) {
|
34
|
+
li = lis[i];
|
35
|
+
innerText = !options.selector ?
|
36
|
+
(li.textContent || li.innerText || "") :
|
37
|
+
$(li).find(options.selector).text();
|
38
|
+
|
39
|
+
if (innerText.toLowerCase().indexOf(filter) >= 0) {
|
40
|
+
if (li.style.display == "none") {
|
41
|
+
li.style.display = oldDisplay;
|
42
|
+
}
|
43
|
+
numShown++;
|
44
|
+
} else {
|
45
|
+
if (li.style.display != "none") {
|
46
|
+
li.style.display = "none";
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
callback(numShown);
|
51
|
+
// var endTime = new Date().getTime();
|
52
|
+
// console.log('Search for ' + filter + ' took: ' + (endTime - startTime) + ' (' + numShown + ' results)');
|
53
|
+
return false;
|
54
|
+
}).keydown(function() {
|
55
|
+
clearTimeout(keyTimeout);
|
56
|
+
keyTimeout = setTimeout(function() {
|
57
|
+
if( input.val() === lastFilter ) return;
|
58
|
+
lastFilter = input.val();
|
59
|
+
input.change();
|
60
|
+
}, timeout);
|
61
|
+
});
|
62
|
+
return this; // maintain jQuery chainability
|
63
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
pre {
|
2
|
+
background-color: black;
|
3
|
+
color: #999;
|
4
|
+
font-family: "Lucida Console", Monaco, monospace;
|
5
|
+
padding: 10px;
|
6
|
+
max-width: 100%;
|
7
|
+
overflow: auto;
|
8
|
+
}
|
9
|
+
|
10
|
+
#reload {
|
11
|
+
float: right;
|
12
|
+
font-size: 120%;
|
13
|
+
}
|
14
|
+
|
15
|
+
.action-name {
|
16
|
+
border-bottom: 1px black dotted;
|
17
|
+
}
|
18
|
+
|
19
|
+
#main-content h2 a,
|
20
|
+
#main-content h1 a {
|
21
|
+
display: none;
|
22
|
+
}
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "bootstrap";
|
@@ -3,7 +3,30 @@ require_dependency "apidocs/application_controller"
|
|
3
3
|
module Apidocs
|
4
4
|
class ApidocsController < ApplicationController
|
5
5
|
def index
|
6
|
-
@routes =
|
6
|
+
@routes = routes_rdoc
|
7
|
+
if params[:path]
|
8
|
+
@route = routes_rdoc[params[:path]]
|
9
|
+
else
|
10
|
+
begin
|
11
|
+
h = RDoc::Markup::ToHtml.new(RDoc::Options.new)
|
12
|
+
@intro = h.convert(Rails.root.join('API.rdoc').read)
|
13
|
+
rescue
|
14
|
+
@intro = "Please put API.rdoc into "+Rails.root.to_s
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def flush
|
20
|
+
Rails.cache.delete("routes_rdoc_html")
|
21
|
+
redirect_to :back
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def routes_rdoc
|
26
|
+
Rails.cache.fetch("routes_rdoc_html") do
|
27
|
+
routes = Apidocs::ApiDocs.new.generate_html
|
28
|
+
routes.group_by { |r| r[:path] }
|
29
|
+
end
|
7
30
|
end
|
8
31
|
end
|
9
32
|
end
|
@@ -1,17 +1,18 @@
|
|
1
|
-
|
2
|
-
<ul>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
</
|
7
|
-
<% end %>
|
8
|
-
</ul>
|
9
|
-
|
10
|
-
<h2>Documentation</h2>
|
11
|
-
|
12
|
-
<% @routes.each do |route| %>
|
13
|
-
<h3 id="<%= Digest::SHA1.hexdigest "#{route[:verb]} #{route[:path]}" %>">
|
14
|
-
<%= route[:verb] %> <%= route[:path] %>
|
15
|
-
</h3>
|
16
|
-
<%= route[:html_comment].html_safe %>
|
1
|
+
<% content_for :nav do %>
|
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' %></li>
|
5
|
+
<% end %>
|
6
|
+
</ul>
|
17
7
|
<% end %>
|
8
|
+
<% if @intro %>
|
9
|
+
<%= @intro.html_safe %>
|
10
|
+
<% end %>
|
11
|
+
<% if @route %>
|
12
|
+
<% @route.each do |r| %>
|
13
|
+
<h3 class="action-name">
|
14
|
+
<%= r[:verb] %> <%= r[:path] %>
|
15
|
+
</h3>
|
16
|
+
<%= r[:html_comment].html_safe %>
|
17
|
+
<% end %>
|
18
|
+
<% end%>
|
@@ -1,14 +1,33 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
<title>Apidocs</title>
|
5
|
+
<%= stylesheet_link_tag "apidocs/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "apidocs/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
8
|
</head>
|
9
9
|
<body>
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
<div class="container-fluid">
|
12
|
+
<nav class="navbar navbar-default" role="navigation">
|
13
|
+
<div class="container-fluid">
|
14
|
+
<%= link_to 'APIDOC', root_path, class: 'navbar-brand' %>
|
15
|
+
<form class="navbar-form navbar-left" role="search">
|
16
|
+
<div class="form-group">
|
17
|
+
<input type="text" class="search-query" id="search-input" placeholder="Search">
|
18
|
+
</div>
|
19
|
+
</form>
|
20
|
+
</div>
|
21
|
+
</nav>
|
22
|
+
<div class="row">
|
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>
|
29
|
+
</div>
|
30
|
+
<%= link_to "↺".html_safe, flush_path, id: 'reload' %>
|
31
|
+
</div>
|
13
32
|
</body>
|
14
33
|
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails.cache.delete("routes_rdoc_html")
|
data/config/routes.rb
CHANGED
data/lib/apidocs.rb
CHANGED
@@ -36,22 +36,19 @@ module Apidocs
|
|
36
36
|
inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
|
37
37
|
routes = inspector.send(:collect_routes, inspector.send(:filter_routes, nil)).select {|r| r[:reqs] =~ /#/}
|
38
38
|
|
39
|
+
formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new)
|
40
|
+
|
39
41
|
routes = routes.map do |r|
|
40
42
|
{ verb: r[:verb],
|
41
|
-
path: r[:path],
|
43
|
+
path: r[:path].sub('(.:format)',''),
|
42
44
|
class_name: gen_class_name(r),
|
43
45
|
action_name: gen_action_name(r)
|
44
46
|
}
|
45
47
|
end
|
46
48
|
|
47
49
|
routes.each do |r|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new)
|
52
|
-
|
53
|
-
routes.each do |r|
|
54
|
-
r[:html_comment] = r[:doc] ? r[:doc].accept(formatter) : ""
|
50
|
+
doc = document_route(r)
|
51
|
+
r[:html_comment] = doc ? doc.accept(formatter) : ""
|
55
52
|
end
|
56
53
|
|
57
54
|
routes.select {|r| r[:class_name] != "ApidocsController" }
|
@@ -62,7 +59,6 @@ module Apidocs
|
|
62
59
|
def document_route(r)
|
63
60
|
klas = @store.instance_variable_get("@classes_hash")[r[:class_name]]
|
64
61
|
return nil if klas.nil?
|
65
|
-
puts klas.methods_hash["##{r[:action_name]}"].try(:comment)
|
66
62
|
klas.methods_hash["##{r[:action_name]}"].try(:comment).try(:parse)
|
67
63
|
end
|
68
64
|
|
data/lib/apidocs/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Motsak
|
@@ -14,16 +14,58 @@ dependencies:
|
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
33
|
+
version: 4.0.0
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - "
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jquery-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
25
46
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bootstrap-sass
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
27
69
|
- !ruby/object:Gem::Dependency
|
28
70
|
name: sqlite3
|
29
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,19 +88,24 @@ extensions: []
|
|
46
88
|
extra_rdoc_files: []
|
47
89
|
files:
|
48
90
|
- MIT-LICENSE
|
49
|
-
-
|
50
|
-
- app/assets/
|
51
|
-
- app/assets/
|
91
|
+
- README.md
|
92
|
+
- app/assets/javascripts/apidocs/apidocs.js
|
93
|
+
- app/assets/javascripts/apidocs/application.js
|
94
|
+
- app/assets/javascripts/apidocs/jquery.fastLiveFilter.js
|
95
|
+
- app/assets/stylesheets/apidocs/apidocs.css.scss
|
96
|
+
- app/assets/stylesheets/apidocs/application.css.scss
|
97
|
+
- app/assets/stylesheets/apidocs/custom.css.scss
|
52
98
|
- app/controllers/apidocs/apidocs_controller.rb
|
53
99
|
- app/controllers/apidocs/application_controller.rb
|
54
100
|
- app/views/apidocs/apidocs/index.html.erb
|
55
101
|
- app/views/layouts/apidocs/application.html.erb
|
102
|
+
- config/initializers/clean_up_rdoc_cache.rb
|
56
103
|
- config/routes.rb
|
57
104
|
- lib/apidocs.rb
|
58
105
|
- lib/apidocs/engine.rb
|
59
106
|
- lib/apidocs/version.rb
|
60
107
|
- lib/tasks/apidocs_tasks.rake
|
61
|
-
homepage: http://github.com
|
108
|
+
homepage: http://github.com/vmotsak/apidocs
|
62
109
|
licenses:
|
63
110
|
- MIT
|
64
111
|
metadata: {}
|
data/Rakefile
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'bundler/setup'
|
3
|
-
rescue LoadError
|
4
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'rdoc/task'
|
8
|
-
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = 'Apidocs'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
16
|
-
|
17
|
-
Bundler::GemHelper.install_tasks
|
18
|
-
|
19
|
-
require 'rake/testtask'
|
20
|
-
|
21
|
-
Rake::TestTask.new(:test) do |t|
|
22
|
-
t.libs << 'lib'
|
23
|
-
t.libs << 'test'
|
24
|
-
t.pattern = 'test/**/*_test.rb'
|
25
|
-
t.verbose = false
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
task default: :test
|
@@ -1 +0,0 @@
|
|
1
|
-
pre { background-color: black; color: #999; font-family: "Lucida Console", Monaco, monospace; padding: 10px; max-width: 100%; overflow: auto;}
|