rapidoc 0.0.6 → 0.0.7
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/.gitignore +2 -0
- data/.rspec +1 -0
- data/README.rdoc +11 -2
- data/lib/rapidoc.rb +23 -8
- data/lib/rapidoc/action_doc.rb +8 -6
- data/lib/rapidoc/config.rb +3 -3
- data/lib/rapidoc/http_response.rb +3 -1
- data/lib/rapidoc/resource_doc.rb +2 -2
- data/lib/rapidoc/resources_extractor.rb +1 -1
- data/lib/rapidoc/templates/action.html.hbs +34 -11
- data/lib/rapidoc/templates/index.html.hbs +4 -3
- data/lib/rapidoc/templates_generator.rb +8 -2
- data/lib/rapidoc/version.rb +1 -1
- data/lib/rapidoc/yaml_parser.rb +4 -4
- data/lib/tasks/rapidoc.rake +15 -6
- data/rapidoc.gemspec +6 -5
- data/spec/dummy/config/application.rb +0 -1
- data/spec/dummy/config/environments/development.rb +68 -25
- data/spec/dummy/config/environments/production.rb +41 -28
- data/spec/dummy/config/environments/test.rb +67 -24
- data/spec/dummy/config/routes.rb +2 -2
- data/spec/features/action_spec.rb +9 -8
- data/spec/features/index_spec.rb +3 -3
- data/spec/lib/action_doc_spec.rb +8 -6
- data/spec/lib/config_spec.rb +11 -7
- data/spec/lib/controller_extractor_spec.rb +4 -1
- data/spec/lib/http_response_spec.rb +1 -1
- data/spec/lib/param_errors_spec.rb +5 -0
- data/spec/lib/rake_spec.rb +74 -13
- data/spec/lib/rapidoc_spec.rb +31 -36
- data/spec/lib/resource_doc_spec.rb +5 -1
- data/spec/lib/resources_extractor_spec.rb +6 -0
- data/spec/lib/templates_generator_spec.rb +5 -4
- metadata +25 -43
@@ -51,7 +51,6 @@ module Dummy
|
|
51
51
|
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
52
52
|
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
53
53
|
# parameters by using an attr_accessible or attr_protected declaration.
|
54
|
-
config.active_record.whitelist_attributes = true
|
55
54
|
|
56
55
|
# Enable the asset pipeline
|
57
56
|
config.assets.enabled = true
|
@@ -1,37 +1,80 @@
|
|
1
1
|
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
|
-
#
|
5
|
-
|
6
|
-
# since you don't have to restart the web server when you make code changes.
|
7
|
-
config.cache_classes = false
|
4
|
+
# Code is not reloaded between requests.
|
5
|
+
config.cache_classes = true
|
8
6
|
|
9
|
-
#
|
10
|
-
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both thread web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
11
12
|
|
12
|
-
#
|
13
|
-
config.consider_all_requests_local =
|
14
|
-
config.action_controller.perform_caching =
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
14
|
+
config.consider_all_requests_local = false
|
15
|
+
config.action_controller.perform_caching = true
|
15
16
|
|
16
|
-
#
|
17
|
-
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
20
|
+
# config.action_dispatch.rack_cache = true
|
18
21
|
|
19
|
-
#
|
20
|
-
config.
|
22
|
+
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
+
config.serve_static_assets = true
|
21
24
|
|
22
|
-
#
|
23
|
-
config.
|
25
|
+
# Compress JavaScripts and CSS.
|
26
|
+
config.assets.js_compressor = :uglifier
|
27
|
+
# config.assets.css_compressor = :sass
|
24
28
|
|
25
|
-
#
|
26
|
-
config.
|
29
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
30
|
+
config.assets.compile = false
|
27
31
|
|
28
|
-
#
|
29
|
-
|
30
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
32
|
+
# Generate digests for assets URLs.
|
33
|
+
config.assets.digest = true
|
31
34
|
|
32
|
-
#
|
33
|
-
config.assets.
|
35
|
+
# Version of your assets, change this if you want to expire all your assets.
|
36
|
+
config.assets.version = '1.0'
|
34
37
|
|
35
|
-
#
|
36
|
-
config.
|
38
|
+
# Specifies the header that your server uses for sending files.
|
39
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
40
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
41
|
+
|
42
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
43
|
+
# config.force_ssl = true
|
44
|
+
|
45
|
+
# Set to :debug to see everything in the log.
|
46
|
+
config.log_level = :info
|
47
|
+
|
48
|
+
# Prepend all log lines with the following tags.
|
49
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
50
|
+
|
51
|
+
# Use a different logger for distributed setups.
|
52
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
53
|
+
|
54
|
+
# Use a different cache store in production.
|
55
|
+
# config.cache_store = :mem_cache_store
|
56
|
+
|
57
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
58
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
59
|
+
|
60
|
+
# Precompile additional assets.
|
61
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
62
|
+
# config.assets.precompile += %w( search.js )
|
63
|
+
|
64
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
65
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
66
|
+
# config.action_mailer.raise_delivery_errors = false
|
67
|
+
|
68
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
69
|
+
# the I18n.default_locale when a translation can not be found).
|
70
|
+
config.i18n.fallbacks = true
|
71
|
+
|
72
|
+
# Send deprecation notices to registered listeners.
|
73
|
+
config.active_support.deprecation = :notify
|
74
|
+
|
75
|
+
# Disable automatic flushing of the log to improve performance.
|
76
|
+
# config.autoflush_log = false
|
77
|
+
|
78
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
79
|
+
config.log_formatter = ::Logger::Formatter.new
|
37
80
|
end
|
@@ -1,67 +1,80 @@
|
|
1
1
|
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
|
-
# Code is not reloaded between requests
|
4
|
+
# Code is not reloaded between requests.
|
5
5
|
config.cache_classes = true
|
6
6
|
|
7
|
-
#
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both thread web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
8
14
|
config.consider_all_requests_local = false
|
9
15
|
config.action_controller.perform_caching = true
|
10
16
|
|
11
|
-
#
|
12
|
-
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
20
|
+
# config.action_dispatch.rack_cache = true
|
21
|
+
|
22
|
+
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
+
config.serve_static_assets = true
|
13
24
|
|
14
|
-
# Compress JavaScripts and CSS
|
15
|
-
config.assets.
|
25
|
+
# Compress JavaScripts and CSS.
|
26
|
+
config.assets.js_compressor = :uglifier
|
27
|
+
# config.assets.css_compressor = :sass
|
16
28
|
|
17
|
-
#
|
29
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
18
30
|
config.assets.compile = false
|
19
31
|
|
20
|
-
# Generate digests for assets URLs
|
32
|
+
# Generate digests for assets URLs.
|
21
33
|
config.assets.digest = true
|
22
34
|
|
23
|
-
#
|
24
|
-
|
35
|
+
# Version of your assets, change this if you want to expire all your assets.
|
36
|
+
config.assets.version = '1.0'
|
25
37
|
|
26
|
-
# Specifies the header that your server uses for sending files
|
38
|
+
# Specifies the header that your server uses for sending files.
|
27
39
|
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
28
40
|
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
29
41
|
|
30
42
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
31
43
|
# config.force_ssl = true
|
32
44
|
|
33
|
-
#
|
34
|
-
|
45
|
+
# Set to :debug to see everything in the log.
|
46
|
+
config.log_level = :info
|
35
47
|
|
36
|
-
# Prepend all log lines with the following tags
|
48
|
+
# Prepend all log lines with the following tags.
|
37
49
|
# config.log_tags = [ :subdomain, :uuid ]
|
38
50
|
|
39
|
-
# Use a different logger for distributed setups
|
51
|
+
# Use a different logger for distributed setups.
|
40
52
|
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
41
53
|
|
42
|
-
# Use a different cache store in production
|
54
|
+
# Use a different cache store in production.
|
43
55
|
# config.cache_store = :mem_cache_store
|
44
56
|
|
45
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
57
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
46
58
|
# config.action_controller.asset_host = "http://assets.example.com"
|
47
59
|
|
48
|
-
# Precompile additional assets
|
60
|
+
# Precompile additional assets.
|
61
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
49
62
|
# config.assets.precompile += %w( search.js )
|
50
63
|
|
51
|
-
#
|
64
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
65
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
52
66
|
# config.action_mailer.raise_delivery_errors = false
|
53
67
|
|
54
|
-
# Enable threaded mode
|
55
|
-
# config.threadsafe!
|
56
|
-
|
57
68
|
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
58
|
-
# the I18n.default_locale when a translation can not be found)
|
69
|
+
# the I18n.default_locale when a translation can not be found).
|
59
70
|
config.i18n.fallbacks = true
|
60
71
|
|
61
|
-
# Send deprecation notices to registered listeners
|
72
|
+
# Send deprecation notices to registered listeners.
|
62
73
|
config.active_support.deprecation = :notify
|
63
74
|
|
64
|
-
#
|
65
|
-
#
|
66
|
-
|
75
|
+
# Disable automatic flushing of the log to improve performance.
|
76
|
+
# config.autoflush_log = false
|
77
|
+
|
78
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
79
|
+
config.log_formatter = ::Logger::Formatter.new
|
67
80
|
end
|
@@ -1,37 +1,80 @@
|
|
1
1
|
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
|
-
#
|
5
|
-
# test suite. You never need to work with it otherwise. Remember that
|
6
|
-
# your test database is "scratch space" for the test suite and is wiped
|
7
|
-
# and recreated between test runs. Don't rely on the data there!
|
4
|
+
# Code is not reloaded between requests.
|
8
5
|
config.cache_classes = true
|
9
6
|
|
10
|
-
#
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both thread web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
14
|
+
config.consider_all_requests_local = false
|
15
|
+
config.action_controller.perform_caching = true
|
16
|
+
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
20
|
+
# config.action_dispatch.rack_cache = true
|
21
|
+
|
22
|
+
# Disable Rails's static asset server (Apache or nginx will already do this).
|
11
23
|
config.serve_static_assets = true
|
12
|
-
config.static_cache_control = "public, max-age=3600"
|
13
24
|
|
14
|
-
#
|
15
|
-
config.
|
25
|
+
# Compress JavaScripts and CSS.
|
26
|
+
config.assets.js_compressor = :uglifier
|
27
|
+
# config.assets.css_compressor = :sass
|
28
|
+
|
29
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
30
|
+
config.assets.compile = false
|
31
|
+
|
32
|
+
# Generate digests for assets URLs.
|
33
|
+
config.assets.digest = true
|
34
|
+
|
35
|
+
# Version of your assets, change this if you want to expire all your assets.
|
36
|
+
config.assets.version = '1.0'
|
37
|
+
|
38
|
+
# Specifies the header that your server uses for sending files.
|
39
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
40
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
41
|
+
|
42
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
43
|
+
# config.force_ssl = true
|
44
|
+
|
45
|
+
# Set to :debug to see everything in the log.
|
46
|
+
config.log_level = :info
|
47
|
+
|
48
|
+
# Prepend all log lines with the following tags.
|
49
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
50
|
+
|
51
|
+
# Use a different logger for distributed setups.
|
52
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
53
|
+
|
54
|
+
# Use a different cache store in production.
|
55
|
+
# config.cache_store = :mem_cache_store
|
56
|
+
|
57
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
58
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
16
59
|
|
17
|
-
#
|
18
|
-
|
19
|
-
config.
|
60
|
+
# Precompile additional assets.
|
61
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
62
|
+
# config.assets.precompile += %w( search.js )
|
20
63
|
|
21
|
-
#
|
22
|
-
|
64
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
65
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
66
|
+
# config.action_mailer.raise_delivery_errors = false
|
23
67
|
|
24
|
-
#
|
25
|
-
|
68
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
69
|
+
# the I18n.default_locale when a translation can not be found).
|
70
|
+
config.i18n.fallbacks = true
|
26
71
|
|
27
|
-
#
|
28
|
-
|
29
|
-
# ActionMailer::Base.deliveries array.
|
30
|
-
config.action_mailer.delivery_method = :test
|
72
|
+
# Send deprecation notices to registered listeners.
|
73
|
+
config.active_support.deprecation = :notify
|
31
74
|
|
32
|
-
#
|
33
|
-
config.
|
75
|
+
# Disable automatic flushing of the log to improve performance.
|
76
|
+
# config.autoflush_log = false
|
34
77
|
|
35
|
-
#
|
36
|
-
config.
|
78
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
79
|
+
config.log_formatter = ::Logger::Formatter.new
|
37
80
|
end
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Dummy::Application.routes.draw do
|
2
|
-
match 'testing', :to => 'testing#redirect', :constraints => { :id => /[A-Z]\d{5}/ }
|
3
|
-
match '*tests', :controller => 'testing', :action => 'index'
|
2
|
+
match 'testing', :to => 'testing#redirect', :via => :get, :constraints => { :id => /[A-Z]\d{5}/ }
|
3
|
+
match '*tests', :controller => 'testing', :action => 'index', :via => :get
|
4
4
|
|
5
5
|
resources :users, :only => [ :index, :show, :create ] do
|
6
6
|
resources :albums, :only => [ :index, :show, :create, :update, :destroy ] do
|
@@ -14,9 +14,10 @@ describe "Action page" do
|
|
14
14
|
reset_structure
|
15
15
|
|
16
16
|
@json_info = { "user" => { "name" => "Check", "apellido" => "Me" } }
|
17
|
-
request_file = examples_dir "
|
18
|
-
response_file = examples_dir "
|
17
|
+
request_file = examples_dir "users/create_request.json"
|
18
|
+
response_file = examples_dir "users/create_response.json"
|
19
19
|
|
20
|
+
create_folders_for_files([response_file, request_file])
|
20
21
|
File.open( request_file, 'w') { |file| file.write @json_info.to_json }
|
21
22
|
File.open( response_file, 'w') { |file| file.write @json_info.to_json }
|
22
23
|
|
@@ -28,13 +29,13 @@ describe "Action page" do
|
|
28
29
|
end
|
29
30
|
|
30
31
|
after :all do
|
31
|
-
|
32
|
+
remove_structure
|
32
33
|
remove_examples
|
33
34
|
end
|
34
35
|
|
35
|
-
context "when visit
|
36
|
+
context "when visit users/index.html page" do
|
36
37
|
before do
|
37
|
-
visit '/
|
38
|
+
visit '/public/docs/actions/users/index.html'
|
38
39
|
end
|
39
40
|
|
40
41
|
context "when check action page" do
|
@@ -95,7 +96,7 @@ describe "Action page" do
|
|
95
96
|
|
96
97
|
it "have table with one row for each parameter" do
|
97
98
|
# +1 becouse rapidoc add empty row at the end
|
98
|
-
page.should have_css( "table#table-params tr", :count => @params_info.size +
|
99
|
+
page.should have_css( "table#table-params tr", :count => @params_info.size + 2 )
|
99
100
|
end
|
100
101
|
|
101
102
|
it "have a row with parameter name" do
|
@@ -138,9 +139,9 @@ describe "Action page" do
|
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|
141
|
-
context "when visit
|
142
|
+
context "when visit users/create.html page" do
|
142
143
|
before do
|
143
|
-
visit '/
|
144
|
+
visit '/public/docs/actions/users/create.html'
|
144
145
|
end
|
145
146
|
|
146
147
|
context "when check tab 'Params'" do
|
data/spec/features/index_spec.rb
CHANGED
@@ -17,11 +17,11 @@ describe "Index page" do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
before do
|
20
|
-
visit '/
|
20
|
+
visit '/public/docs/index.html'
|
21
21
|
end
|
22
22
|
|
23
23
|
after :all do
|
24
|
-
|
24
|
+
remove_structure
|
25
25
|
end
|
26
26
|
|
27
27
|
context "when check global page" do
|
@@ -46,7 +46,7 @@ describe "Index page" do
|
|
46
46
|
resource.actions_doc.each do |action|
|
47
47
|
action.urls.each do |url|
|
48
48
|
if action.has_controller_info
|
49
|
-
page.should have_link( url, href: "actions/" + action.file + ".html" )
|
49
|
+
page.should have_link( url, href: "actions/" + action.file.gsub('_','/') + ".html" )
|
50
50
|
else
|
51
51
|
page.should have_text( url )
|
52
52
|
end
|
data/spec/lib/action_doc_spec.rb
CHANGED
@@ -6,15 +6,16 @@ describe ActionDoc do
|
|
6
6
|
|
7
7
|
before :all do
|
8
8
|
@json_info = { "user" => { "name" => "Check", "apellido" => "Me" } }
|
9
|
-
response_file = examples_dir "
|
10
|
-
answer_file = examples_dir "
|
9
|
+
response_file = examples_dir "users/create_response.json"
|
10
|
+
answer_file = examples_dir "users/create_request.json"
|
11
11
|
|
12
12
|
reset_structure
|
13
|
+
create_folders_for_files([response_file, answer_file])
|
13
14
|
File.open( response_file, 'w') { |file| file.write @json_info.to_json }
|
14
15
|
File.open( answer_file, 'w') { |file| file.write @json_info.to_json }
|
15
16
|
|
16
|
-
@info = {
|
17
|
-
:resource=>"users",
|
17
|
+
@info = {
|
18
|
+
:resource=>"users",
|
18
19
|
:action=>"create",
|
19
20
|
:method=>"POST",
|
20
21
|
:urls=>["/users(.:format)"]
|
@@ -26,6 +27,7 @@ describe ActionDoc do
|
|
26
27
|
|
27
28
|
after :all do
|
28
29
|
remove_examples
|
30
|
+
remove_structure
|
29
31
|
end
|
30
32
|
|
31
33
|
context "when initialize ActionDoc" do
|
@@ -63,7 +65,7 @@ describe ActionDoc do
|
|
63
65
|
end
|
64
66
|
|
65
67
|
it "set correct file" do
|
66
|
-
@action_doc.file.should == @info[:resource].to_s + "
|
68
|
+
@action_doc.file.should == @info[:resource].to_s + "/" + @info[:action].to_s
|
67
69
|
end
|
68
70
|
|
69
71
|
it "set correct example_req" do
|
@@ -175,7 +177,7 @@ describe ActionDoc do
|
|
175
177
|
|
176
178
|
context "when use config messages and descriptions" do
|
177
179
|
before :all do
|
178
|
-
File.open( config_file_path, 'w') do |file|
|
180
|
+
File.open( config_file_path, 'w') do |file|
|
179
181
|
file.write "default_errors: true\n"
|
180
182
|
file.write "errors:\n"
|
181
183
|
file.write " required:\n message: \"m1\"\n description: \"d1\"\n"
|