rapi_doc 0.1.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,10 +3,12 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
+ gem 'activesupport', '>= 2.1'
7
+
6
8
  # Add dependencies to develop your gem here.
7
9
  # Include everything needed to run rake, tests, features, etc.
8
10
  group :development do
9
- gem "shoulda", ">= 0"
11
+ gem "rspec", "~> 2.7.0"
10
12
  gem "bundler", "~> 1.0.0"
11
13
  gem "jeweler", "~> 1.6.4"
12
14
  gem "rcov", ">= 0"
@@ -1,20 +1,32 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ activesupport (3.1.3)
5
+ multi_json (~> 1.0)
6
+ diff-lcs (1.1.3)
4
7
  git (1.2.5)
5
8
  jeweler (1.6.4)
6
9
  bundler (~> 1.0)
7
10
  git (>= 1.2.5)
8
11
  rake
12
+ multi_json (1.0.4)
9
13
  rake (0.9.2.2)
10
14
  rcov (0.9.11)
11
- shoulda (2.11.3)
15
+ rspec (2.7.0)
16
+ rspec-core (~> 2.7.0)
17
+ rspec-expectations (~> 2.7.0)
18
+ rspec-mocks (~> 2.7.0)
19
+ rspec-core (2.7.1)
20
+ rspec-expectations (2.7.0)
21
+ diff-lcs (~> 1.1.2)
22
+ rspec-mocks (2.7.0)
12
23
 
13
24
  PLATFORMS
14
25
  ruby
15
26
 
16
27
  DEPENDENCIES
28
+ activesupport (>= 2.1)
17
29
  bundler (~> 1.0.0)
18
30
  jeweler (~> 1.6.4)
19
31
  rcov
20
- shoulda
32
+ rspec (~> 2.7.0)
data/README.md CHANGED
@@ -1,9 +1,7 @@
1
1
  Rails API Doc Generator
2
2
  =======================
3
3
 
4
- RESTTful API generator...
5
-
6
- It generates a set of HTML views in the public directory. Parses the desired controllers and generates appropriate views.
4
+ RESTTful API documentation generator for Rails. It supports Rails 2.1 and greater. It generates a set of HTML views in the public directory. Parses the desired controllers and generates appropriate views.
7
5
 
8
6
  Currently does not read routes.rb and requires manual entry of routes
9
7
 
