rdoc-markdown 0.20.0 → 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 867481b03e8cfa3279b67d5344e3d95dfed1c23b4a885cef33bf2cf0992d2df8
|
|
4
|
+
data.tar.gz: f1bea8f39ecc1ccfdb9363c8c1071fa01099cf48596c1e4d90b01dee4cd000b1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9eb94354e06c97eb71c9bf4defc1c4f4b7f62489d1ac5d9170cb2d091ab126f181b6f84457d9f2f78a324814ed417d78a9dba67f3d2a995cacfabc276cab3eba
|
|
7
|
+
data.tar.gz: 2caa21c1f0968226a68dddfb115f9dd6c8750ed08db856fb94dce541100eb7b0c2fb36ef7da355f54f5b50e15129c9b65cd19ff5e0aa597e9a65c4a955eb2e33
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
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
|
+
|
|
9
|
+
## 0.20.1
|
|
10
|
+
|
|
11
|
+
- Don't offset headings for commets
|
|
12
|
+
|
|
5
13
|
## 0.20.0
|
|
6
14
|
|
|
7
15
|
- Restore legacy anchors in a single Markdown substitution pass.
|
|
@@ -96,6 +96,8 @@ module RDoc::Generator::Markdown::Descriptions
|
|
|
96
96
|
description = render_description(code_object)
|
|
97
97
|
return fallback.to_s if description.empty?
|
|
98
98
|
|
|
99
|
+
comment = code_object.comment
|
|
100
|
+
heading_level_offset = 0 if RDoc::Comment === comment && comment.format == "markdown"
|
|
99
101
|
RDoc::Generator::Markdown::Conversion.markdownify(description, heading_level_offset: heading_level_offset)
|
|
100
102
|
end
|
|
101
103
|
|
|
@@ -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]
|
|
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]
|
|
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)
|
|
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
|
|
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
|
-
|
|
42
|
+
signature = signatures.empty? ? "()" : signatures.join(" | ")
|
|
43
|
+
"#{method.name}#{signature}"
|
|
44
|
+
end
|
|
40
45
|
|
|
41
|
-
|
|
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.
|
|
@@ -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 %> `<%=
|
|
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 -%>
|