rapi_doc 0.1.0
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.
- data/.rvmrc +1 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +20 -0
- data/README +44 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/config.rb +25 -0
- data/lib/doc_util.rb +6 -0
- data/lib/method_doc.rb +32 -0
- data/lib/rapi_doc/railtie.rb +9 -0
- data/lib/rapi_doc/tasks/rapi_doc_tasks.rake +24 -0
- data/lib/rapi_doc.rb +69 -0
- data/lib/resource_doc.rb +124 -0
- data/templates/_resource_header.html.erb +18 -0
- data/templates/_resource_method.html.erb +39 -0
- data/templates/config.yml +3 -0
- data/templates/index.html.erb +67 -0
- data/templates/resource.html.erb +67 -0
- data/test/rapi_doc_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- data/uninstall.rb +1 -0
- metadata +124 -0
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm ruby-1.9.2-p180@rapidoc --create
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.6.4"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.6.4)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rake (0.9.2.2)
|
10
|
+
rcov (0.9.11)
|
11
|
+
shoulda (2.11.3)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 1.0.0)
|
18
|
+
jeweler (~> 1.6.4)
|
19
|
+
rcov
|
20
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Husein Choroomi
|
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/README
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
@WIP
|
2
|
+
Based on RAPI Doc by Jaap van der Meer found here: http://code.google.com/p/rapidoc/
|
3
|
+
|
4
|
+
Rails API Doc Generator
|
5
|
+
Original Author: JPM van der Meer
|
6
|
+
Modified By: Chelsea Robb
|
7
|
+
=======================
|
8
|
+
With API DOC one can generate code for a Restful Rails API.
|
9
|
+
It generates a set of HTML views in the public directory. Parses the desired controllers and generates appropriate views.
|
10
|
+
Currently does not read routes.rb and requires manual entry of routes
|
11
|
+
|
12
|
+
=INSTALL
|
13
|
+
gem install rapi_doc
|
14
|
+
|
15
|
+
==Layout files
|
16
|
+
You can find documentation layouts in config/rapi_doc
|
17
|
+
|
18
|
+
index.html.erb is used for index page.
|
19
|
+
resource.html.erb is used for individual controllers.
|
20
|
+
|
21
|
+
==Usage
|
22
|
+
Run 'rake rapi_doc' to generate config and layout files. (TODO: Add a separte rake task to generate config files)
|
23
|
+
Modify config file by adding your controllers, e.g.:
|
24
|
+
|
25
|
+
users:
|
26
|
+
location: "/users"
|
27
|
+
controller_name: "users_controller.rb"
|
28
|
+
|
29
|
+
Then invoke the generation by calling:
|
30
|
+
rake rapi_doc
|
31
|
+
|
32
|
+
==Documentation Example
|
33
|
+
|
34
|
+
=begin apidoc
|
35
|
+
url:: /users
|
36
|
+
method:: GET
|
37
|
+
access:: FREE
|
38
|
+
return:: [JSON|XML] - list of user objects
|
39
|
+
param:: page:int - the page, default is 1
|
40
|
+
param:: per_page:int - max items per page, default is 10
|
41
|
+
|
42
|
+
Get a list of all users in the system with pagination. Defaults to 10 per page
|
43
|
+
=end
|
44
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "rapi_doc"
|
18
|
+
gem.homepage = "http://github.com/hchoroomi/rapi_doc"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Rails API Doc Generator}
|
21
|
+
gem.description = %Q{Rails API Doc Generator}
|
22
|
+
gem.email = "hchoroomi@gmail.com"
|
23
|
+
gem.authors = ["Husein Choroomi"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "rapi_doc #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rapi_doc'
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
data/lib/config.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Config
|
2
|
+
def config_dir
|
3
|
+
File.join(::Rails.root.to_s, 'config/rapi_doc')
|
4
|
+
end
|
5
|
+
|
6
|
+
def template_dir
|
7
|
+
File.join(File.dirname(__FILE__), '/../templates')
|
8
|
+
end
|
9
|
+
|
10
|
+
def config_file(location)
|
11
|
+
File.join(find_location(location), 'config.yml')
|
12
|
+
end
|
13
|
+
|
14
|
+
def index_layout_file(location)
|
15
|
+
File.join(find_location(location), 'index.html.erb')
|
16
|
+
end
|
17
|
+
|
18
|
+
def resource_layout_file(location)
|
19
|
+
File.join(find_location(location), 'resource.html.erb')
|
20
|
+
end
|
21
|
+
|
22
|
+
def find_location(location)
|
23
|
+
location == :target ? config_dir : template_dir
|
24
|
+
end
|
25
|
+
end
|
data/lib/doc_util.rb
ADDED
data/lib/method_doc.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# This class holds methods about a doc.
|
2
|
+
class MethodDoc
|
3
|
+
attr_accessor :scope, :content, :request, :response, :code
|
4
|
+
|
5
|
+
def initialize(type)
|
6
|
+
@scope = type
|
7
|
+
@variables = []
|
8
|
+
@content = ""
|
9
|
+
@code = ""
|
10
|
+
@request = ""
|
11
|
+
@response = ""
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def add_variable(name, value)
|
16
|
+
if name == "param"
|
17
|
+
@variables << value
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
21
|
+
eval("@#{name}= \"#{value}\"")
|
22
|
+
|
23
|
+
if name == "json"
|
24
|
+
puts "Found json:"
|
25
|
+
puts @json
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_binding
|
30
|
+
binding
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
desc "Generate the API Documentation"
|
2
|
+
task :rapi_doc do
|
3
|
+
begin
|
4
|
+
yml = YAML::load(File.open(config_file(:target)))
|
5
|
+
rescue
|
6
|
+
FileUtils.mkdir(config_dir) if (!File.directory?(config_dir))
|
7
|
+
[config_file(:template), index_layout_file(:template), resource_layout_file(:template)].each do |_file|
|
8
|
+
FileUtils.cp _file, config_dir
|
9
|
+
puts "Generated config/rapi_doc/#{File.basename(_file)}" # TODO Add instructions for users to update the config file
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Generating documentations
|
14
|
+
if yml
|
15
|
+
resources = []
|
16
|
+
yml.keys.each do |key|
|
17
|
+
resources << ResourceDoc.new(key, yml[key]["location"], yml[key]["controller_name"])
|
18
|
+
end
|
19
|
+
|
20
|
+
# generate the apidoc
|
21
|
+
RAPIDoc.new(resources)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
data/lib/rapi_doc.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'doc_util'
|
4
|
+
require 'resource_doc'
|
5
|
+
require 'config'
|
6
|
+
require 'rapi_doc/railtie' if defined?(Rails)
|
7
|
+
|
8
|
+
include Config # TODO FIXME
|
9
|
+
|
10
|
+
class RAPIDoc
|
11
|
+
|
12
|
+
# Initalize the ApiDocGenerator
|
13
|
+
def initialize(resources)
|
14
|
+
puts "Apidoc started..."
|
15
|
+
@resources = resources
|
16
|
+
generate_templates!
|
17
|
+
move_structure!
|
18
|
+
puts "Finished."
|
19
|
+
end
|
20
|
+
|
21
|
+
# Iterates over the resources creates views for them.
|
22
|
+
# Creates an index file
|
23
|
+
def generate_templates!
|
24
|
+
|
25
|
+
@resources.each do |r|
|
26
|
+
r.parse_apidoc!
|
27
|
+
r.generate_view!(@resources, temp_dir)
|
28
|
+
end
|
29
|
+
generate_index!
|
30
|
+
copy_styles!
|
31
|
+
end
|
32
|
+
|
33
|
+
# generate the index file for the api views
|
34
|
+
def generate_index!
|
35
|
+
template = ""
|
36
|
+
File.open(index_layout_file(:target)).each { |line| template << line }
|
37
|
+
parsed = ERB.new(template).result(binding)
|
38
|
+
File.open(File.join(temp_dir, "index.html"), 'w') { |file| file.write parsed }
|
39
|
+
end
|
40
|
+
|
41
|
+
def move_structure!
|
42
|
+
target_folder = "#{::Rails.root.to_s}/public/apidoc/"
|
43
|
+
Dir.mkdir(target_folder) if (!File.directory?(target_folder))
|
44
|
+
|
45
|
+
Dir.new(temp_dir).each do |d|
|
46
|
+
if d =~ /^[a-zA-Z]+\.(html|css)$/ # Only want to copy over the .html files, not the .erb templates
|
47
|
+
FileUtils.cp File.join(temp_dir + d), target_folder + d
|
48
|
+
end
|
49
|
+
|
50
|
+
#Clean up the no longer needed files
|
51
|
+
filepath = "#{temp_dir}/#{d}"
|
52
|
+
File.delete(filepath) unless File.directory?(filepath)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def copy_styles!
|
57
|
+
Dir[File.join(File.dirname(__FILE__), '..', 'templates/*')].each do |f|
|
58
|
+
if f =~ /[\/a-zA-Z\.]+\.css$/i
|
59
|
+
FileUtils.cp f, temp_dir
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def temp_dir
|
67
|
+
@temp_dir ||= "#{Dir.mktmpdir("apidoc")}/"
|
68
|
+
end
|
69
|
+
end
|
data/lib/resource_doc.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'method_doc'
|
2
|
+
|
3
|
+
# ResourceDoc holds the information a resource contains. It parses the class header and also the
|
4
|
+
# method documentation, which will be contained in MethodDoc.
|
5
|
+
class ResourceDoc
|
6
|
+
|
7
|
+
attr_reader :name, :resource_location, :controller_name, :function_blocks, :class_block
|
8
|
+
|
9
|
+
# Initializes RAPIDoc.
|
10
|
+
def initialize(name, resource_location, controller_name, options = {})
|
11
|
+
@name = name
|
12
|
+
@standard_methods = options[:standard_methods] || [:put, :post, :get, :delete]
|
13
|
+
@resource_location, @controller_name = resource_location, controller_name
|
14
|
+
@function_blocks = []
|
15
|
+
@method_codes = []
|
16
|
+
@header_code = ""
|
17
|
+
|
18
|
+
unless File.exist?(controller_location)
|
19
|
+
raise "Unable to find or open controller. Make sure it's set properly in config/rapidoc/config.yml File: #{controller_location}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# returns the location of the controller that is to be parsed
|
24
|
+
def controller_location
|
25
|
+
"#{::Rails.root.to_s}/app/controllers/#{controller_name}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_binding
|
29
|
+
binding
|
30
|
+
end
|
31
|
+
|
32
|
+
# parse the controller
|
33
|
+
def parse_apidoc!
|
34
|
+
current_api_block = nil
|
35
|
+
current_scope = :none
|
36
|
+
block_holder = []
|
37
|
+
lineno = 0
|
38
|
+
inclass = false
|
39
|
+
|
40
|
+
File.open(controller_location).each do |line|
|
41
|
+
if line =~ /=begin apidoc/
|
42
|
+
current_scope = !inclass ? :class : :function
|
43
|
+
current_api_block = MethodDoc.new(current_scope)
|
44
|
+
elsif line =~ /=end/
|
45
|
+
if current_api_block.nil?
|
46
|
+
puts "#{controller_location}:#{lineno} - No starttag for =end found"
|
47
|
+
exit
|
48
|
+
elsif current_api_block.scope == :class
|
49
|
+
@class_block = current_api_block
|
50
|
+
elsif current_api_block.scope == :function
|
51
|
+
@function_blocks << current_api_block
|
52
|
+
end
|
53
|
+
current_api_block = nil
|
54
|
+
current_scope = :none
|
55
|
+
elsif line =~ /class/
|
56
|
+
inclass = true
|
57
|
+
elsif line =~ /::response-end::/
|
58
|
+
current_scope = :function
|
59
|
+
elsif line =~ /::request-end::/
|
60
|
+
current_scope = :function
|
61
|
+
elsif current_scope == :response
|
62
|
+
current_api_block.response += "#{line}"
|
63
|
+
elsif current_scope == :request
|
64
|
+
current_api_block.request += "#{line}"
|
65
|
+
elsif current_scope == :class || current_scope == :function # check if we are looking at a api block
|
66
|
+
# strip the # on the line
|
67
|
+
#line = line[1..line.length].lstrip.rstrip
|
68
|
+
# check if we are dealing with a variable
|
69
|
+
# something in the format: # varname:: sometext
|
70
|
+
if result = /(\w+)\:\:\s*(.+)/.match(line)
|
71
|
+
if result[1] == "response" || result[1] == "request"
|
72
|
+
puts "="*30
|
73
|
+
puts "found response"
|
74
|
+
puts "="*30; puts ""
|
75
|
+
puts line
|
76
|
+
current_scope = result[1].to_sym
|
77
|
+
else
|
78
|
+
current_api_block.add_variable(result[1], result[2])
|
79
|
+
end
|
80
|
+
else
|
81
|
+
# add line to block
|
82
|
+
current_api_block.content << line
|
83
|
+
end
|
84
|
+
end
|
85
|
+
lineno += 1
|
86
|
+
end
|
87
|
+
|
88
|
+
puts "Generated #{name}.html"
|
89
|
+
end
|
90
|
+
|
91
|
+
def generate_view!(resources, temp_dir)
|
92
|
+
@resources = resources
|
93
|
+
@header_code = get_parsed_header unless @class_block.nil?
|
94
|
+
function_blocks.each do |mb|
|
95
|
+
@method_codes << get_parsed_method(mb)
|
96
|
+
end
|
97
|
+
# write it to a file
|
98
|
+
template = ""
|
99
|
+
File.open(resource_layout_file(:target)).each { |line| template << line }
|
100
|
+
parsed = ERB.new(template).result(binding)
|
101
|
+
File.open(File.join(temp_dir, name + ".html"), 'w') { |file| file.write parsed }
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
def get_parsed_header
|
106
|
+
template = ""
|
107
|
+
File.open(File.join(File.dirname(__FILE__), '..', 'templates', '_resource_header.html.erb')).each { |line| template << line }
|
108
|
+
|
109
|
+
puts "-"*30
|
110
|
+
puts ">>> inside: get_parsed_header"
|
111
|
+
puts ERB.new(template).result(@class_block.get_binding)
|
112
|
+
puts "-"*30; puts ""
|
113
|
+
|
114
|
+
return ERB.new(template).result(@class_block.get_binding)
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
def get_parsed_method(method_block)
|
119
|
+
template = ""
|
120
|
+
File.open(File.join(File.dirname(__FILE__), '..', 'templates', '_resource_method.html.erb')).each { |line| template << line }
|
121
|
+
return ERB.new(template).result(method_block.get_binding)
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<h1><%=@name %></h1>
|
2
|
+
<p class="summary"><%=@content %></p>
|
3
|
+
|
4
|
+
<% if @xml || @json %>
|
5
|
+
<h2>Representations</h2>
|
6
|
+
|
7
|
+
<% if @json %>
|
8
|
+
<a name="json"></a>
|
9
|
+
<strong>JSON representation:</strong> <br /><a href="javascript:$('#jsonrep').toggle()">(toggle code)</a><br />
|
10
|
+
<textarea style="width:100%;height:200px;display:none;" id="jsonrep"><%=@json %></textarea><br />
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<% if @xml %>
|
14
|
+
<a name="xml"></a>
|
15
|
+
<strong>XML representation:</strong> <br /><a href="javascript:$('#xmlrep').toggle()">(toggle code)</a><br/>
|
16
|
+
<textarea style="width:100%;height:200px;display:none;" id="xmlrep"><%=@xml %></textarea>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<div id="method">
|
2
|
+
|
3
|
+
<%
|
4
|
+
splitted = @method
|
5
|
+
str = @method
|
6
|
+
str = "<span id='http_verb'>#{str}</span>"
|
7
|
+
%>
|
8
|
+
<p class='description'><strong>Description:</strong> <%=@content %></p>
|
9
|
+
|
10
|
+
<h2><%=str %><%=@url %></h2>
|
11
|
+
|
12
|
+
<% if @access %>
|
13
|
+
<strong>Access:</strong> <%=@access %><br />
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<% if @return %>
|
17
|
+
<strong>Return:</strong>
|
18
|
+
<%=@return %>
|
19
|
+
<br />
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
<% if @variables %>
|
23
|
+
<strong>Parameters:</strong>
|
24
|
+
<ul>
|
25
|
+
<% @variables.each do |v| %><li><%=v %></li><% end %>
|
26
|
+
</ul>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<% unless @request.blank? %>
|
30
|
+
<strong>Request:</strong>
|
31
|
+
<pre class="code"><code><%= @request %></code></pre>
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
<% unless @response.blank? %>
|
35
|
+
<strong>Response:</strong>
|
36
|
+
<pre class="code"><code><%= @response %></code></pre>
|
37
|
+
<% end %>
|
38
|
+
|
39
|
+
</div>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
5
|
+
<title><%= @name || 'Home' %></title>
|
6
|
+
|
7
|
+
<style>
|
8
|
+
body {
|
9
|
+
line-height: 1.5em;
|
10
|
+
color:#484848;
|
11
|
+
}
|
12
|
+
|
13
|
+
ul, ol {
|
14
|
+
margin-bottom: 0.8em;
|
15
|
+
}
|
16
|
+
|
17
|
+
li {
|
18
|
+
padding-left: 10px;
|
19
|
+
margin-right: 10px;
|
20
|
+
}
|
21
|
+
|
22
|
+
#resources {
|
23
|
+
|
24
|
+
}
|
25
|
+
|
26
|
+
h1, h2, h3 {
|
27
|
+
padding-top: 8px;
|
28
|
+
padding-bottom: 2px;
|
29
|
+
}
|
30
|
+
|
31
|
+
#method {
|
32
|
+
padding: 15px 30px;
|
33
|
+
border-top:1px solid #ddd;
|
34
|
+
}
|
35
|
+
|
36
|
+
#http_verb {
|
37
|
+
color:#ff6600;
|
38
|
+
width:200px;
|
39
|
+
margin-right:20px;'
|
40
|
+
}
|
41
|
+
|
42
|
+
.description{
|
43
|
+
font-size: 1.4em;
|
44
|
+
color:#262626;
|
45
|
+
}
|
46
|
+
</style>
|
47
|
+
|
48
|
+
</head>
|
49
|
+
<body>
|
50
|
+
<div class="content">
|
51
|
+
|
52
|
+
<div id="introduction">
|
53
|
+
<!-- documentation intro -->
|
54
|
+
</div>
|
55
|
+
|
56
|
+
<h2>Resources</h2>
|
57
|
+
<div id="resources">
|
58
|
+
<ul>
|
59
|
+
<% @resources.each do |r| %>
|
60
|
+
<li>Resource: <a href="/apidoc/<%=r.name %>.html"><%=r.resource_location %></a></li>
|
61
|
+
<% end %>
|
62
|
+
</ul>
|
63
|
+
</div>
|
64
|
+
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!-- TODO Use same layout for index and resources -->
|
2
|
+
<!DOCTYPE html>
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title><%= @name || 'Home' %></title>
|
7
|
+
|
8
|
+
<style>
|
9
|
+
body {
|
10
|
+
line-height: 1.5em;
|
11
|
+
color:#484848;
|
12
|
+
}
|
13
|
+
|
14
|
+
ul, ol {
|
15
|
+
margin-bottom: 0.8em;
|
16
|
+
}
|
17
|
+
|
18
|
+
li {
|
19
|
+
padding-left: 10px;
|
20
|
+
margin-right: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#resources {
|
24
|
+
|
25
|
+
}
|
26
|
+
|
27
|
+
h1, h2, h3 {
|
28
|
+
padding-top: 8px;
|
29
|
+
padding-bottom: 2px;
|
30
|
+
}
|
31
|
+
|
32
|
+
#method {
|
33
|
+
padding: 15px 30px;
|
34
|
+
border-top:1px solid #ddd;
|
35
|
+
}
|
36
|
+
|
37
|
+
#http_verb {
|
38
|
+
color:#ff6600;
|
39
|
+
width:200px;
|
40
|
+
margin-right:20px;'
|
41
|
+
}
|
42
|
+
|
43
|
+
.description{
|
44
|
+
font-size: 1.4em;
|
45
|
+
color:#262626;
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
|
49
|
+
</head>
|
50
|
+
<body>
|
51
|
+
<div class="content">
|
52
|
+
<div id="navigation">
|
53
|
+
<ul class="main">
|
54
|
+
<li><a href="/apidoc/index.html">« Back to index</a></li>
|
55
|
+
</ul>
|
56
|
+
</div>
|
57
|
+
|
58
|
+
<hr />
|
59
|
+
|
60
|
+
<%=@header_code %>
|
61
|
+
|
62
|
+
<% @method_codes.each do |mc| %>
|
63
|
+
<%=mc %>
|
64
|
+
<% end %>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
data/test/test_helper.rb
ADDED
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rapi_doc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Husein Choroomi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-10-31 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: shoulda
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: bundler
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: jeweler
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.6.4
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rcov
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *id004
|
59
|
+
description: Rails API Doc Generator
|
60
|
+
email: hchoroomi@gmail.com
|
61
|
+
executables: []
|
62
|
+
|
63
|
+
extensions: []
|
64
|
+
|
65
|
+
extra_rdoc_files:
|
66
|
+
- LICENSE.txt
|
67
|
+
- README
|
68
|
+
files:
|
69
|
+
- .rvmrc
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- LICENSE.txt
|
73
|
+
- README
|
74
|
+
- Rakefile
|
75
|
+
- VERSION
|
76
|
+
- init.rb
|
77
|
+
- install.rb
|
78
|
+
- lib/config.rb
|
79
|
+
- lib/doc_util.rb
|
80
|
+
- lib/method_doc.rb
|
81
|
+
- lib/rapi_doc.rb
|
82
|
+
- lib/rapi_doc/railtie.rb
|
83
|
+
- lib/rapi_doc/tasks/rapi_doc_tasks.rake
|
84
|
+
- lib/resource_doc.rb
|
85
|
+
- templates/_resource_header.html.erb
|
86
|
+
- templates/_resource_method.html.erb
|
87
|
+
- templates/config.yml
|
88
|
+
- templates/index.html.erb
|
89
|
+
- templates/resource.html.erb
|
90
|
+
- test/rapi_doc_test.rb
|
91
|
+
- test/test_helper.rb
|
92
|
+
- uninstall.rb
|
93
|
+
homepage: http://github.com/hchoroomi/rapi_doc
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 2005719792368905649
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: "0"
|
116
|
+
requirements: []
|
117
|
+
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 1.8.6
|
120
|
+
signing_key:
|
121
|
+
specification_version: 3
|
122
|
+
summary: Rails API Doc Generator
|
123
|
+
test_files: []
|
124
|
+
|