rspec-apidoc 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70f813f8f9f45e4f454cd07147cc1ff8dc22496ddd99e22bccf098b6f513f732
4
- data.tar.gz: a817bac7f9c2f5bed38117de7634ae16520192f9f4a3864e685016d6f5e5d283
3
+ metadata.gz: fdcc283a659667529475a9c1836398a5ad092018a484ac60a746994a35924759
4
+ data.tar.gz: c637fccb0640b1db43582d36f7f4b0889df8017e6bbcfb56506a4d8085b7328a
5
5
  SHA512:
6
- metadata.gz: c52748bb8d403685869114c402c36ee40ba0f1a3909871bc430cd753a4c74b626ad1d5f6252c5428d9ca628fe6757ae934ebbce923c9231e31205c77b989c722
7
- data.tar.gz: b2f2f1f893a876532f404ecd47598e986f805b888503055668ed7144f2f972a45ef4783fb12df76602107adbdce9b6ef05338bb1321fb3195d6fa7cb231e655c
6
+ metadata.gz: 0b550af654071e60b390866d9dd99e6484288cc7013e5a43b1d6e21cb3ac6d7c82f02316daf7500b032fe81cbe9b5859a70207a6b7d762bd6bc54653fdeb8592
7
+ data.tar.gz: 1818afff93418cba9c72083b565ac73868187f87ef578e8d8509a41990e025ab6d8647967773c0b786ad52d8fad64cef2cb3f73704fabf81fc8aac85739879d3
@@ -90,9 +90,13 @@
90
90
  </div>
91
91
 
92
92
  <% examples.each do |controller, items| %>
93
- <% items.sort.each do |action, action_items| %>
93
+ <% items.sort.each_with_index do |(action, action_items), mindex| %>
94
94
  <% action_items.each_with_index do |item, index| %>
95
95
  <div class="example">
96
+ <% if mindex == 0 %>
97
+ <%= item[:controller_comment] %>
98
+ <% end %>
99
+
96
100
  <% if index == 0 %>
97
101
  <div class="example-doc" id="<%= controller %>-<%= action %>">
98
102
  <%= item[:action_comment] || ( item[:method] + ' ' + controller ) %>
data/lib/rspec/apidoc.rb CHANGED
@@ -82,15 +82,21 @@ module RSpec
82
82
  response_body = parse_json_safely(spec.response.body)
83
83
 
84
84
  if spec.request.controller_instance
85
- action_comment = spec.request.controller_class.instance_method(
86
- spec.request.controller_instance.action_name
87
- ).comment
85
+ action_name = spec.request.controller_instance.action_name
86
+ action_method = spec.request.controller_instance.method(action_name)
88
87
  # Remove any `@param` or `@return` lines
89
- action_comment = action_comment.delete('#').gsub(/@.*$/, '').strip
88
+ action_comment = \
89
+ action_method.comment.gsub('# ', '').gsub(/@.*$/, '').strip
90
90
  controller_class = spec.request.controller_class
91
- action_name = spec.request.controller_instance.action_name
91
+ controller_comment = nil
92
+
93
+ if action_method.respond_to?(:class_comment)
94
+ controller_comment = \
95
+ action_method.class_comment.gsub('# ', '').gsub(/@.*$/, '').strip
96
+ end
92
97
  else
93
98
  action_comment = nil
99
+ controller_comment = nil
94
100
  controller_class = spec.request.path
95
101
  action_name = spec.request.method
96
102
  end
@@ -99,6 +105,7 @@ module RSpec
99
105
  description: example.metadata[:full_description],
100
106
 
101
107
  controller_class: controller_class,
108
+ controller_comment: controller_comment,
102
109
  action_name: action_name,
103
110
  action_comment: action_comment,
104
111
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-apidoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stas Suscov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-02 00:00:00.000000000 Z
11
+ date: 2021-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source