rdoc-markdown 0.21.0 → 0.21.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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +1 -8
- data/lib/rdoc/generator/markdown/conversion.rb +9 -8
- data/lib/rdoc/generator/markdown/index.rb +2 -1
- data/lib/rdoc/markdown/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: feb14b11dc71c71a4e9e0af4a71f6d074706120984b7b5c6c890c126e8894e23
|
|
4
|
+
data.tar.gz: ea5b339442fe650abae65db6f5ce051a959c361056b651cde5fb7ae2b1daf778
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c0a5a47ff262d233b3bebb8f2016f1f31f3a0ce106ce3d25e68f46251bed353cc5df1a26e4534a9e92159e9ee458965d0864b91f94f4c48100f4f54d012824ce
|
|
7
|
+
data.tar.gz: a95167a0eed14716ce4014cd6330c73cb546fa45a553f747e883b64f7614c54638656ce6ce76a95bc6e64ae9f9f8051ceabcfd02c30c060e8d0aa1a94aa8ac85
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.21.2
|
|
6
|
+
|
|
7
|
+
- Distinguish instance methods (`Class#method`) from class methods (`Class.method`) in search-index names, without changing their document paths or anchors.
|
|
8
|
+
|
|
9
|
+
## 0.21.1
|
|
10
|
+
|
|
11
|
+
- Preserve hash-prefixed comments and literal Markdown headings in code examples when offsetting documentation headings.
|
|
12
|
+
|
|
13
|
+
## 0.21.0
|
|
5
14
|
- Keep generated method and section headings readable after raw HTML descriptions.
|
|
6
15
|
- Validate search-index targets and same-document links against parsed Markdown headings and anchors, including alias targets.
|
|
7
16
|
- Leave alias targets unlinked when RDoc has removed the canonical method from the generated documentation.
|
data/README.md
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
# RDoc-Markdown
|
|
2
2
|
RDoc plugin to generate markdown documentation and search index file (CSV).
|
|
3
3
|
|
|
4
|
-
> [!CAUTION]
|
|
5
|
-
> This gem relies on multiple hacks to generate "plausible" markdown documentation. This is **NOT PRODUCTION READY** — use at your own risk.
|
|
6
|
-
>
|
|
7
|
-
> RDoc maintainers are actively working on markdown support, things will improve with time...
|
|
8
|
-
|
|
9
4
|
## Motivation
|
|
10
|
-
Markdown has become the de facto documentation standard.
|
|
11
|
-
|
|
12
|
-
It's a pity that RDoc can't output a proper markdown file. Somebody has to try to build it.
|
|
5
|
+
Markdown has become the de facto documentation standard. Rdoc should be able to output it too.
|
|
13
6
|
|
|
14
7
|
## Installation
|
|
15
8
|
|
|
@@ -9,15 +9,13 @@ class RDoc::Generator::Markdown::Conversion
|
|
|
9
9
|
#
|
|
10
10
|
# @return [String] Markdown with normalized links and no trailing whitespace.
|
|
11
11
|
def self.markdownify(input, heading_level_offset: 0)
|
|
12
|
-
fragment = normalized_html_fragment(input)
|
|
12
|
+
fragment = normalized_html_fragment(input, heading_level_offset)
|
|
13
13
|
anchor_aliases = tokenize_legacy_anchors(fragment.css("span.legacy-anchor[id]"))
|
|
14
14
|
document = fragment.document
|
|
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
|
-
normalize_definition_lists(markdown).rstrip
|
|
19
|
-
"#{"#" * [Regexp.last_match(1).length + heading_level_offset, 6].min}#{Regexp.last_match(2)}"
|
|
20
|
-
end
|
|
18
|
+
normalize_definition_lists(markdown).rstrip
|
|
21
19
|
end
|
|
22
20
|
|
|
23
21
|
class << self
|
|
@@ -26,9 +24,10 @@ class RDoc::Generator::Markdown::Conversion
|
|
|
26
24
|
# Normalizes HTML constructs that reverse_markdown cannot preserve directly.
|
|
27
25
|
#
|
|
28
26
|
# @param input [String] RDoc HTML fragment.
|
|
27
|
+
# @param heading_level_offset [Integer] Heading levels to add to actual HTML headings.
|
|
29
28
|
#
|
|
30
29
|
# @return [Nokogiri::HTML4::DocumentFragment] Normalized fragment.
|
|
31
|
-
def normalized_html_fragment(input)
|
|
30
|
+
def normalized_html_fragment(input, heading_level_offset)
|
|
32
31
|
fragment = Nokogiri::HTML.fragment(input)
|
|
33
32
|
context_anchors, content_anchors = fragment.css("span.legacy-anchor[id]").partition do |span|
|
|
34
33
|
context_anchor?(span)
|
|
@@ -41,7 +40,7 @@ class RDoc::Generator::Markdown::Conversion
|
|
|
41
40
|
normalize_pre_blocks(fragment)
|
|
42
41
|
document = fragment.document
|
|
43
42
|
fragment.css("h1, h2, h3, h4, h5, h6").each do |heading|
|
|
44
|
-
|
|
43
|
+
normalize_heading(heading, document, heading_level_offset)
|
|
45
44
|
end
|
|
46
45
|
fragment
|
|
47
46
|
end
|
|
@@ -68,13 +67,15 @@ class RDoc::Generator::Markdown::Conversion
|
|
|
68
67
|
end
|
|
69
68
|
end
|
|
70
69
|
|
|
71
|
-
# Normalizes one heading's leading fragment link.
|
|
70
|
+
# Normalizes one heading's level and leading fragment link.
|
|
72
71
|
#
|
|
73
72
|
# @param heading [Nokogiri::XML::Element] Heading element.
|
|
74
73
|
# @param document [Nokogiri::HTML4::Document] Owning document.
|
|
74
|
+
# @param heading_level_offset [Integer] Heading levels to add, capped at six.
|
|
75
75
|
#
|
|
76
76
|
# @return [void]
|
|
77
|
-
def
|
|
77
|
+
def normalize_heading(heading, document, heading_level_offset)
|
|
78
|
+
heading.name = "h#{[Integer(heading.name.delete_prefix("h")) + heading_level_offset, 6].min}"
|
|
78
79
|
link = heading.xpath("./a[starts-with(@href, '#') and string-length(@href) > 1]").find do |anchor|
|
|
79
80
|
leading_heading_link?(anchor)
|
|
80
81
|
end
|
|
@@ -34,7 +34,8 @@ module RDoc::Generator::Markdown::Index
|
|
|
34
34
|
csv << [class_name, klass.type.capitalize, output_path]
|
|
35
35
|
|
|
36
36
|
klass.method_list.select(&:display?).each do |method|
|
|
37
|
-
|
|
37
|
+
separator = method.singleton ? "." : "#"
|
|
38
|
+
csv << ["#{class_name}#{separator}#{method.name}", "Method", "#{output_path}##{method.aref}"]
|
|
38
39
|
end
|
|
39
40
|
klass.constants.select(&:display?).sort.each do |const|
|
|
40
41
|
name = const.name
|
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.21.
|
|
4
|
+
version: 0.21.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stanislav (Stas) Katkov
|
|
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
208
208
|
- !ruby/object:Gem::Version
|
|
209
209
|
version: '0'
|
|
210
210
|
requirements: []
|
|
211
|
-
rubygems_version: 4.0.
|
|
211
|
+
rubygems_version: 4.0.20
|
|
212
212
|
specification_version: 4
|
|
213
213
|
summary: RDoc plugin to generate markdown documentation
|
|
214
214
|
test_files: []
|