rdoc-markdown 0.20.2 → 0.21.0
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +6 -0
- data/lib/rdoc/generator/markdown/conversion.rb +9 -6
- data/lib/rdoc/generator/markdown/descriptions.rb +3 -1
- data/lib/rdoc/markdown/version.rb +1 -1
- data/lib/templates/classfile.md.erb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8b215eca69feb6c88372f2a84436dff0c42712e0f3deb7086c91e9ee1f0e8cd3
|
|
4
|
+
data.tar.gz: 3ce6ccaeecfd189da39207c07e6f6733c5f183589eb90a3474ea3316b80c0445
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5cc5f170e0eae86a2f5ba510db36fb9f1bf5b1eca91d7b3a31fb95f1a0b2188ff8d1b48892fb98c65bfa2b7b46e9d80cbe5c852595e540f214204d0a9d3c936f
|
|
7
|
+
data.tar.gz: 3df4e291559a57ca7cf727e1e59b60ae8c292cd6defadb7a0c8cef91e1bd56f504e8ab9072d75a9978658efd19b8a0613b7884352ce57cd7cd5d67143762f322
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- Keep generated method and section headings readable after raw HTML descriptions.
|
|
6
|
+
- Validate search-index targets and same-document links against parsed Markdown headings and anchors, including alias targets.
|
|
7
|
+
- Leave alias targets unlinked when RDoc has removed the canonical method from the generated documentation.
|
|
8
|
+
- Preserve literal HTML, ERB templates, heredocs, and entity strings in code examples.
|
|
9
|
+
|
|
5
10
|
## 0.20.2
|
|
6
11
|
|
|
7
12
|
- Preserve documented bracket lookup and assignment arguments in method headings without changing their anchors.
|
data/README.md
CHANGED
|
@@ -60,6 +60,12 @@ To validate generated markdown against GitHub Flavored Markdown and check local
|
|
|
60
60
|
rake markdown:validate
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
+
Validation also checks same-document fragment links and every `index.csv` target.
|
|
64
|
+
Indexed fragments and method/attribute links must point to parsed Markdown heading
|
|
65
|
+
sections: an anchor appearing only in a code example or a raw HTML block is not
|
|
66
|
+
enough. This catches method headings swallowed by an unterminated Markdown HTML
|
|
67
|
+
block, including aliases that link back to those methods.
|
|
68
|
+
|
|
63
69
|
To lint markdown ERB templates:
|
|
64
70
|
|
|
65
71
|
```
|
|
@@ -15,7 +15,7 @@ class RDoc::Generator::Markdown::Conversion
|
|
|
15
15
|
fragment.css("a").each { |link| normalize_link(link, document) }
|
|
16
16
|
markdown = ReverseMarkdown.convert(fragment, github_flavored: true).dup
|
|
17
17
|
markdown.gsub!(Regexp.union(anchor_aliases.keys), anchor_aliases)
|
|
18
|
-
|
|
18
|
+
normalize_definition_lists(markdown).rstrip.gsub(/^(#+)(\s)/) do
|
|
19
19
|
"#{"#" * [Regexp.last_match(1).length + heading_level_offset, 6].min}#{Regexp.last_match(2)}"
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -64,7 +64,7 @@ class RDoc::Generator::Markdown::Conversion
|
|
|
64
64
|
fragment.css("pre").each do |pre|
|
|
65
65
|
language = pre["class"].to_s[/\A(?!highlight\z)[A-Za-z][A-Za-z0-9_+-]*\z/]
|
|
66
66
|
pre["class"] = "brush: #{language};" if language
|
|
67
|
-
pre.
|
|
67
|
+
pre.content = pre.text
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -152,14 +152,17 @@ class RDoc::Generator::Markdown::Conversion
|
|
|
152
152
|
.sub(%r{\A((?:\.\./)*)(?:files|classes|modules)/(?=.+\.md(?:[?#]|\z))}, '\1')
|
|
153
153
|
end
|
|
154
154
|
|
|
155
|
-
# Converts RDoc definition-list code blocks into Markdown lists
|
|
155
|
+
# Converts RDoc definition-list code blocks into Markdown lists and separates
|
|
156
|
+
# raw HTML lists from following Markdown without rewriting fenced examples.
|
|
156
157
|
#
|
|
157
158
|
# @param markdown [String] Markdown content.
|
|
158
159
|
#
|
|
159
|
-
# @return [String] Markdown with
|
|
160
|
-
def
|
|
161
|
-
markdown.gsub(
|
|
160
|
+
# @return [String] Markdown with definition lists normalized.
|
|
161
|
+
def normalize_definition_lists(markdown)
|
|
162
|
+
markdown.gsub(%r{```[^\n]*\n(.+?)\n```|</dl>\n(?=\S)}m) do
|
|
162
163
|
body = Regexp.last_match(1)
|
|
164
|
+
next "</dl>\n\n" unless body
|
|
165
|
+
|
|
163
166
|
converted = convert_definition_list_block(body)
|
|
164
167
|
converted || Regexp.last_match
|
|
165
168
|
end
|
|
@@ -149,11 +149,13 @@ module RDoc::Generator::Markdown::Descriptions
|
|
|
149
149
|
# @param method [RDoc::AnyMethod] Target method.
|
|
150
150
|
# @param current_class [RDoc::Context] Class or module currently being rendered.
|
|
151
151
|
#
|
|
152
|
-
# @return [String, nil] Anchor or relative Markdown link target, or nil when the target page is omitted.
|
|
152
|
+
# @return [String, nil] Anchor or relative Markdown link target, or nil when the target method or page is omitted.
|
|
153
153
|
def method_link(method, current_class:)
|
|
154
154
|
return unless method.display?
|
|
155
155
|
|
|
156
156
|
target_parent = method.parent
|
|
157
|
+
return unless target_parent.method_list.include?(method)
|
|
158
|
+
|
|
157
159
|
target_path = generation_state.class_output_paths[target_parent.full_name]
|
|
158
160
|
return unless target_path
|
|
159
161
|
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
<%- group_heading_level = section_heading_level + 1 -%>
|
|
30
30
|
<%- member_heading_level = group_heading_level + 1 -%>
|
|
31
31
|
<%- unless section_title.empty? -%>
|
|
32
|
+
|
|
32
33
|
<%= "#" * section_heading_level %> <%= section_title %>
|
|
33
34
|
<%- end -%>
|
|
34
35
|
<%- section_description = section_description(section, heading_level_offset: section_heading_level) -%>
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
|
|
62
63
|
<%= "#" * group_heading_level %> <%= visibility.capitalize %> <%= type.capitalize %> Methods
|
|
63
64
|
<% methods.each do |method| -%>
|
|
65
|
+
|
|
64
66
|
<%= "#" * member_heading_level %> `<%= method_signature(method) %>`<%= anchor(method.aref) %>
|
|
65
67
|
<%= method_description(method, current_class: klass, heading_level_offset: member_heading_level) %>
|
|
66
68
|
<% end -%>
|