rdoc-markdown 0.20.1 → 0.20.2

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: 5ae68a40db5d99f60034820bab835a6a6d17c9db00dd3d38d3d47bd7da73743b
4
- data.tar.gz: 65a59f988b16411b5914dc5d7de8496efac2a12a67b835ac50b9fa478c1492fd
3
+ metadata.gz: 867481b03e8cfa3279b67d5344e3d95dfed1c23b4a885cef33bf2cf0992d2df8
4
+ data.tar.gz: f1bea8f39ecc1ccfdb9363c8c1071fa01099cf48596c1e4d90b01dee4cd000b1
5
5
  SHA512:
6
- metadata.gz: c8c080f1704dff5d1a4ca256676fbf5f1a69d51a9ec0223e952cceb37837f840274a2bb39e44c70801379ef72d7a70d3811e96810de1d5a568341f6ec2a74875
7
- data.tar.gz: 10a07e634578b0ac0290d91e4b1f52f6af36e0cb30349fa8d519970020b55246e719dec427f64c8ad59f6505def782e8709e98b6ff4be01f5494637af5cb265c
6
+ metadata.gz: 9eb94354e06c97eb71c9bf4defc1c4f4b7f62489d1ac5d9170cb2d091ab126f181b6f84457d9f2f78a324814ed417d78a9dba67f3d2a995cacfabc276cab3eba
7
+ data.tar.gz: 2caa21c1f0968226a68dddfb115f9dd6c8750ed08db856fb94dce541100eb7b0c2fb36ef7da355f54f5b50e15129c9b65cd19ff5e0aa597e9a65c4a955eb2e33
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.20.2
6
+
7
+ - Preserve documented bracket lookup and assignment arguments in method headings without changing their anchors.
8
+
5
9
  ## 0.20.1
6
10
 
7
11
  - Don't offset headings for commets
@@ -11,34 +11,54 @@ module RDoc::Generator::Markdown::Signatures
11
11
  #
12
12
  # @param method [RDoc::AnyMethod] Method object to render.
13
13
  #
14
- # @return [String] Normalized method signature.
14
+ # @return [String] Complete signature including the method name or documented receiver.
15
15
  def method_signature(method)
16
16
  RDoc::Generator::Markdown::Signatures.render_method_signature(method, store)
17
17
  end
18
18
 
19
19
  private :method_signature
20
20
 
21
- # Builds a method signature from RDoc and store metadata.
21
+ # Builds a complete method heading signature from RDoc and store metadata.
22
22
  #
23
23
  # @param method [RDoc::AnyMethod] Method object to render.
24
24
  # @param store [RDoc::Store] Documentation store with sidecar signatures.
25
25
  #
26
- # @return [String] Normalized method signature.
26
+ # @return [String] Complete signature including the method name or documented receiver.
27
27
  def self.render_method_signature(method, store)
28
- signatures = method.type_signature_lines || store.rbs_signature_for(method) || [method.param_seq]
28
+ signatures = method.type_signature_lines || store.rbs_signature_for(method)
29
+ if !signatures && (call_seq = bracket_call_sequence(method))
30
+ return call_seq.lines.map { |line| normalize_signature(line) }.join(" | ")
31
+ end
32
+ signatures ||= [method.param_seq]
29
33
 
30
34
  signatures = signatures.filter_map do |signature|
31
35
  next unless signature&.match?(/\S/)
32
36
 
33
- signature = signature.gsub("->", " -> ")
34
- signature = signature.gsub(/\s+/, " ").strip
37
+ signature = normalize_signature(signature)
35
38
  signature = " #{signature}" if signature.start_with?("->")
36
39
  merge_method_signature_arguments(signature, method.params)
37
40
  end
38
41
 
39
- return "()" if signatures.empty?
42
+ signature = signatures.empty? ? "()" : signatures.join(" | ")
43
+ "#{method.name}#{signature}"
44
+ end
40
45
 
41
- signatures.join(" | ")
46
+ # Returns the original call syntax for bracket operators, when documented.
47
+ #
48
+ # @param method [RDoc::AnyMethod] Method object to render.
49
+ #
50
+ # @return [String, nil] Documented bracket calls, or nil for other signatures.
51
+ def self.bracket_call_sequence(method)
52
+ method.call_seq if ["[]", "[]="].include?(method.name)
53
+ end
54
+
55
+ # Normalizes spacing in a signature without changing its call syntax.
56
+ #
57
+ # @param signature [String] Signature or complete call sequence.
58
+ #
59
+ # @return [String] Signature with consistent arrow and whitespace formatting.
60
+ def self.normalize_signature(signature)
61
+ signature.gsub("->", " -> ").gsub(/\s+/, " ").strip
42
62
  end
43
63
 
44
64
  # Merges RDoc parameter names into a type-only signature.
@@ -5,6 +5,6 @@ module Rdoc
5
5
  # @private
6
6
  module Markdown
7
7
  # @private
8
- VERSION = "0.20.1"
8
+ VERSION = "0.20.2"
9
9
  end
10
10
  end
@@ -61,7 +61,7 @@
61
61
 
62
62
  <%= "#" * group_heading_level %> <%= visibility.capitalize %> <%= type.capitalize %> Methods
63
63
  <% methods.each do |method| -%>
64
- <%= "#" * member_heading_level %> `<%= method.name %><%= method_signature(method) %>`<%= anchor(method.aref) %>
64
+ <%= "#" * member_heading_level %> `<%= method_signature(method) %>`<%= anchor(method.aref) %>
65
65
  <%= method_description(method, current_class: klass, heading_level_offset: member_heading_level) %>
66
66
  <% end -%>
67
67
  <% end -%>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.20.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav (Stas) Katkov