@@ -19,11 +17,9 @@ Run `rake rapi_doc` to generate config and layout files. (TODO: Add a separate r
19
17
 
20
18
  Modify config file by adding your controllers, e.g.:
21
19
 
22
- `
23
- users:
24
- location: "/users"
25
- controller_name: "users_controller.rb"
26
- `
20
+ books:
21
+ location: "/books"
22
+ controller_name: "books_controller.rb"
27
23
 
28
24
  Then invoke the generation by calling:
29
25
 
@@ -32,16 +28,41 @@ Then invoke the generation by calling:
32
28
  Documentation Example
33
29
  ---------------------
34
30
 
35
- =begin apidoc
36
- url:: /users
37
- method:: GET
38
- access:: FREE
39
- return:: [JSON|XML] - list of user objects
40
- param:: page:int - the page, default is 1
41
- param:: per_page:int - max items per page, default is 10
42
-
43
- Get a list of all users in the system with pagination. Defaults to 10 per page
44
- =end
31
+ # =begin apidoc
32
+ # url:: /books
33
+ # method:: GET
34
+ # access:: FREE
35
+ # return:: [JSON|XML] - list of book objects
36
+ # param:: page:int - the page, default is 1
37
+ # param:: per_page:int - max items per page, default is 10
38
+ #
39
+ # output:: json
40
+ # [
41
+ # { "created_at":"2011-12-05T09:46:11Z",
42
+ # "description":"As with the last several books in the series, V Is for Vengeance was a long time in the making.",
43
+ # "id":1,
44
+ # "price":19,
45
+ # "title":"V is for Vengeance",
46
+ # "updated_at":"2011-12-05T09:46:11Z" },
47
+ # ]
48
+ # ::output-end::
49
+ #
50
+ # output:: xml
51
+ # <books type="array">
52
+ # <book>
53
+ # <id type="integer">1</id>
54
+ # <title>V is for Vengeance</title>
55
+ # <description>As with the last several books in the series, V Is for Vengeance was a long time in the making.</description>
56
+ # <price type="integer">19</price>
57
+ # <created-at type="datetime">2011-12-05T09:46:11Z</created-at>
58
+ # <updated-at type="datetime">2011-12-05T09:46:11Z</updated-at>
59
+ # </book>
60
+ # </books>
61
+ #::output-end::
62
+ #
63
+ # Get a list of all books in the system with pagination. Defaults to 10 per page
64
+ # =end
65
+
45
66
 
46
67
  Layout
47
68
  ------
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ Jeweler::Tasks.new do |gem|
20
20
  gem.summary = %Q{Rails API Doc Generator}
21
21
  gem.description = %Q{Rails API Doc Generator}
22
22
  gem.email = "hchoroomi@gmail.com"
23
- gem.authors = ["Husein Choroomi"]
23
+ gem.authors = ["Husein Choroomi", "Adinda Praditya"]
24
24
  # dependencies defined in Gemfile
25
25
  end
26
26
  Jeweler::RubygemsDotOrgTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.1
@@ -0,0 +1,53 @@
1
+ module RapiDoc
2
+ # This class holds the methods that parse the doc
3
+ class DocParser
4
+ attr_accessor :current_api_block, :current_scope, :line_no, :in_class
5
+
6
+ def initialize
7
+ @current_api_block = nil
8
+ @current_scope = :none
9
+ @line_no = 0
10
+ @in_class = false
11
+ end
12
+
13
+ def start
14
+ @current_scope = !in_class ? :class : :function
15
+ @current_api_block = MethodDoc.new(current_scope)
16
+ end
17
+
18
+ def reset_current_scope_and_api_block
19
+ @current_api_block = nil
20
+ @current_scope = :none
21
+ end
22
+
23
+ def parse(line)
24
+ case current_scope
25
+ when :response
26
+ @current_api_block.response += strip_line(line)
27
+ when :request
28
+ @current_api_block.request += strip_line(line)
29
+ when :output
30
+ @current_api_block.append_output strip_line(line)
31
+ when :class, :function
32
+ if result = /(\w+)\:\:\s*(.+)/.match(line)
33
+ if result[1] == "response" || result[1] == "request"
34
+ @current_scope = result[1].to_sym
35
+ elsif result[1] == "output"
36
+ @current_scope = result[1].to_sym
37
+ @current_api_block.add_output(result[1], result[2])
38
+ else
39
+ @current_api_block.add_variable(result[1], result[2])
40
+ end
41
+ else
42
+ # add line to block
43
+ @current_api_block.content << strip_line(line)
44
+ end
45
+ end
46
+ end
47
+
48
+ # strip the '#' on the line
49
+ def strip_line(line)
50
+ line[1..line.length]
51
+ end
52
+ end
53
+ end
@@ -1,11 +1,12 @@
1
1
  module RapiDoc
2
2
  # This class holds methods about a doc.
3
3
  class MethodDoc
4
- attr_accessor :scope, :content, :request, :response, :code
4
+ attr_accessor :scope, :content, :request, :response, :code, :outputs, :variables
5
5
 
6
6
  def initialize(type)
7
7
  @scope = type
8
8
  @variables = []
9
+ @outputs = []
9
10
  @content = ""
10
11
  @code = ""
11
12
  @request = ""
@@ -20,8 +21,21 @@ module RapiDoc
20
21
  end
21
22
 
22
23
  eval("@#{name}= \"#{value}\"")
24
+ self.class.class_eval { attr_accessor name.to_sym }
23
25
  end
24
-
26
+
27
+ def add_output(name, value)
28
+ if name == 'output'
29
+ @outputs << eval("{#{value}: ''}")
30
+ return
31
+ end
32
+ end
33
+
34
+ def append_output(value)
35
+ last_output_key = @outputs.last.keys[0]
36
+ @outputs.last[last_output_key] += ERB::Util.html_escape(value)
37
+ end
38
+
25
39
  def get_binding
26
40
  binding
27
41
  end
@@ -1,7 +1,9 @@
1
1
  module RapiDoc
2
2
  module RapiConfig
3
+ BASE_DIR = 'config/rapi_doc'
4
+
3
5
  def config_dir
4
- File.join(::Rails.root.to_s, 'config/rapi_doc')
6
+ File.join(::Rails.root.to_s, BASE_DIR)
5
7
  end
6
8
 
7
9
  def template_dir
@@ -1,26 +1,41 @@
1
1
  include RapiDoc::RapiConfig
2
2
 
3
- desc "Generate the API Documentation"
4
- task :rapi_doc do
5
- begin
6
- yml = YAML::load(File.open(config_file(:target)))
7
- rescue
8
- FileUtils.mkdir(config_dir) if (!File.directory?(config_dir))
9
- [config_file(:template), layout_file(:template)].each do |_file|
10
- FileUtils.cp _file, config_dir
11
- puts "Generated config/rapi_doc/#{File.basename(_file)}" # TODO Add instructions for users to update the config file
3
+ namespace :rapi_doc do
4
+ desc "Generate the config files"
5
+ task :setup do
6
+ if File.directory?(config_dir)
7
+ puts "#{BASE_DIR}/#{File.basename(config_dir)} exists"
8
+ else
9
+ FileUtils.mkdir(config_dir)
10
+ end
11
+ %w(config_file layout_file).each do |type_file|
12
+ target_file = send(type_file, :target)
13
+ template_file = send(type_file, :template)
14
+ if File.exist? target_file
15
+ puts "#{BASE_DIR}/#{File.basename(target_file)} exists"
16
+ else
17
+ FileUtils.cp template_file, config_dir
18
+ puts "Generated #{BASE_DIR}/#{File.basename(template_file)}" # TODO Add instructions for users to update the config file
19
+ end
12
20
  end
13
21
  end
14
-
15
- # Generating documentations
16
- if yml
17
- resources = []
18
- yml.keys.each do |key|
19
- resources << RapiDoc::ResourceDoc.new(key, yml[key]["location"], yml[key]["controller_name"])
22
+ desc "Generate the API Documentation"
23
+ task :generate do
24
+ begin
25
+ yml = YAML::load(File.open(config_file(:target)))
26
+ rescue
27
+ puts "It seems that you don't have the config files yet. Please run rake rapi_doc:setup"
20
28
  end
21
29
 
22
- # generate the apidoc
23
- RapiDoc::RAPIDoc.new(resources)
30
+ # Generating documentations
31
+ if yml
32
+ resources = []
33
+ yml.keys.each do |key|
34
+ resources << RapiDoc::ResourceDoc.new(key, yml[key]["location"], yml[key]["controller_name"])
35
+ end
36
+
37
+ # generate the apidoc
38
+ RapiDoc::RAPIDoc.new(resources)
39
+ end
24
40
  end
25
41
  end
26
-
@@ -1,4 +1,5 @@
1
1
  require 'method_doc'
2
+ require 'doc_parser'
2
3
 
3
4
  module RapiDoc
4
5
  # ResourceDoc holds the information a resource contains. It parses the class header and also the
@@ -23,6 +24,7 @@ module RapiDoc
23
24
 
24
25
  # returns the location of the controller that is to be parsed
25
26
  def controller_location
27
+ # @resource_location
26
28
  "#{::Rails.root.to_s}/app/controllers/#{controller_name}"
27
29
  end
28
30
 
@@ -32,63 +34,40 @@ module RapiDoc
32
34
 
33
35
  # parse the controller
34
36
  def parse_apidoc!
35
- current_api_block = nil
36
- current_scope = :none
37
- block_holder = []
38
- lineno = 0
39
- inclass = false
37
+ line_no = 0
40
38
 
39
+ parser = DocParser.new
41
40
  File.open(controller_location).each do |line|
42
- if line =~ /=begin apidoc/
43
- current_scope = !inclass ? :class : :function
44
- current_api_block = MethodDoc.new(current_scope)
45
- elsif line =~ /=end/
46
- if current_api_block.nil?
47
- puts "#{controller_location}:#{lineno} - No starttag for =end found"
41
+ case
42
+ when line =~ /=begin apidoc/
43
+ parser.start
44
+ when line =~ /=end/
45
+ if parser.current_api_block.nil?
46
+ puts "#{controller_location}:#{line_no} - No starttag for '=end' found"
48
47
  exit
49
- elsif current_api_block.scope == :class
50
- @class_block = current_api_block
51
- elsif current_api_block.scope == :function
52
- @function_blocks << current_api_block
53
- end
54
- current_api_block = nil
55
- current_scope = :none
56
- elsif line =~ /class/
57
- inclass = true
58
- elsif line =~ /::response-end::/
59
- current_scope = :function
60
- elsif line =~ /::request-end::/
61
- current_scope = :function
62
- elsif current_scope == :response
63
- current_api_block.response += "#{line}"
64
- elsif current_scope == :request
65
- current_api_block.request += "#{line}"
66
- elsif current_scope == :class || current_scope == :function # check if we are looking at a api block
67
- # strip the # on the line
68
- #line = line[1..line.length].lstrip.rstrip
69
- # check if we are dealing with a variable
70
- # something in the format: # varname:: sometext
71
- if result = /(\w+)\:\:\s*(.+)/.match(line)
72
- if result[1] == "response" || result[1] == "request"
73
- puts "="*30
74
- puts "found response"
75
- puts "="*30; puts ""
76
- puts line
77
- current_scope = result[1].to_sym
78
- else
79
- current_api_block.add_variable(result[1], result[2])
80
- end
81
48
  else
82
- # add line to block
83
- current_api_block.content << line
49
+ case parser.current_scope
50
+ when :class
51
+ @class_block = parser.current_api_block
52
+ when :function
53
+ @function_blocks << parser.current_api_block
54
+ end
55
+ parser.reset_current_scope_and_api_block
84
56
  end
57
+ when line =~ /class/
58
+ parser.in_class = true
59
+ when line =~ /::response-end::/, line =~ /::request-end::/, line =~ /::output-end::/
60
+ parser.current_scope = :function
61
+ else
62
+ parser.parse(line)
85
63
  end
86
- lineno += 1
64
+
65
+ line_no += 1
87
66
  end
88
-
67
+
89
68
  puts "Generated #{name}.html"
90
69
  end
91
-
70
+
92
71
  def generate_view!(resources, temp_dir)
93
72
  @resources = resources
94
73
  @header_code = get_parsed_header unless @class_block.nil?
@@ -113,5 +92,6 @@ module RapiDoc
113
92
  File.open(File.join(File.dirname(__FILE__), '..', 'templates', '_resource_method.html.erb')).each { |line| template << line }
114
93
  return ERB.new(template).result(method_block.get_binding)
115
94
  end
95
+
116
96
  end
117
97
  end
@@ -0,0 +1,172 @@
1
+ require 'spec_helper'
2
+
3
+ describe RapiDoc::DocParser do
4
+ before do
5
+ @parser = RapiDoc::DocParser.new
6
+ end
7
+
8
+ describe "#methods" do
9
+ describe "strip_line" do
10
+ it "should strip '#' correctly" do
11
+ line = '# random string'
12
+ @parser.strip_line(line).should eq(' random string')
13
+ end
14
+ it "should strip only one '#'" do
15
+ line = '## random string'
16
+ @parser.strip_line(line).should_not eq(' random string')
17
+ @parser.strip_line(line).should eq('# random string')
18
+ end
19
+ end
20
+
21
+ describe "start" do
22
+ it 'should by default generate MethodDoc with scope :class' do
23
+ method_doc = RapiDoc::MethodDoc.new(:class)
24
+ @parser.start
25
+ @parser.current_scope.should eq(method_doc.scope)
26
+ end
27
+
28
+ it 'should generate MethodDoc object with scope :function if in class' do
29
+ method_doc = RapiDoc::MethodDoc.new(:function)
30
+ @parser.in_class = true
31
+ @parser.start
32
+ @parser.current_scope.should eq(method_doc.scope)
33
+ end
34
+
35
+ it 'should generate MethodDoc object with scope :class if not in class' do
36
+ method_doc = RapiDoc::MethodDoc.new(:class)
37
+ @parser.in_class = false
38
+ @parser.start
39
+ @parser.current_scope.should eq(method_doc.scope)
40
+ end
41
+ end
42
+
43
+ describe "when it gets started" do
44
+ before do
45
+ @parser.start
46
+ end
47
+
48
+ it 'reset_current_scope_and_api_block will set it to :none and nil respectively' do
49
+ @parser.reset_current_scope_and_api_block
50
+ @parser.current_api_block.should be(nil)
51
+ @parser.current_scope.should be(:none)
52
+ end
53
+
54
+ describe 'parse' do
55
+ before do
56
+ @api_block = @parser.current_api_block
57
+ @line = "#output:: xml"
58
+ end
59
+
60
+ describe 'with scope :response' do
61
+ before do
62
+ @parser.current_scope = :response
63
+ @api_block.response = "some responses"
64
+ @current_response = @api_block.response
65
+ end
66
+
67
+ it 'should append the existing response on the current_api_block' do
68
+ @parser.parse(@line)
69
+ @api_block.response.should eq(@current_response + @parser.strip_line(@line))
70
+ end
71
+ end
72
+
73
+ describe 'with scope :request' do
74
+ before do
75
+ @parser.current_scope = :request
76
+ @api_block.request = "some requests"
77
+ @current_request = @api_block.request
78
+ end
79
+
80
+ it 'should append the existing request on the current_api_block' do
81
+ @parser.parse(@line)
82
+ @api_block.request.should eq(@current_request + @parser.strip_line(@line))
83
+ end
84
+ end
85
+
86
+ describe 'with scope :output' do
87
+ before do
88
+ @parser.current_scope = :output
89
+ @current_content = 'some output content'
90
+ @api_block.outputs = [{ext: @current_content}]
91
+ end
92
+
93
+ it 'should append the existing content of the last output type' do
94
+ @parser.parse(@line)
95
+ @api_block.outputs.last[:ext].should eq(@current_content + @parser.strip_line(@line))
96
+ end
97
+ end
98
+
99
+ describe 'with scope :class' do
100
+ describe 'when the line matches /(\w+)\:\:\s*(.+)/ regex' do
101
+ before do
102
+ @previous_scope = @parser.current_scope
103
+ @regex = /(\w+)\:\:\s*(.+)/
104
+ end
105
+
106
+ it 'should update the current_scope' do
107
+ @parser.parse(@line)
108
+ @parser.current_scope.should_not eq(@previous_scope)
109
+ end
110
+
111
+ it "should update the current_scope if the captured string is one of 'response', 'request' or 'output'" do
112
+ %w(response request output).all? do |type|
113
+ line = "##{type}:: something"
114
+ @parser.parse(line)
115
+ # since we need to reset the scope back to :function, we need to
116
+ # save the spec result and then put it at the end for all? method
117
+ result = @parser.current_scope.should eq(type.to_sym)
118
+ @parser.current_scope = :function
119
+ result
120
+ end
121
+ end
122
+
123
+ describe "when the captured string is 'output'" do
124
+ it "should add a new output to the current api block" do
125
+ expect{
126
+ @parser.parse(@line)
127
+ }.to change {
128
+ @api_block.outputs.count
129
+ }.by(1)
130
+ end
131
+
132
+ it "the new output should be a hash with a key named the output type " do
133
+ @parser.parse(@line)
134
+ result = @regex.match(@line)
135
+ the_output = eval("{#{result[2]}: ''}")
136
+ @api_block.outputs.last.should eq(the_output)
137
+ end
138
+ end
139
+
140
+ describe "when the captured string is other than any of 'response', 'request' or 'output'" do
141
+ it "should add a new instance variable to the current api block" do
142
+ @line = "#anystring:: any random content"
143
+ @parser.parse(@line)
144
+ @api_block.send('anystring').should eq('any random content')
145
+ end
146
+
147
+ describe "when the captured string is 'param'" do
148
+ before do
149
+ @line = "#param:: page:int - the page, default is 1"
150
+ end
151
+
152
+ it "should add a new variable to the current api block" do
153
+ expect {
154
+ @parser.parse(@line)
155
+ }.to change {
156
+ @api_block.variables.count
157
+ }.by(1)
158
+ end
159
+
160
+ it "the new variable's value should be included in current api block's variables attribute" do
161
+ @parser.parse(@line)
162
+ result = @regex.match(@line)
163
+ @api_block.variables.include?(result[2]).should be_true
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end # describe 'parse'
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,108 @@
1
+ require 'spec_helper'
2
+
3
+ describe RapiDoc::MethodDoc do
4
+ before do
5
+ @method_doc = RapiDoc::MethodDoc.new('a_type')
6
+ end
7
+
8
+ describe "#methods" do
9
+ describe 'add_variable' do
10
+ before do
11
+ @name = 'any_name'
12
+ @value = 'a_value'
13
+ end
14
+
15
+ it "should add a new attribute to the object with the same name" do
16
+ @method_doc.add_variable(@name, @value)
17
+ @method_doc.send(@name).should eq(@value)
18
+ end
19
+
20
+ it "the value should not be added to 'variables' attribute when adding with named other than 'param' " do
21
+ expect {
22
+ @method_doc.add_variable(@name, @value)
23
+ }.to change {
24
+ @method_doc.variables.count
25
+ }.by(0)
26
+ end
27
+
28
+ describe "adding with named 'param'" do
29
+ before do
30
+ @name = 'param'
31
+ end
32
+
33
+ it "the value should be added to 'variables' attribute" do
34
+ expect {
35
+ @method_doc.add_variable(@name, @value)
36
+ }.to change {
37
+ @method_doc.variables.count
38
+ }.by(1)
39
+ end
40
+
41
+ it "the added value should be at the last entry of 'variables' attribute" do
42
+ @method_doc.add_variable(@name, @value)
43
+ @method_doc.variables.last.should eq(@value)
44
+ end
45
+ end
46
+ end
47
+
48
+ describe 'add_output' do
49
+ before do
50
+ @name = 'any_name'
51
+ @value = 'a_value'
52
+ end
53
+
54
+ it "should not be added to the 'outputs' attribute when adding with named other than 'output'" do
55
+ expect {
56
+ @method_doc.add_output(@name, @value)
57
+ }.to change {
58
+ @method_doc.outputs.count
59
+ }.by(0)
60
+ end
61
+
62
+ describe "adding with named 'output'" do
63
+ before do
64
+ @name = 'output'
65
+ end
66
+
67
+ it "should add an output item to the 'outputs' attribute" do
68
+ expect {
69
+ @method_doc.add_output(@name, @value)
70
+ }.to change {
71
+ @method_doc.outputs.count
72
+ }.by(1)
73
+ end
74
+
75
+ it "the added item should be at the last entry of 'outputs' attribute" do
76
+ @method_doc.add_output(@name, @value)
77
+ new_hash = eval("{#{@value}: ''}")
78
+ @method_doc.outputs.last.should eq(new_hash)
79
+ end
80
+
81
+ it "the new output item should be a hash with key named the 'value' parameter" do
82
+ @method_doc.add_output(@name, @value)
83
+ @method_doc.outputs.last.keys.include?(@value.to_sym).should be_true
84
+ end
85
+ end
86
+ end
87
+
88
+ describe 'append_output' do
89
+ before do
90
+ @current_format_content = "any string"
91
+ @last_hash = {format: @current_format_content}
92
+ @method_doc.outputs << @last_hash
93
+ end
94
+
95
+ it 'should append the existing format content on the outputs' do
96
+ value = "some string"
97
+ @method_doc.append_output(value)
98
+ @method_doc.outputs.last[:format].should eq(@current_format_content + value)
99
+ end
100
+
101
+ it 'the appended value should be html-escaped' do
102
+ value = "<a>tag</a>"
103
+ @method_doc.append_output(value)
104
+ @method_doc.outputs.last[:format].should eq(@current_format_content + ERB::Util.html_escape(value))
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,5 @@
1
+ require 'erb'
2
+ require 'fileutils'
3
+ require 'doc_util'
4
+ require 'resource_doc'
5
+ require 'rapi_config'
@@ -26,12 +26,21 @@
26
26
  </ul>
27
27
  <% end %>
28
28
 
29
- <% if @output %>
30
- <strong>Output:</strong>
31
- <div class="code">
32
- <%= @output %>
33
- </div>
34
- <br />
29
+ <% unless @outputs.empty? %>
30
+ <ul class="tabs">
31
+ <% @outputs.each do |output| %>
32
+ <li class="<%= (output == @outputs.first)? 'active' : '' %>"><a href="#<%= output.keys.first %>"><%= output.keys.first %></a></li>
33
+ <% end %>
34
+ </ul>
35
+ <div class="pill-content">
36
+ <% @outputs.each do |output| %>
37
+ <% output_format = output.keys.first %>
38
+ <div class="<%= (output == @outputs.first)? 'active' : '' %>" id="<%= output_format %>">
39
+ <pre class="prettyprint" ><%= output[output_format] %></pre>
40
+ </div>
41
+ <% end %>
42
+ </div>
43
+ <br />
35
44
  <% end %>
36
45
 
37
46
  <% unless @request.blank? %>
metadata CHANGED
@@ -2,52 +2,64 @@
2
2
  name: rapi_doc
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Husein Choroomi
9
+ - Adinda Praditya
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
13
 
13
- date: 2011-11-02 00:00:00 Z
14
+ date: 2011-12-09 00:00:00 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
- name: shoulda
17
+ name: activesupport
17
18
  requirement: &id001 !ruby/object:Gem::Requirement
18
19
  none: false
19
20
  requirements:
20
21
  - - ">="
21
22
  - !ruby/object:Gem::Version
22
- version: "0"
23
- type: :development
23
+ version: "2.1"
24
+ type: :runtime
24
25
  prerelease: false
25
26
  version_requirements: *id001
26
27
  - !ruby/object:Gem::Dependency
27
- name: bundler
28
+ name: rspec
28
29
  requirement: &id002 !ruby/object:Gem::Requirement
29
30
  none: false
30
31
  requirements:
31
32
  - - ~>
32
33
  - !ruby/object:Gem::Version
33
- version: 1.0.0
34
+ version: 2.7.0
34
35
  type: :development
35
36
  prerelease: false
36
37
  version_requirements: *id002
37
38
  - !ruby/object:Gem::Dependency
38
- name: jeweler
39
+ name: bundler
39
40
  requirement: &id003 !ruby/object:Gem::Requirement
40
41
  none: false
41
42
  requirements:
42
43
  - - ~>
43
44
  - !ruby/object:Gem::Version
44
- version: 1.6.4
45
+ version: 1.0.0
45
46
  type: :development
46
47
  prerelease: false
47
48
  version_requirements: *id003
48
49
  - !ruby/object:Gem::Dependency
49
- name: rcov
50
+ name: jeweler
50
51
  requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 1.6.4
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rcov
62
+ requirement: &id005 !ruby/object:Gem::Requirement
51
63
  none: false
52
64
  requirements:
53
65
  - - ">="
@@ -55,7 +67,7 @@ dependencies:
55
67
  version: "0"
56
68
  type: :development
57
69
  prerelease: false
58
- version_requirements: *id004
70
+ version_requirements: *id005
59
71
  description: Rails API Doc Generator
60
72
  email: hchoroomi@gmail.com
61
73
  executables: []
@@ -75,6 +87,7 @@ files:
75
87
  - VERSION
76
88
  - init.rb
77
89
  - install.rb
90
+ - lib/doc_parser.rb
78
91
  - lib/doc_util.rb
79
92
  - lib/method_doc.rb
80
93
  - lib/rapi_config.rb
@@ -82,12 +95,13 @@ files:
82
95
  - lib/rapi_doc/railtie.rb
83
96
  - lib/rapi_doc/tasks/rapi_doc_tasks.rake
84
97
  - lib/resource_doc.rb
98
+ - spec/doc_parser_spec.rb
99
+ - spec/method_doc_spec.rb
100
+ - spec/spec_helper.rb
85
101
  - templates/_resource_header.html.erb
86
102
  - templates/_resource_method.html.erb
87
103
  - templates/config.yml
88
104
  - templates/layout.html.erb
89
- - test/rapi_doc_test.rb
90
- - test/test_helper.rb
91
105
  - uninstall.rb
92
106
  homepage: http://github.com/hchoroomi/rapi_doc
93
107
  licenses:
@@ -102,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
116
  requirements:
103
117
  - - ">="
104
118
  - !ruby/object:Gem::Version
105
- hash: -1142143920796928786
119
+ hash: -2515806695583733167
106
120
  segments:
107
121
  - 0
108
122
  version: "0"
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RapiDocTest < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
@@ -1,3 +0,0 @@
1
- require 'rubygems'
2
- require 'active_support'
3
- require 'active_support/test_case'