apipie-dsl 2.2.7 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/apipie_dsl_helper.rb +35 -9
- data/app/public/apipie_dsl/stylesheets/application.css +11 -0
- data/app/views/apipie_dsl/apipie_dsls/_index_class_prop.html.erb +1 -1
- data/app/views/apipie_dsl/apipie_dsls/_method.html.erb +2 -2
- data/app/views/apipie_dsl/apipie_dsls/_params.html.erb +2 -1
- data/app/views/apipie_dsl/apipie_dsls/_property.html.erb +2 -2
- data/app/views/apipie_dsl/apipie_dsls/_property_detail.html.erb +10 -0
- data/app/views/apipie_dsl/apipie_dsls/class.html.erb +1 -15
- data/app/views/apipie_dsl/apipie_dsls/custom_help.html.erb +1 -9
- data/app/views/apipie_dsl/apipie_dsls/index.html.erb +3 -16
- data/app/views/apipie_dsl/apipie_dsls/method.html.erb +1 -15
- data/app/views/apipie_dsl/apipie_dsls/plain.html.erb +10 -4
- data/app/views/apipie_dsl/apipie_dsls/static.html.erb +10 -4
- data/lib/apipie_dsl/application.rb +1 -1
- data/lib/apipie_dsl/class_description.rb +15 -14
- data/lib/apipie_dsl/dsl.rb +22 -17
- data/lib/apipie_dsl/errors.rb +4 -0
- data/lib/apipie_dsl/parameter_description.rb +0 -2
- data/lib/apipie_dsl/return_description.rb +0 -2
- data/lib/apipie_dsl/routing.rb +2 -0
- data/lib/apipie_dsl/tasks/apipie_dsl/cache.rake +23 -12
- data/lib/apipie_dsl/tasks_utils.rb +2 -2
- data/lib/apipie_dsl/utils.rb +1 -12
- data/lib/apipie_dsl/validator.rb +3 -3
- data/lib/apipie_dsl/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95dfead8f64abaa0afb0acb4c8af97c43a484d0486596a08049420baff6ba9a4
|
4
|
+
data.tar.gz: 5f454030f583bd23a2728693c6950c6c145223289448f1f6ae681c021cc0897f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0d8dccd8fdaa5bbd2c8cc1ef4a89cdda096fa000ace242518f5196a420cf7cc7e62f4790d3f9e6c1b7335bdc2dd65c5b6dbe5133fceb7b6477376d3bf95d640
|
7
|
+
data.tar.gz: c5a0a6ba9167b2bf13e117ca608d997689ab97eb76e422a69423dab1c8152c7e203594dde8d9d6216e661c4116a5d6f5f113ed95913b41b8d41cb6418f8f3232
|
@@ -12,17 +12,35 @@ module ApipieDslHelper
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def escaped_method_name(method,
|
16
|
-
|
15
|
+
def escaped_method_name(method, options = {})
|
16
|
+
options[:escaping] ||= ''
|
17
|
+
options[:pattern] ||= /[?]/
|
18
|
+
return method.gsub(options[:pattern], options[:escaping]) if method.is_a?(String)
|
19
|
+
end
|
20
|
+
|
21
|
+
def apipie_dsl_menu
|
22
|
+
content_tag(:ul, class: 'breadcrumb') do
|
23
|
+
content = dsl_sections.map do |section|
|
24
|
+
content_tag(:li, class: section == @section ? 'active' : '') do
|
25
|
+
link_to(_(section.titleize), @doc[:doc_url] + section_ext(section) + @doc[:link_extension])
|
26
|
+
end
|
27
|
+
end.join(' | ').html_safe
|
28
|
+
|
29
|
+
unless ApipieDSL.configuration.help_layout.nil?
|
30
|
+
content += content_tag(:li, class: "pull-right #{'active' if @section == 'help'}") do
|
31
|
+
link_to(_('Help'), @doc[:doc_url] + section_ext('help') + @doc[:link_extension])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
17
35
|
end
|
18
36
|
|
19
37
|
def apipie_dsl_example(source, output = nil)
|
20
38
|
text = content_tag(:p, _('Example input:')) +
|
21
|
-
content_tag(:pre, source)
|
39
|
+
content_tag(:pre, source, class: 'wiki')
|
22
40
|
|
23
41
|
if output.present?
|
24
42
|
text += content_tag(:p, _('Example output:')) +
|
25
|
-
content_tag(:pre, output)
|
43
|
+
content_tag(:pre, output, class: 'wiki')
|
26
44
|
end
|
27
45
|
|
28
46
|
text.html_safe
|
@@ -31,11 +49,11 @@ module ApipieDslHelper
|
|
31
49
|
def apipie_erb_wrap(content, mode: :loud, open_trim: false, close_trim: false)
|
32
50
|
case mode
|
33
51
|
when :loud
|
34
|
-
|
52
|
+
"<%= #{content} #{close_trim ? '-' : ''}%>"
|
35
53
|
when :comment
|
36
|
-
|
54
|
+
"<%# #{content} #{close_trim ? '-' : ''}%>"
|
37
55
|
else
|
38
|
-
"<%#{open_trim ? '-
|
56
|
+
"<%#{open_trim ? '-' : ''} #{content} #{close_trim ? '-' : ''}%>"
|
39
57
|
end
|
40
58
|
end
|
41
59
|
|
@@ -45,6 +63,10 @@ module ApipieDslHelper
|
|
45
63
|
'nil'
|
46
64
|
when ''
|
47
65
|
"\"\""
|
66
|
+
when Symbol
|
67
|
+
":#{default}"
|
68
|
+
when String
|
69
|
+
"\"#{default}\""
|
48
70
|
else
|
49
71
|
default
|
50
72
|
end
|
@@ -81,6 +103,9 @@ module ApipieDslHelper
|
|
81
103
|
# Try to convert to a constant in case of LazyValidator usage
|
82
104
|
# Will raise const missing exception in case of wrong usage of the method
|
83
105
|
if obj.is_a?(String)
|
106
|
+
ref = ApipieDSL.refs[version][ApipieDSL.get_class_name(obj)]
|
107
|
+
return "<a href='#{ref.doc_url(ref.sections.first)}#{link_extension}'>#{obj}</a>" if ref
|
108
|
+
|
84
109
|
obj = ApipieDSL.configuration.rails? ? obj.constantize : obj.split('::').reduce(::Module, :const_get)
|
85
110
|
end
|
86
111
|
return obj.to_s unless [::Module, ::Class, ::Array].include?(obj.class)
|
@@ -119,9 +144,10 @@ module ApipieDslHelper
|
|
119
144
|
end
|
120
145
|
|
121
146
|
def current_version(classes)
|
122
|
-
|
147
|
+
case classes
|
148
|
+
when Array
|
123
149
|
classes.first[:version]
|
124
|
-
|
150
|
+
when Hash
|
125
151
|
classes.values.first[:version]
|
126
152
|
else
|
127
153
|
raise ApipieDSL::Error, "Cannot find current version for #{classes}"
|
@@ -5,3 +5,14 @@ body {
|
|
5
5
|
.sidebar-nav {
|
6
6
|
padding: 9px 0;
|
7
7
|
}
|
8
|
+
|
9
|
+
pre:not(.prettyprint):not(.wiki) {
|
10
|
+
margin: 0 0 9px;
|
11
|
+
padding: 0;
|
12
|
+
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
13
|
+
font-size: 13px;
|
14
|
+
line-height: 18px;
|
15
|
+
color: #333333;
|
16
|
+
background-color: inherit;
|
17
|
+
border: none;
|
18
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<% if prop[:show] %>
|
2
2
|
<tr>
|
3
3
|
<td>
|
4
|
-
<a href='<%= doc_url %><%= link_extension %>#link-description-<%= escaped_method_name(prop[:name], '_') %>'>
|
4
|
+
<a href='<%= doc_url %><%= link_extension %>#link-description-<%= escaped_method_name(prop[:name], escaping: '_') %>'>
|
5
5
|
<%= prop[:name] %>
|
6
6
|
</a>
|
7
7
|
<% if prop[:deprecated] %>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<div>
|
9
9
|
<% (meth[:signature] || [method_signature(meth)]).each do |signature| %>
|
10
10
|
<h2>
|
11
|
-
<a href='#description-<%= escaped_method_name(meth[:name], '_') %>'
|
11
|
+
<a href='#description-<%= escaped_method_name(meth[:name], escaping: '_') %>'
|
12
12
|
class='accordion-toggle'
|
13
13
|
data-toggle='collapse'
|
14
14
|
data-parent='#meth-accordion'>
|
@@ -29,7 +29,7 @@
|
|
29
29
|
Also see <%= meth[:see].map { |s| link_to(s[:description] || s[:link], "#{s[:url]}#{link_extension}") }.to_sentence.html_safe %>.
|
30
30
|
<% end %>
|
31
31
|
|
32
|
-
<div id='description-<%= escaped_method_name(meth[:name], '_') %>' class='collapse accordion-body'>
|
32
|
+
<div id='description-<%= escaped_method_name(meth[:name], escaping: '_') %>' class='collapse accordion-body'>
|
33
33
|
<%= render partial: 'method_detail', locals: { method: meth, h_level: 3 } %>
|
34
34
|
</div>
|
35
35
|
</td>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<td>
|
5
5
|
<div>
|
6
6
|
<h2>
|
7
|
-
<a id='link-description-<%= escaped_method_name(prop[:name], '_') %>' href='#description-<%= escaped_method_name(prop[:name], '_') %>'
|
7
|
+
<a id='link-description-<%= escaped_method_name(prop[:name], escaping: '_', pattern: /[?!]/) %>' href='#description-<%= escaped_method_name(prop[:name], escaping: '_', pattern: /[?!]/) %>'
|
8
8
|
class='accordion-toggle'
|
9
9
|
data-toggle='collapse'
|
10
10
|
data-parent='#prop-accordion'>
|
@@ -15,7 +15,7 @@
|
|
15
15
|
</h2>
|
16
16
|
</div>
|
17
17
|
|
18
|
-
<div id='description-<%= escaped_method_name(prop[:name], '_') %>' class='collapse accordion-body'>
|
18
|
+
<div id='description-<%= escaped_method_name(prop[:name], escaping: '_', pattern: /[?!]/) %>' class='collapse accordion-body'>
|
19
19
|
<%= render partial: 'property_detail', locals: { property: prop, h_level: 3 } %>
|
20
20
|
</div>
|
21
21
|
</td>
|
@@ -3,6 +3,16 @@
|
|
3
3
|
<%= render(partial: 'metadata', locals: { meta: property[:metadata] }) %>
|
4
4
|
<% end %>
|
5
5
|
|
6
|
+
<% unless property[:examples].blank? %>
|
7
|
+
<%= heading(t('apipie_dsl.examples'), h_level) %>
|
8
|
+
<% property[:examples].each do |example| %>
|
9
|
+
<% if example[:desc] %>
|
10
|
+
<p><%= example[:desc] %></p>
|
11
|
+
<% end %>
|
12
|
+
<pre class="prettyprint"><%= example[:example] %></pre>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
|
6
16
|
<% unless property[:params].blank? %>
|
7
17
|
<%= heading(t('apipie_dsl.params'), h_level) %>
|
8
18
|
<table class='table'>
|
@@ -1,18 +1,4 @@
|
|
1
|
-
|
2
|
-
<% dsl_sections.each do |section| %>
|
3
|
-
<% if section == @section %>
|
4
|
-
<li class='active'><a href='<%= @doc[:doc_url] %><%= section_ext(section) %><%= @doc[:link_extension] %>'><%= t("apipie_dsl.#{@section}") %></a></li>
|
5
|
-
<% else %>
|
6
|
-
<li><a href='<%= @doc[:doc_url] %><%= section_ext(section) %><%= @doc[:link_extension] %>'><%= t("apipie_dsl.#{section}") %></a></li>
|
7
|
-
<% end %>
|
8
|
-
<% end %>
|
9
|
-
<% unless ApipieDSL.configuration.help_layout.nil? %>
|
10
|
-
<li class='pull-right'>
|
11
|
-
<% section = 'help' %>
|
12
|
-
<a href='<%= @doc[:doc_url] %><%= section_ext(section) %><%= @doc[:link_extension] %>'><%= t("apipie_dsl.#{section}") %></a>
|
13
|
-
</li>
|
14
|
-
<% end %>
|
15
|
-
</ul>
|
1
|
+
<%= apipie_dsl_menu %>
|
16
2
|
<ul class='breadcrumb'>
|
17
3
|
<li>
|
18
4
|
<a href='<%= @doc[:doc_url] %><%= section_ext(@section) %><%= @doc[:link_extension] %>'><%= @doc[:name] %> <%= @klass[:version] %></a>
|
@@ -1,12 +1,4 @@
|
|
1
1
|
<% if ApipieDSL.configuration.help_layout %>
|
2
|
-
|
3
|
-
<% dsl_sections.each do |section| %>
|
4
|
-
<li><a href='<%= @doc[:doc_url] %><%= section_ext(section) %><%= @doc[:link_extension] %>'><%= t("apipie_dsl.#{section}") %></a></li>
|
5
|
-
<% end %>
|
6
|
-
<li class='active pull-right'>
|
7
|
-
<% section = 'help' %>
|
8
|
-
<a href='<%= @doc[:doc_url] %><%= section_ext(section) %><%= @doc[:link_extension] %>'><%= t("apipie_dsl.#{section}") %></a>
|
9
|
-
</li>
|
10
|
-
</ul>
|
2
|
+
<%= apipie_dsl_menu %>
|
11
3
|
<%= render_help %>
|
12
4
|
<% end %>
|
@@ -1,18 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
<% if section == @section %>
|
4
|
-
<li class='active'><a href='<%= @doc[:doc_url] %><%= section_ext(section) %><%= @doc[:link_extension] %>'><%= t("apipie_dsl.#{@section}") %></a></li>
|
5
|
-
<% else %>
|
6
|
-
<li><a href='<%= @doc[:doc_url] %><%= section_ext(section) %><%= @doc[:link_extension] %>'><%= t("apipie_dsl.#{section}") %></a></li>
|
7
|
-
<% end %>
|
8
|
-
<% end %>
|
9
|
-
<% unless ApipieDSL.configuration.help_layout.nil? %>
|
10
|
-
<li class='pull-right'>
|
11
|
-
<% section = 'help' %>
|
12
|
-
<a href='<%= @doc[:doc_url] %><%= section_ext(section) %><%= @doc[:link_extension] %>'><%= t("apipie_dsl.#{section}") %></a>
|
13
|
-
</li>
|
14
|
-
<% end %>
|
15
|
-
</ul>
|
1
|
+
<%= apipie_dsl_menu %>
|
2
|
+
|
16
3
|
<ul class='breadcrumb'>
|
17
4
|
<li class='active'><a href='<%= @doc[:doc_url] %><%= section_ext(@section) %><%= @doc[:link_extension] %>'><%= @doc[:name] %> <%= current_version(@doc[:classes]) %></a></li>
|
18
5
|
<%= render(partial: 'languages', locals: { doc_url: @doc[:doc_url] + section_ext(@section) }) %>
|
@@ -27,7 +14,7 @@
|
|
27
14
|
|
28
15
|
<h1 class='page-header'><%= t('apipie_dsl.classes') %></h1>
|
29
16
|
|
30
|
-
<% @doc[:classes].
|
17
|
+
<% @doc[:classes].sort_by { |id, c| c[:name] }.each do |id, klass| %>
|
31
18
|
<% next unless klass[:show] && in_section?(@section, klass[:id]) %>
|
32
19
|
<h2>
|
33
20
|
<a href='<%= klass[:doc_url] %><%= @doc[:link_extension] %>'>
|
@@ -1,18 +1,4 @@
|
|
1
|
-
|
2
|
-
<% dsl_sections.each do |section| %>
|
3
|
-
<% if section == @section %>
|
4
|
-
<li class='active'><a href='<%= @doc[:doc_url] %><%= section_ext(section) %><%= @doc[:link_extension] %>'><%= t("apipie_dsl.#{@section}") %></a></li>
|
5
|
-
<% else %>
|
6
|
-
<li><a href='<%= @doc[:doc_url] %><%= section_ext(section) %><%= @doc[:link_extension] %>'><%= t("apipie_dsl.#{section}") %></a></li>
|
7
|
-
<% end %>
|
8
|
-
<% end %>
|
9
|
-
<% unless ApipieDSL.configuration.help_layout.nil? %>
|
10
|
-
<li class='pull-right'>
|
11
|
-
<% section = 'help' %>
|
12
|
-
<a href='<%= @doc[:doc_url] %><%= section_ext(section) %><%= @doc[:link_extension] %>'><%= t("apipie_dsl.#{section}") %></a>
|
13
|
-
</li>
|
14
|
-
<% end %>
|
15
|
-
</ul>
|
1
|
+
<%= apipie_dsl_menu %>
|
16
2
|
<ul class='breadcrumb'>
|
17
3
|
<li>
|
18
4
|
<a href='<%= @doc[:doc_url] %><%= section_ext(@section) %><%= @doc[:link_extension] %>'><%= @doc[:name] %> <%= @klass[:version] %></a>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% @doc[:classes].sort_by
|
1
|
+
<% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
|
2
2
|
<% next unless klass[:show] %>
|
3
3
|
<h4><a href='#<%= key %>'><%= klass[:name] %></a></h4>
|
4
4
|
<ul>
|
@@ -14,7 +14,7 @@
|
|
14
14
|
</ul>
|
15
15
|
<% end %>
|
16
16
|
|
17
|
-
<% @doc[:classes].sort_by
|
17
|
+
<% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
|
18
18
|
<% next unless klass[:show] %>
|
19
19
|
<hr/>
|
20
20
|
<div>
|
@@ -42,7 +42,10 @@
|
|
42
42
|
<% unless prop[:examples].blank? %>
|
43
43
|
<h4><%= t('apipie_dsl.examples') %></h4>
|
44
44
|
<% prop[:examples].each do |example| %>
|
45
|
-
|
45
|
+
<% if example[:desc] %>
|
46
|
+
<p><%= example[:desc] %></p>
|
47
|
+
<% end %>
|
48
|
+
<pre class="wiki"><%= example[:example] %></pre>
|
46
49
|
<% end %>
|
47
50
|
<% end %>
|
48
51
|
|
@@ -79,7 +82,10 @@
|
|
79
82
|
<% unless method[:examples].blank? %>
|
80
83
|
<h4><%= t('apipie_dsl.examples') %></h4>
|
81
84
|
<% method[:examples].each do |example| %>
|
82
|
-
|
85
|
+
<% if example[:desc] %>
|
86
|
+
<p><%= example[:desc] %></p>
|
87
|
+
<% end %>
|
88
|
+
<pre class="wiki"><%= example[:example] %></pre>
|
83
89
|
<% end %>
|
84
90
|
<% end %>
|
85
91
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% @doc[:classes].sort_by
|
1
|
+
<% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
|
2
2
|
<% next unless klass[:show] %>
|
3
3
|
<h4><a href='#<%= key %>'><%= klass[:name] %></a></h4>
|
4
4
|
<ul>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
<hr>
|
20
20
|
|
21
|
-
<% @doc[:classes].sort_by
|
21
|
+
<% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
|
22
22
|
<% next unless klass[:show] %>
|
23
23
|
<ul class='breadcrumb' id='<%= key %>'>
|
24
24
|
<li><a href='#'><%= @doc[:name] %></a><span class='divider'>/</span></li>
|
@@ -59,7 +59,10 @@
|
|
59
59
|
<% unless prop[:examples].blank? %>
|
60
60
|
<h2><%= t('apipie_dsl.examples') %></h2>
|
61
61
|
<% prop[:examples].each do |example| %>
|
62
|
-
|
62
|
+
<% if example[:desc] %>
|
63
|
+
<p><%= example[:desc] %></p>
|
64
|
+
<% end %>
|
65
|
+
<pre><%= example[:example] %></pre>
|
63
66
|
<% end %>
|
64
67
|
<% end %>
|
65
68
|
|
@@ -107,7 +110,10 @@
|
|
107
110
|
<% unless method[:examples].blank? %>
|
108
111
|
<h2><%= t('apipie_dsl.examples') %></h2>
|
109
112
|
<% method[:examples].each do |example| %>
|
110
|
-
|
113
|
+
<% if example[:desc] %>
|
114
|
+
<p><%= example[:desc] %></p>
|
115
|
+
<% end %>
|
116
|
+
<pre class="prettyprint"><%= example[:example] %></pre>
|
111
117
|
<% end %>
|
112
118
|
<% end %>
|
113
119
|
|
@@ -6,7 +6,7 @@ module ApipieDSL
|
|
6
6
|
require 'apipie_dsl/static_dispatcher'
|
7
7
|
|
8
8
|
class Engine < Rails::Engine
|
9
|
-
initializer 'static assets', :
|
9
|
+
initializer 'static assets', before: :build_middleware_stack do |app|
|
10
10
|
app.middleware.use ::ApipieDSL::StaticDispatcher, "#{root}/app/public"
|
11
11
|
end
|
12
12
|
end
|
@@ -12,7 +12,7 @@ module ApipieDSL
|
|
12
12
|
@properties = []
|
13
13
|
@version = version || ApipieDSL.configuration.default_version
|
14
14
|
@parent = ApipieDSL.get_class_description(ApipieDSL.superclass_for(klass), version)
|
15
|
-
@refs = []
|
15
|
+
@refs = [@name]
|
16
16
|
@sections = []
|
17
17
|
@show = true
|
18
18
|
update_from_dsl_data(dsl_data) if dsl_data
|
@@ -20,17 +20,22 @@ module ApipieDSL
|
|
20
20
|
|
21
21
|
def update_from_dsl_data(dsl_data)
|
22
22
|
@name = dsl_data[:class_name] if dsl_data[:class_name]
|
23
|
-
@full_description = ApipieDSL.markup_to_html(dsl_data[:description])
|
24
|
-
@short_description = dsl_data[:short_description]
|
23
|
+
@full_description = ApipieDSL.markup_to_html(dsl_data[:description]) if dsl_data[:description]
|
24
|
+
@short_description = dsl_data[:short_description] || @short_description
|
25
25
|
@tag_list = dsl_data[:tag_list]
|
26
|
-
|
26
|
+
if dsl_data[:meta].is_a?(Hash)
|
27
|
+
@metadata&.merge!(dsl_data[:meta])
|
28
|
+
elsif dsl_data[:meta]
|
29
|
+
@metadata = dsl_data[:meta]
|
30
|
+
end
|
27
31
|
@deprecated = dsl_data[:deprecated] || false
|
28
32
|
@show = dsl_data[:show] || @show
|
29
|
-
|
30
|
-
|
33
|
+
prop_names = @properties.map(&:name)
|
34
|
+
(dsl_data[:properties] || []).each do |args|
|
35
|
+
@properties << ApipieDSL::MethodDescription.from_dsl_data(self, args) unless prop_names.include?(args.first.to_s)
|
31
36
|
end
|
32
|
-
@refs = dsl_data[:refs]
|
33
|
-
@sections = dsl_data[:sections]
|
37
|
+
@refs = (@refs + dsl_data[:refs]).uniq if dsl_data[:refs]
|
38
|
+
@sections = (@sections + dsl_data[:sections]).uniq if dsl_data[:sections]
|
34
39
|
return unless dsl_data[:app_info]
|
35
40
|
|
36
41
|
ApipieDSL.configuration.app_info[version] = dsl_data[:app_info]
|
@@ -65,10 +70,6 @@ module ApipieDSL
|
|
65
70
|
@methods.values
|
66
71
|
end
|
67
72
|
|
68
|
-
def property_descriptions
|
69
|
-
@properties
|
70
|
-
end
|
71
|
-
|
72
73
|
def doc_url(section = nil)
|
73
74
|
crumbs = []
|
74
75
|
crumbs << version if ApipieDSL.configuration.version_in_url
|
@@ -97,8 +98,8 @@ module ApipieDSL
|
|
97
98
|
full_description: ApipieDSL.translate(@full_description, lang),
|
98
99
|
version: version,
|
99
100
|
metadata: @metadata,
|
100
|
-
properties: @properties.map { |prop_desc| prop_desc.docs(section, lang) },
|
101
|
-
methods: methods,
|
101
|
+
properties: @properties.map { |prop_desc| prop_desc.docs(section, lang) }.sort_by { |p| p[:name] },
|
102
|
+
methods: methods.sort_by { |m| m[:name] },
|
102
103
|
deprecated: @deprecated,
|
103
104
|
show: @show
|
104
105
|
}
|
data/lib/apipie_dsl/dsl.rb
CHANGED
@@ -202,9 +202,10 @@ module ApipieDSL
|
|
202
202
|
options[:desc] = desc_or_options
|
203
203
|
end
|
204
204
|
|
205
|
-
|
205
|
+
case retobj_or_options
|
206
|
+
when Hash
|
206
207
|
options.merge!(retobj_or_options)
|
207
|
-
|
208
|
+
when Symbol
|
208
209
|
options[:param_group] = retobj_or_options
|
209
210
|
else
|
210
211
|
options[:object_of] ||= retobj_or_options
|
@@ -347,7 +348,7 @@ module ApipieDSL
|
|
347
348
|
include ApipieDSL::Klass
|
348
349
|
include ApipieDSL::Method
|
349
350
|
|
350
|
-
|
351
|
+
attr_accessor :class_scope
|
351
352
|
|
352
353
|
def initialize(class_scope)
|
353
354
|
@class_scope = class_scope
|
@@ -385,10 +386,9 @@ module ApipieDSL
|
|
385
386
|
end
|
386
387
|
|
387
388
|
def self.extension_data
|
388
|
-
@extension_data ||= []
|
389
|
+
@extension_data ||= { methods: [] }
|
389
390
|
end
|
390
391
|
|
391
|
-
# rubocop:disable Metrics/AbcSize
|
392
392
|
def self.define_validators(class_scope, method_desc)
|
393
393
|
return if method_desc.nil? || ![true, :implicitly, :explicitly].include?(ApipieDSL.configuration.validate)
|
394
394
|
return unless [true, :implicitly].include?(ApipieDSL.configuration.validate)
|
@@ -415,7 +415,7 @@ module ApipieDSL
|
|
415
415
|
def self.update_method_desc(method_desc, dsl_data)
|
416
416
|
method_desc.full_description = dsl_data[:description] || method_desc.full_description
|
417
417
|
method_desc.short_description = dsl_data[:short_description] || method_desc.short_description
|
418
|
-
if dsl_data[:meta]
|
418
|
+
if dsl_data[:meta].is_a?(Hash)
|
419
419
|
method_desc.metadata&.merge!(dsl_data[:meta])
|
420
420
|
else
|
421
421
|
method_desc.metadata = dsl_data[:meta]
|
@@ -430,7 +430,6 @@ module ApipieDSL
|
|
430
430
|
end
|
431
431
|
ParameterDescription.merge(method_desc.plain_params, params)
|
432
432
|
end
|
433
|
-
# rubocop:enable Metrics/AbcSize
|
434
433
|
end
|
435
434
|
end
|
436
435
|
|
@@ -456,9 +455,10 @@ module ApipieDSL
|
|
456
455
|
end
|
457
456
|
|
458
457
|
def apipie(context = :method, desc_or_options = nil, options = {}, &block)
|
459
|
-
|
458
|
+
case desc_or_options
|
459
|
+
when Hash
|
460
460
|
options = options.merge(desc_or_options)
|
461
|
-
|
461
|
+
when String
|
462
462
|
options[:desc] = desc_or_options
|
463
463
|
end
|
464
464
|
options[:name] ||= context.to_s
|
@@ -509,9 +509,10 @@ module ApipieDSL
|
|
509
509
|
private
|
510
510
|
|
511
511
|
def prepare_delegatee(scope, desc_or_options, options, &block)
|
512
|
-
|
512
|
+
case desc_or_options
|
513
|
+
when Hash
|
513
514
|
options = options.merge(desc_or_options)
|
514
|
-
|
515
|
+
when String
|
515
516
|
options[:desc] = desc_or_options
|
516
517
|
end
|
517
518
|
|
@@ -530,9 +531,10 @@ module ApipieDSL
|
|
530
531
|
include ApipieDSL::Delegatable
|
531
532
|
|
532
533
|
def apipie(context = :method, desc_or_options = nil, options = {}, &block)
|
533
|
-
|
534
|
+
case desc_or_options
|
535
|
+
when Hash
|
534
536
|
options = options.merge(desc_or_options)
|
535
|
-
|
537
|
+
when String
|
536
538
|
options[:desc] = desc_or_options
|
537
539
|
end
|
538
540
|
options[:name] ||= context.to_s
|
@@ -553,16 +555,19 @@ module ApipieDSL
|
|
553
555
|
|
554
556
|
delegatee = Delegatee.instance_for(self).with(&block)
|
555
557
|
delegatee.dsl_data[:update_only] = true
|
556
|
-
|
558
|
+
|
557
559
|
return if context == :method
|
558
560
|
|
559
|
-
#
|
561
|
+
# Save instance to reuse when actual scope is set
|
562
|
+
Delegatee.extension_data[:class] = delegatee
|
560
563
|
Delegatee.instance_reset
|
561
564
|
end
|
562
565
|
|
563
566
|
def prepended(klass)
|
564
567
|
super
|
565
|
-
Delegatee.extension_data
|
568
|
+
Delegatee.extension_data[:class]&.class_scope = klass
|
569
|
+
Delegatee.extension_data[:class]&.eval_dsl_for(:class)
|
570
|
+
Delegatee.extension_data[:methods].each do |method_name, dsl_data|
|
566
571
|
class_scope = klass
|
567
572
|
if dsl_data[:update_only]
|
568
573
|
class_name = ApipieDSL.get_class_name(class_scope)
|
@@ -592,7 +597,7 @@ module ApipieDSL
|
|
592
597
|
return if Delegatee.instance.nil?
|
593
598
|
|
594
599
|
dsl_data = Delegatee.instance.eval_dsl_for(:method)
|
595
|
-
Delegatee.extension_data << [method_name, dsl_data]
|
600
|
+
Delegatee.extension_data[:methods] << [method_name, dsl_data]
|
596
601
|
ensure
|
597
602
|
Delegatee.instance_reset
|
598
603
|
end
|
data/lib/apipie_dsl/errors.rb
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
module ApipieDSL
|
4
4
|
class Error < StandardError; end
|
5
|
+
|
5
6
|
class ParamError < Error
|
6
7
|
attr_accessor :param
|
7
8
|
|
8
9
|
def initialize(param)
|
10
|
+
super
|
9
11
|
@param = param
|
10
12
|
end
|
11
13
|
end
|
@@ -46,6 +48,7 @@ module ApipieDSL
|
|
46
48
|
attr_accessor :value
|
47
49
|
|
48
50
|
def initialize(value)
|
51
|
+
super
|
49
52
|
@value = value
|
50
53
|
end
|
51
54
|
|
@@ -70,6 +73,7 @@ module ApipieDSL
|
|
70
73
|
attr_reader :value
|
71
74
|
|
72
75
|
def initialize(value)
|
76
|
+
super
|
73
77
|
@value = value
|
74
78
|
end
|
75
79
|
|
@@ -33,7 +33,6 @@ module ApipieDSL
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
# rubocop:disable Metrics/ParameterLists
|
37
36
|
def initialize(method_description, name, validator, desc_or_options = nil, options = {}, &block)
|
38
37
|
if desc_or_options.is_a?(Hash)
|
39
38
|
options = options.merge(desc_or_options)
|
@@ -64,7 +63,6 @@ module ApipieDSL
|
|
64
63
|
end
|
65
64
|
raise StandardError, "Validator for #{validator} not found." unless @validator
|
66
65
|
end
|
67
|
-
# rubocop:enable Metrics/ParameterLists
|
68
66
|
|
69
67
|
def validator
|
70
68
|
return @validator unless @validator.is_a?(ApipieDSL::Validator::Lazy)
|
@@ -12,8 +12,6 @@ module ApipieDSL
|
|
12
12
|
@param_group = { scope: @scope }
|
13
13
|
@options = options
|
14
14
|
@return_type = (@options.keys & %i[array_of one_of object_of param_group]).first
|
15
|
-
|
16
|
-
return unless @options[@return_type].is_a?(::Class)
|
17
15
|
end
|
18
16
|
|
19
17
|
# this routine overrides Param#default_param_group_scope
|
data/lib/apipie_dsl/routing.rb
CHANGED
@@ -8,6 +8,9 @@ namespace :apipie_dsl do
|
|
8
8
|
task :cache, [:include_json] => :environment do |_task, args|
|
9
9
|
args.with_defaults(include_json: false)
|
10
10
|
include_json = %w[1 true].include?(args[:include_json])
|
11
|
+
cache_part = ENV['cache_part']
|
12
|
+
generate_index = (cache_part == 'classes' ? false : true)
|
13
|
+
generate_classes = (cache_part == 'index' ? false : true)
|
11
14
|
time_start = Time.now
|
12
15
|
puts "#{time_start} | Started"
|
13
16
|
ApipieDSL::TasksUtils.with_loaded_documentation do
|
@@ -24,12 +27,16 @@ namespace :apipie_dsl do
|
|
24
27
|
ApipieDSL.url_prefix = "../../#{subdir}"
|
25
28
|
doc = ApipieDSL.docs(version, nil, nil, lang, section)
|
26
29
|
doc[:docs][:link_extension] = "#{ApipieDSL::TasksUtils.lang_ext(lang)}.html"
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
if generate_index
|
31
|
+
ApipieDSL::TasksUtils.generate_index_page(file_base_version, doc, include_json, true, lang, section)
|
32
|
+
end
|
33
|
+
if generate_classes
|
34
|
+
ApipieDSL.url_prefix = "../../../#{subdir}"
|
35
|
+
section_out = "#{file_base_version}/#{section}"
|
36
|
+
ApipieDSL::TasksUtils.generate_class_pages(version, section_out, doc, include_json, lang, section)
|
37
|
+
ApipieDSL.url_prefix = "../../../../#{subdir}"
|
38
|
+
ApipieDSL::TasksUtils.generate_method_pages(version, section_out, doc, include_json, lang, section)
|
39
|
+
end
|
33
40
|
end
|
34
41
|
ApipieDSL.url_prefix = "../../#{subdir}"
|
35
42
|
doc = ApipieDSL.docs(version, nil, nil, lang)
|
@@ -61,12 +68,16 @@ namespace :apipie_dsl do
|
|
61
68
|
ApipieDSL.url_prefix = "../../#{subdir}"
|
62
69
|
doc = ApipieDSL.docs(version, nil, nil, lang, section)
|
63
70
|
doc[:docs][:link_extension] = "#{ApipieDSL::TasksUtils.lang_ext(lang)}.html"
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
71
|
+
if generate_index
|
72
|
+
ApipieDSL::TasksUtils.generate_index_page(file_base_version, doc, include_json, true, lang, section)
|
73
|
+
end
|
74
|
+
if generate_classes
|
75
|
+
ApipieDSL.url_prefix = "../../../#{subdir}"
|
76
|
+
section_out = "#{file_base_version}/#{section}"
|
77
|
+
ApipieDSL::TasksUtils.generate_class_pages(version, section_out, doc, include_json, lang, section)
|
78
|
+
ApipieDSL.url_prefix = "../../../../#{subdir}"
|
79
|
+
ApipieDSL::TasksUtils.generate_method_pages(version, section_out, doc, include_json, lang, section)
|
80
|
+
end
|
70
81
|
end
|
71
82
|
ApipieDSL.url_prefix = "../../#{subdir}"
|
72
83
|
doc = ApipieDSL.docs(version, nil, nil, lang)
|
@@ -21,8 +21,8 @@ module ApipieDSL
|
|
21
21
|
base_paths.unshift("#{Rails.root}/app/views/apipie_dsl/apipie_dsls") if File.directory?("#{Rails.root}/app/views/apipie_dsl/apipie_dsls")
|
22
22
|
end
|
23
23
|
layouts_paths = [File.expand_path('../../app/views/layouts', __dir__)]
|
24
|
-
if ApipieDSL.configuration.rails?
|
25
|
-
layouts_paths.unshift("#{Rails.root}/app/views/layouts")
|
24
|
+
if ApipieDSL.configuration.rails? && File.directory?("#{Rails.root}/app/views/layouts/apipie_dsl")
|
25
|
+
layouts_paths.unshift("#{Rails.root}/app/views/layouts")
|
26
26
|
end
|
27
27
|
paths = ActionView::PathSet.new(base_paths + layouts_paths)
|
28
28
|
@renderer = ActionView::Base.new(paths, {})
|
data/lib/apipie_dsl/utils.rb
CHANGED
@@ -60,18 +60,7 @@ module ApipieDSL
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
64
|
-
class Hash
|
65
|
-
def transform_keys
|
66
|
-
result = {}
|
67
|
-
each do |key, value|
|
68
|
-
new_key = yield key
|
69
|
-
result[new_key] = value
|
70
|
-
end
|
71
|
-
result
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
63
|
+
|
75
64
|
if defined? Rails
|
76
65
|
class Module
|
77
66
|
# https://github.com/rails/rails/pull/35035
|
data/lib/apipie_dsl/validator.rb
CHANGED
@@ -17,6 +17,7 @@ module ApipieDSL
|
|
17
17
|
BaseValidator.find(@param_description, @argument.constantize, @options, @block)
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
20
21
|
# To create a new validator, inherit from ApipieDSL::Validator::BaseValidator
|
21
22
|
# and implement class method 'build' and instance method 'validate'
|
22
23
|
class BaseValidator
|
@@ -49,6 +50,7 @@ module ApipieDSL
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def self.inherited(subclass)
|
53
|
+
super(subclass)
|
52
54
|
@validators ||= []
|
53
55
|
@validators.unshift(subclass)
|
54
56
|
end
|
@@ -325,9 +327,7 @@ module ApipieDSL
|
|
325
327
|
return false unless value.is_a?(Hash)
|
326
328
|
|
327
329
|
@hash_params&.each do |name, param|
|
328
|
-
if ApipieDSL.configuration.validate_value?
|
329
|
-
param.validate(value[name]) if value.key?(name)
|
330
|
-
end
|
330
|
+
param.validate(value[name]) if ApipieDSL.configuration.validate_value? && value.key?(name)
|
331
331
|
end
|
332
332
|
true
|
333
333
|
end
|
data/lib/apipie_dsl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apipie-dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleh Fedorenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -206,14 +206,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
206
206
|
requirements:
|
207
207
|
- - ">="
|
208
208
|
- !ruby/object:Gem::Version
|
209
|
-
version: 2.
|
209
|
+
version: 2.5.0
|
210
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
211
|
requirements:
|
212
212
|
- - ">="
|
213
213
|
- !ruby/object:Gem::Version
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
|
-
rubygems_version: 3.
|
216
|
+
rubygems_version: 3.0.8
|
217
217
|
signing_key:
|
218
218
|
specification_version: 4
|
219
219
|
summary: Ruby DSL documentation tool
|