apidocs 0.0.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +29 -0
- data/app/assets/stylesheets/apidocs/apidocs.css +1 -0
- data/app/assets/stylesheets/apidocs/application.css +15 -0
- data/app/controllers/apidocs/apidocs_controller.rb +9 -0
- data/app/controllers/apidocs/application_controller.rb +4 -0
- data/app/views/apidocs/apidocs/index.html.erb +17 -0
- data/app/views/layouts/apidocs/application.html.erb +14 -0
- data/config/routes.rb +3 -0
- data/lib/apidocs.rb +80 -0
- data/lib/apidocs/engine.rb +5 -0
- data/lib/apidocs/version.rb +3 -0
- data/lib/tasks/apidocs_tasks.rake +4 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d2def707f7b8578ecd5cb455e04355916deae5b7
|
4
|
+
data.tar.gz: a9a903e49b5261b7c1320c6cde03078ba85db5dc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8caf8d21c4d59b525513559037b16c43a4d4b12684f3f6d7dcb0966102c822618758d97b996a4f00c14392a2e0437876509f17794acb5fbd29155b568dc448e0
|
7
|
+
data.tar.gz: 095bdaff380c72191c49145cbf04fb03da95ea0564faaa13fbdbb0e8131b40c1af1f4d1554126973113cc0001a6d5438ad482d09fda3fe101edffdac756a2f2f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
pre { background-color: black; color: #999; font-family: "Lucida Console", Monaco, monospace; padding: 10px; max-width: 100%; overflow: auto;}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<h2>Table of Contents</h2>
|
2
|
+
<ul>
|
3
|
+
<% @routes.each do |route| %>
|
4
|
+
<li>
|
5
|
+
<a href="#<%= Digest::SHA1.hexdigest "#{route[:verb]} #{route[:path]}" %>"><%= route[:verb] %> <%= route[:path] %></a>
|
6
|
+
</li>
|
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 %>
|
17
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Apidocs</title>
|
5
|
+
<%= stylesheet_link_tag "apidocs/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "apidocs/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
data/lib/apidocs.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require "apidocs/engine"
|
2
|
+
|
3
|
+
module Apidocs
|
4
|
+
require 'rdoc'
|
5
|
+
require 'action_dispatch/routing/inspector'
|
6
|
+
require 'fileutils'
|
7
|
+
# This is class comment
|
8
|
+
class ApiDocs < RDoc::RDoc
|
9
|
+
# generate_html entry point for on fly document generation
|
10
|
+
def generate_html
|
11
|
+
FileUtils.rm_rf(Rails.root.join('tmp/apidocs'))
|
12
|
+
options = ["app/controllers", "--op=#{Rails.root.join('tmp/apidocs')}"]
|
13
|
+
|
14
|
+
self.store = RDoc::Store.new
|
15
|
+
|
16
|
+
@options = load_options
|
17
|
+
@options.parse options
|
18
|
+
@exclude = @options.exclude
|
19
|
+
|
20
|
+
@last_modified = setup_output_dir @options.op_dir, @options.force_update
|
21
|
+
|
22
|
+
@store.encoding = @options.encoding if @options.respond_to? :encoding
|
23
|
+
@store.dry_run = @options.dry_run
|
24
|
+
@store.main = @options.main_page
|
25
|
+
@store.title = @options.title
|
26
|
+
@store.path = @options.op_dir
|
27
|
+
|
28
|
+
@start_time = Time.now
|
29
|
+
@store.load_cache
|
30
|
+
@options.default_title = "RDoc Documentation"
|
31
|
+
|
32
|
+
parse_files @options.files
|
33
|
+
@store.complete @options.visibility
|
34
|
+
|
35
|
+
all_routes = Rails.application.routes.routes
|
36
|
+
inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
|
37
|
+
routes = inspector.send(:collect_routes, inspector.send(:filter_routes, nil)).select {|r| r[:reqs] =~ /#/}
|
38
|
+
|
39
|
+
routes = routes.map do |r|
|
40
|
+
{ verb: r[:verb],
|
41
|
+
path: r[:path],
|
42
|
+
class_name: gen_class_name(r),
|
43
|
+
action_name: gen_action_name(r)
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
routes.each do |r|
|
48
|
+
r[:doc] = document_route(r)
|
49
|
+
end
|
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) : ""
|
55
|
+
end
|
56
|
+
|
57
|
+
routes.select {|r| r[:class_name] != "ApidocsController" }
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def document_route(r)
|
63
|
+
klas = @store.instance_variable_get("@classes_hash")[r[:class_name]]
|
64
|
+
return nil if klas.nil?
|
65
|
+
puts klas.methods_hash["##{r[:action_name]}"].try(:comment)
|
66
|
+
klas.methods_hash["##{r[:action_name]}"].try(:comment).try(:parse)
|
67
|
+
end
|
68
|
+
|
69
|
+
def gen_class_name(r)
|
70
|
+
"#{r[:reqs].split("#").first}_controller".classify
|
71
|
+
end
|
72
|
+
|
73
|
+
def gen_action_name(r)
|
74
|
+
"#{r[:reqs].split("#").last}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: apidocs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vladimir Motsak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: On Fly RDoc generation
|
42
|
+
email:
|
43
|
+
- vmotsak@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- Rakefile
|
50
|
+
- app/assets/stylesheets/apidocs/apidocs.css
|
51
|
+
- app/assets/stylesheets/apidocs/application.css
|
52
|
+
- app/controllers/apidocs/apidocs_controller.rb
|
53
|
+
- app/controllers/apidocs/application_controller.rb
|
54
|
+
- app/views/apidocs/apidocs/index.html.erb
|
55
|
+
- app/views/layouts/apidocs/application.html.erb
|
56
|
+
- config/routes.rb
|
57
|
+
- lib/apidocs.rb
|
58
|
+
- lib/apidocs/engine.rb
|
59
|
+
- lib/apidocs/version.rb
|
60
|
+
- lib/tasks/apidocs_tasks.rake
|
61
|
+
homepage: http://github.com
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.2.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: On Fly RDoc generation
|
85
|
+
test_files: []
|