rdoc-markdown 0.21.1 → 0.22.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 +9 -0
- data/README.md +9 -16
- data/lib/rdoc/discover.rb +3 -1
- data/lib/rdoc/generator/markdown/blocks.rb +268 -0
- data/lib/rdoc/generator/markdown/descriptions.rb +36 -60
- data/lib/rdoc/generator/markdown/formatter.rb +44 -0
- data/lib/rdoc/generator/markdown/html_input.rb +126 -0
- data/lib/rdoc/generator/markdown/index.rb +4 -4
- data/lib/rdoc/generator/markdown/inline.rb +173 -0
- data/lib/rdoc/generator/markdown/inline_html.rb +56 -0
- data/lib/rdoc/generator/markdown/markdown_links.rb +101 -0
- data/lib/rdoc/generator/markdown/paths.rb +10 -41
- data/lib/rdoc/generator/markdown/references.rb +164 -0
- data/lib/rdoc/generator/markdown/signatures.rb +10 -74
- data/lib/rdoc/generator/markdown/syntax.rb +135 -0
- data/lib/rdoc/generator/markdown.rb +28 -46
- data/lib/rdoc/markdown/version.rb +1 -1
- data/lib/templates/classfile.md.erb +10 -5
- metadata +19 -42
- data/lib/markdown.rb +0 -3
- data/lib/rdoc/generator/markdown/conversion.rb +0 -200
- data/lib/rdoc/generator/markdown/crossref.rb +0 -41
|
@@ -7,17 +7,6 @@ module RDoc::Generator::Markdown::Signatures
|
|
|
7
7
|
"(" => ")", "[" => "]", "{" => "}"
|
|
8
8
|
}.freeze
|
|
9
9
|
|
|
10
|
-
# Builds the visible method signature used in headings.
|
|
11
|
-
#
|
|
12
|
-
# @param method [RDoc::AnyMethod] Method object to render.
|
|
13
|
-
#
|
|
14
|
-
# @return [String] Complete signature including the method name or documented receiver.
|
|
15
|
-
def method_signature(method)
|
|
16
|
-
RDoc::Generator::Markdown::Signatures.render_method_signature(method, store)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private :method_signature
|
|
20
|
-
|
|
21
10
|
# Builds a complete method heading signature from RDoc and store metadata.
|
|
22
11
|
#
|
|
23
12
|
# @param method [RDoc::AnyMethod] Method object to render.
|
|
@@ -25,8 +14,9 @@ module RDoc::Generator::Markdown::Signatures
|
|
|
25
14
|
#
|
|
26
15
|
# @return [String] Complete signature including the method name or documented receiver.
|
|
27
16
|
def self.render_method_signature(method, store)
|
|
17
|
+
name = method.name
|
|
28
18
|
signatures = method.type_signature_lines || store.rbs_signature_for(method)
|
|
29
|
-
if !signatures && (call_seq =
|
|
19
|
+
if !signatures && ["[]", "[]="].include?(name) && (call_seq = method.call_seq)
|
|
30
20
|
return call_seq.lines.map { |line| normalize_signature(line) }.join(" | ")
|
|
31
21
|
end
|
|
32
22
|
signatures ||= [method.param_seq]
|
|
@@ -39,17 +29,7 @@ module RDoc::Generator::Markdown::Signatures
|
|
|
39
29
|
merge_method_signature_arguments(signature, method.params)
|
|
40
30
|
end
|
|
41
31
|
|
|
42
|
-
|
|
43
|
-
"#{method.name}#{signature}"
|
|
44
|
-
end
|
|
45
|
-
|
|
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)
|
|
32
|
+
"#{name}#{signatures.empty? ? "()" : signatures.join(" | ")}"
|
|
53
33
|
end
|
|
54
34
|
|
|
55
35
|
# Normalizes spacing in a signature without changing its call syntax.
|
|
@@ -68,7 +48,8 @@ module RDoc::Generator::Markdown::Signatures
|
|
|
68
48
|
#
|
|
69
49
|
# @return [String] Signature with names added when safe.
|
|
70
50
|
def self.merge_method_signature_arguments(signature, raw_params)
|
|
71
|
-
params =
|
|
51
|
+
params = raw_params.to_s.strip
|
|
52
|
+
params = params[1...-1] if params.start_with?("(") && params.end_with?(")")
|
|
72
53
|
|
|
73
54
|
signature_args, signature_suffix = split_signature_arguments_and_suffix(signature)
|
|
74
55
|
return signature unless signature_args
|
|
@@ -77,21 +58,18 @@ module RDoc::Generator::Markdown::Signatures
|
|
|
77
58
|
signature_parts = split_signature_list(signature_args)
|
|
78
59
|
return signature unless param_parts.length.eql?(signature_parts.length)
|
|
79
60
|
|
|
80
|
-
|
|
81
|
-
merged || signature
|
|
61
|
+
merged_signature(param_parts, signature_parts, signature_suffix) || signature
|
|
82
62
|
end
|
|
83
63
|
|
|
84
|
-
# Merges matching parameter and
|
|
85
|
-
#
|
|
64
|
+
# Merges matching parameter and type fragments only when names can be inferred.
|
|
86
65
|
# @param param_parts [Array<String>] RDoc parameter fragments.
|
|
87
66
|
# @param signature_parts [Array<String>] Signature type fragments.
|
|
88
67
|
# @param signature_suffix [String] Text following the argument list.
|
|
89
|
-
#
|
|
90
68
|
# @return [String, nil] Merged signature, or nil when merging is unsafe or unnecessary.
|
|
91
69
|
def self.merged_signature(param_parts, signature_parts, signature_suffix)
|
|
92
|
-
param_names = param_parts.map { |part|
|
|
70
|
+
param_names = param_parts.map { |part| part[/\A(?:\*\*|\*|&)?([a-z_]\w*):?\z/, 1] }
|
|
93
71
|
return if param_names.any?(&:nil?)
|
|
94
|
-
return if signature_parts.zip(param_names).all? { |part, name|
|
|
72
|
+
return if signature_parts.zip(param_names).all? { |part, name| part.match?(/(?<!\w)#{name}(?!\w)/) }
|
|
95
73
|
|
|
96
74
|
merged_args = param_parts.zip(signature_parts).map do |param, type|
|
|
97
75
|
separator = param.end_with?(":") ? " " : ": "
|
|
@@ -101,18 +79,6 @@ module RDoc::Generator::Markdown::Signatures
|
|
|
101
79
|
"(#{merged_args.join(", ")})#{signature_suffix}"
|
|
102
80
|
end
|
|
103
81
|
|
|
104
|
-
# Normalizes RDoc's raw parameter string.
|
|
105
|
-
#
|
|
106
|
-
# @param raw_params [String, nil] Parameter list from RDoc.
|
|
107
|
-
#
|
|
108
|
-
# @return [String] Parameter list without outer parentheses.
|
|
109
|
-
def self.normalized_method_params(raw_params)
|
|
110
|
-
params = raw_params.to_s.strip
|
|
111
|
-
params = params[1...-1] if params.start_with?("(") && params.end_with?(")")
|
|
112
|
-
|
|
113
|
-
params
|
|
114
|
-
end
|
|
115
|
-
|
|
116
82
|
# Splits a parenthesized signature into arguments and suffix.
|
|
117
83
|
#
|
|
118
84
|
# @param signature [String] Method signature.
|
|
@@ -144,7 +110,7 @@ module RDoc::Generator::Markdown::Signatures
|
|
|
144
110
|
delimiters = []
|
|
145
111
|
|
|
146
112
|
list.each_char do |char|
|
|
147
|
-
if
|
|
113
|
+
if char == "," && delimiters.empty?
|
|
148
114
|
parts << current.strip
|
|
149
115
|
current.clear
|
|
150
116
|
else
|
|
@@ -161,34 +127,4 @@ module RDoc::Generator::Markdown::Signatures
|
|
|
161
127
|
parts << current.strip unless current.empty?
|
|
162
128
|
parts
|
|
163
129
|
end
|
|
164
|
-
|
|
165
|
-
# Checks whether a character separates top-level signature parts.
|
|
166
|
-
#
|
|
167
|
-
# @param char [String] Current signature character.
|
|
168
|
-
# @param delimiters [Array<String>] Expected closing delimiters.
|
|
169
|
-
#
|
|
170
|
-
# @return [Boolean] Whether the character is a top-level comma.
|
|
171
|
-
def self.top_level_signature_separator?(char, delimiters)
|
|
172
|
-
char == "," && delimiters.empty?
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
# Extracts a bare Ruby parameter name from a parameter fragment.
|
|
176
|
-
#
|
|
177
|
-
# @param parameter [String] Parameter fragment.
|
|
178
|
-
#
|
|
179
|
-
# @return [String, nil] Parameter name, or nil when invalid.
|
|
180
|
-
def self.extract_parameter_name(parameter)
|
|
181
|
-
match = parameter.match(/\A(?:\*\*|\*|&)?([a-z_]\w*):?\z/)
|
|
182
|
-
match && match[1]
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
# Checks whether a signature fragment already includes a parameter name.
|
|
186
|
-
#
|
|
187
|
-
# @param text [String] Signature fragment.
|
|
188
|
-
# @param name [String] Parameter name.
|
|
189
|
-
#
|
|
190
|
-
# @return [Boolean] True when the name appears as a standalone word.
|
|
191
|
-
def self.signature_part_mentions_name?(text, name)
|
|
192
|
-
text.match?(/(?<!\w)#{name}(?!\w)/)
|
|
193
|
-
end
|
|
194
130
|
end
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "cgi"
|
|
4
|
+
|
|
5
|
+
# Small GFM primitives shared by native markup and the HTML input boundary.
|
|
6
|
+
module RDoc::Generator::Markdown::Syntax
|
|
7
|
+
# Maps Commonmarker's one-based UTF-8 byte columns to Ruby byte ranges.
|
|
8
|
+
# @param node [Commonmarker::Node] Parsed node with source positions.
|
|
9
|
+
# @param offsets [Array<Integer>] Byte offset of each source line.
|
|
10
|
+
# @return [Range<Integer>] Half-open source byte range.
|
|
11
|
+
def self.source_range(node, offsets)
|
|
12
|
+
start_line, start_column, end_line, end_column = node.source_position.fetch_values(:start_line, :start_column, :end_line, :end_column)
|
|
13
|
+
first = offsets.fetch(start_line - 1) + start_column - 1
|
|
14
|
+
last = offsets.fetch(end_line - 1) + end_column
|
|
15
|
+
first...last
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Uses RDoc's code-tag and escape rules to identify literal native source.
|
|
19
|
+
# @param text [String] Original inline source.
|
|
20
|
+
# @return [Array<Range<Integer>>] Literal native source byte ranges.
|
|
21
|
+
def self.native_literal_ranges(text)
|
|
22
|
+
ranges = []
|
|
23
|
+
text.b.scan(/\\[\\*_+`{}\[\]<>]|<(code|tt)>(?:\\.|[^\\])*?<\/\1>/) do
|
|
24
|
+
ranges << Range.new(*Regexp.last_match.offset(0), true)
|
|
25
|
+
end
|
|
26
|
+
ranges
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Protects native code tags and Markdown code spans during prose cleanup.
|
|
30
|
+
# @param text [String] Inline source encoded as UTF-8.
|
|
31
|
+
# @return [Array<Range<Integer>>] Literal source byte ranges.
|
|
32
|
+
def self.code_ranges(text)
|
|
33
|
+
offsets = [0]
|
|
34
|
+
text.each_line { |line| offsets << offsets.last + line.bytesize }
|
|
35
|
+
ranges = native_literal_ranges(text)
|
|
36
|
+
Commonmarker.parse(text).walk do |node|
|
|
37
|
+
ranges << source_range(node, offsets) if node.type == :code
|
|
38
|
+
end
|
|
39
|
+
ranges
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Checks a byte position against protected source spans.
|
|
43
|
+
# @param ranges [Array<Range<Integer>>] Literal source ranges.
|
|
44
|
+
# @param position [Integer] Source byte offset.
|
|
45
|
+
# @return [Boolean] Whether the position is inside literal content.
|
|
46
|
+
def self.literal_position?(ranges, position)
|
|
47
|
+
ranges.any? { |range| range.cover?(position) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Collects visible inline text without rendering Markdown through HTML.
|
|
51
|
+
# @param node [Commonmarker::Node] Parsed heading or image label.
|
|
52
|
+
# @return [String] Plain visible text, including soft and hard breaks.
|
|
53
|
+
def self.node_text(node)
|
|
54
|
+
text = +""
|
|
55
|
+
node.walk do |child|
|
|
56
|
+
case child.type
|
|
57
|
+
when :text, :code then text << child.string_content
|
|
58
|
+
when :softbreak, :linebreak then text << " "
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
text
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Escapes prose while retaining main's Markdown escape for semicolons.
|
|
65
|
+
# @param text [String] Literal prose, including block-looking definition terms.
|
|
66
|
+
# @return [String] Safe Markdown text.
|
|
67
|
+
def self.escape(text)
|
|
68
|
+
text.gsub(/[ \t]+/, " ").gsub(/[&`*_\[\]<>#]|\\(?!;)/) { |character| (character == "&") ? "&" : "\\#{character}" }
|
|
69
|
+
.sub(/\A(\d+)\.(?=\s)/, '\1\\.')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Wraps literal code with a delimiter that cannot occur in its contents.
|
|
73
|
+
# @param text [String] Literal code.
|
|
74
|
+
# @return [String] Native code span.
|
|
75
|
+
def self.code(text)
|
|
76
|
+
return "<code></code>" if text.empty?
|
|
77
|
+
|
|
78
|
+
fence = ""
|
|
79
|
+
fence += "`" while text.include?(fence)
|
|
80
|
+
content = (text.start_with?("`") || text.end_with?("`")) ? " #{text} " : text
|
|
81
|
+
"#{fence}#{content}#{fence}"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Emits fenced code without interpreting its contents as prose.
|
|
85
|
+
# @param text [String] Literal code.
|
|
86
|
+
# @param language [String, Symbol, nil] Optional language metadata.
|
|
87
|
+
# @return [String] Fenced code block.
|
|
88
|
+
def self.code_block(text, language)
|
|
89
|
+
fence = "```"
|
|
90
|
+
fence += "`" while text.include?(fence)
|
|
91
|
+
"#{fence}#{language}\n#{text.rstrip}\n#{fence}"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Emits an explicit, attribute-safe heading alias.
|
|
95
|
+
# @param id [String] Fragment identifier.
|
|
96
|
+
# @return [String] Empty HTML anchor.
|
|
97
|
+
def self.anchor(id)
|
|
98
|
+
%(<a id="#{CGI.escapeHTML(id)}"></a>)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Formats a GFM heading and its explicit aliases.
|
|
102
|
+
# @param level [Integer] Requested heading level.
|
|
103
|
+
# @param text [String] Native inline Markdown.
|
|
104
|
+
# @param aliases [Array<String>] Additional heading IDs.
|
|
105
|
+
# @return [String] Heading capped at level six.
|
|
106
|
+
def self.heading(level, text, aliases)
|
|
107
|
+
"#{"#" * [level, 6].min} #{text}#{aliases.map { |id| anchor(id) }.join}"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Maps legacy local HTML targets while preserving external URLs and fragments.
|
|
111
|
+
# @param href [String] Original target.
|
|
112
|
+
# @return [String] Markdown target.
|
|
113
|
+
def self.target(href)
|
|
114
|
+
return "https://#{href}" if href.start_with?("www.")
|
|
115
|
+
return href if href.match?(/\A(?:https?:\/\/|mailto:|#)/i)
|
|
116
|
+
|
|
117
|
+
href.sub(/\.html(?=[?#]|\z)/i, ".md")
|
|
118
|
+
.sub(%r{\A/(?=.+\.md(?:[?#]|\z))}, "")
|
|
119
|
+
.sub(%r{\A((?:\.\./)*)(?:files|classes|modules)/(?=.+\.md(?:[?#]|\z))}, '\1')
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Emits a link, restoring Ruby indexing expressions misparsed as tidy links.
|
|
123
|
+
# @param label [String] Native inline Markdown label.
|
|
124
|
+
# @param href [String] Original target.
|
|
125
|
+
# @return [String] Markdown link or literal code span.
|
|
126
|
+
def self.link(label, href)
|
|
127
|
+
receiver = label.delete("\\")
|
|
128
|
+
if receiver.match?(/\A(?:[A-Z][A-Za-z0-9_]*(?:::[A-Z][A-Za-z0-9_]*)*|[a-z_][A-Za-z0-9_]*)\z/) &&
|
|
129
|
+
href.match?(/\A(?::.+|".+")\z/)
|
|
130
|
+
code("#{receiver}[#{href}]")
|
|
131
|
+
else
|
|
132
|
+
"[#{label}](#{target(href)})"
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "erb"
|
|
4
|
-
|
|
5
|
-
require "set"
|
|
6
|
-
# standard:enable Lint/RedundantRequireStatement
|
|
7
|
-
require "reverse_markdown"
|
|
4
|
+
require "nokogiri"
|
|
8
5
|
require "csv"
|
|
9
6
|
require "fileutils"
|
|
10
7
|
|
|
@@ -12,9 +9,11 @@ require "fileutils"
|
|
|
12
9
|
class RDoc::Generator::Markdown
|
|
13
10
|
RDoc::RDoc.add_generator self
|
|
14
11
|
|
|
15
|
-
require_relative "markdown/
|
|
16
|
-
require_relative "markdown/
|
|
12
|
+
require_relative "markdown/syntax"
|
|
13
|
+
require_relative "markdown/references"
|
|
14
|
+
require_relative "markdown/html_input"
|
|
17
15
|
require_relative "markdown/descriptions"
|
|
16
|
+
require_relative "markdown/formatter"
|
|
18
17
|
require_relative "markdown/index"
|
|
19
18
|
require_relative "markdown/paths"
|
|
20
19
|
require_relative "markdown/selection"
|
|
@@ -23,14 +22,12 @@ class RDoc::Generator::Markdown
|
|
|
23
22
|
include Descriptions
|
|
24
23
|
include Index
|
|
25
24
|
include Paths
|
|
26
|
-
include Signatures
|
|
27
25
|
|
|
28
26
|
# Directory containing ERB templates.
|
|
29
27
|
TEMPLATE_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "templates"))
|
|
30
28
|
|
|
31
29
|
# Prepared objects and lookup tables used during one generation run.
|
|
32
30
|
GenerationState = Data.define(
|
|
33
|
-
:output_dir,
|
|
34
31
|
:classes,
|
|
35
32
|
:pages,
|
|
36
33
|
:class_output_paths,
|
|
@@ -44,20 +41,6 @@ class RDoc::Generator::Markdown
|
|
|
44
41
|
# @return [RDoc::Store]
|
|
45
42
|
attr_reader :store
|
|
46
43
|
|
|
47
|
-
# Classes and modules selected for output.
|
|
48
|
-
#
|
|
49
|
-
# @return [Array<RDoc::Context>, nil]
|
|
50
|
-
def classes
|
|
51
|
-
generation_state&.classes
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Text files selected for output.
|
|
55
|
-
#
|
|
56
|
-
# @return [Array<RDoc::TopLevel>, nil]
|
|
57
|
-
def pages
|
|
58
|
-
generation_state&.pages
|
|
59
|
-
end
|
|
60
|
-
|
|
61
44
|
# Creates a generator for an RDoc store and options.
|
|
62
45
|
#
|
|
63
46
|
# @param store [RDoc::Store] Source documentation store.
|
|
@@ -87,28 +70,35 @@ class RDoc::Generator::Markdown
|
|
|
87
70
|
|
|
88
71
|
private
|
|
89
72
|
|
|
90
|
-
attr_reader :generation_state, :options, :source_dir
|
|
73
|
+
attr_reader :generation_state, :options, :source_dir, :output_dir
|
|
91
74
|
|
|
92
|
-
#
|
|
75
|
+
# Classes and modules selected for output.
|
|
93
76
|
#
|
|
94
|
-
# @
|
|
77
|
+
# @return [Array<RDoc::Context>]
|
|
78
|
+
def classes
|
|
79
|
+
generation_state.classes
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Text files selected for output.
|
|
95
83
|
#
|
|
96
|
-
# @return [
|
|
97
|
-
def
|
|
98
|
-
|
|
84
|
+
# @return [Array<RDoc::TopLevel>]
|
|
85
|
+
def pages
|
|
86
|
+
generation_state.pages
|
|
99
87
|
end
|
|
100
88
|
|
|
101
89
|
# Applies final whitespace and link normalization before writing Markdown.
|
|
90
|
+
# Blank-line cleanup skips code: a fence is longer than any backtick run it contains.
|
|
102
91
|
#
|
|
103
92
|
# @param content [String] Markdown content.
|
|
104
93
|
# @param current_output_path [String] Output path for the file being written.
|
|
105
94
|
#
|
|
106
95
|
# @return [String] Final Markdown ending with one newline.
|
|
107
96
|
def finalize_markdown(content, current_output_path:)
|
|
108
|
-
normalized =
|
|
97
|
+
normalized = Paths.rewrite_internal_links(
|
|
109
98
|
content.lines.map(&:rstrip).join("\n"),
|
|
110
|
-
current_output_path
|
|
111
|
-
).
|
|
99
|
+
current_output_path, generation_state
|
|
100
|
+
).gsub(/(`{3,}).+?\1|\n{3,}/m) { ($1) ? $& : "\n\n" }
|
|
101
|
+
.gsub(/(`{3,}).+?\1|^(#+ [^\n]+)\n\n/m) { ($2) ? "#{$2}\n" : $& }
|
|
112
102
|
"#{normalized}\n"
|
|
113
103
|
end
|
|
114
104
|
|
|
@@ -153,7 +143,7 @@ class RDoc::Generator::Markdown
|
|
|
153
143
|
|
|
154
144
|
next FileUtils.cp(File.expand_path(page.absolute_name, source_dir), out_file) if page.relative_name.match?(/\.(?:md|markdown)\z/i)
|
|
155
145
|
|
|
156
|
-
content =
|
|
146
|
+
content = describe(page)
|
|
157
147
|
File.write(out_file, finalize_markdown(content, current_output_path: output_path))
|
|
158
148
|
end
|
|
159
149
|
end
|
|
@@ -162,30 +152,22 @@ class RDoc::Generator::Markdown
|
|
|
162
152
|
#
|
|
163
153
|
# @return [void]
|
|
164
154
|
def setup
|
|
165
|
-
output_dir = options.op_dir
|
|
166
|
-
unless output_dir.instance_of?(String)
|
|
167
|
-
raise TypeError, "RDoc markdown output directory must be a String"
|
|
168
|
-
end
|
|
169
|
-
|
|
170
155
|
classes = Selection.classes(store)
|
|
171
156
|
class_output_paths = classes.to_h { |klass| [klass.full_name, output_path_for(klass)] }
|
|
172
157
|
pages = Selection.pages(store)
|
|
158
|
+
known_output_paths = Set.new
|
|
159
|
+
(class_output_paths.values + pages.map { |page| page_output_path(page) }).each do |path|
|
|
160
|
+
warn "rdoc-markdown: several inputs write #{path}; only the last one is kept" unless known_output_paths.add?(path)
|
|
161
|
+
end
|
|
173
162
|
|
|
163
|
+
@output_dir = options.op_dir
|
|
174
164
|
@generation_state = GenerationState.new(
|
|
175
|
-
output_dir: output_dir,
|
|
176
165
|
classes: classes,
|
|
177
166
|
pages: pages,
|
|
178
167
|
class_output_paths: class_output_paths,
|
|
179
168
|
markdown_output_object_ids: (classes + pages).to_set(&:object_id),
|
|
180
|
-
known_output_paths:
|
|
169
|
+
known_output_paths: known_output_paths,
|
|
181
170
|
root_path_segment: Pathname.new(options.root || ".").basename
|
|
182
171
|
)
|
|
183
172
|
end
|
|
184
|
-
|
|
185
|
-
# Returns the prepared output directory.
|
|
186
|
-
#
|
|
187
|
-
# @return [String] Output directory.
|
|
188
|
-
def output_dir
|
|
189
|
-
generation_state.output_dir
|
|
190
|
-
end
|
|
191
173
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# <%= klass.type.capitalize %> <%= klass.full_name %><%= anchor(klass.aref.strip) %>
|
|
1
|
+
# <%= klass.type.capitalize %> <%= klass.full_name %><%= Syntax.anchor(klass.aref.strip) %>
|
|
2
2
|
<%- superclass = klass.superclass if klass.type == "class" -%>
|
|
3
3
|
<%- includes = klass.includes -%>
|
|
4
4
|
<%- source_files = klass.in_files -%>
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
<%= "#" * section_heading_level %> <%= section_title %>
|
|
34
34
|
<%- end -%>
|
|
35
|
-
<%- section_description =
|
|
35
|
+
<%- section_description = render_description(section, heading_level_offset: section_heading_level) -%>
|
|
36
36
|
<%- unless section_description.empty? -%>
|
|
37
37
|
|
|
38
38
|
<%= section_description %>
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
<%= "#" * group_heading_level %> Constants
|
|
43
43
|
<% constants.sort_by(&:name).each do |const| -%>
|
|
44
44
|
|
|
45
|
-
<%= "#" * member_heading_level %> `<%= const.name %>`<%= anchor(const.name) %>
|
|
45
|
+
<%= "#" * member_heading_level %> `<%= const.name %>`<%= Syntax.anchor(const.name) %>
|
|
46
46
|
<%= describe(const, fallback: "Not documented.", heading_level_offset: member_heading_level) %>
|
|
47
47
|
<% end -%>
|
|
48
48
|
<%- end -%>
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
<%= "#" * group_heading_level %> Attributes
|
|
52
52
|
<% attributes.sort_by(&:name).each do |attr| -%>
|
|
53
53
|
|
|
54
|
-
<%= "#" * member_heading_level %> `<%= attr.name %>` [<%= attr.rw %>]<%= anchor(attr.aref.strip) %>
|
|
54
|
+
<%= "#" * member_heading_level %> `<%= attr.name %>` [<%= attr.rw %>]<%= Syntax.anchor(attr.aref.strip) %>
|
|
55
55
|
<%= describe(attr, fallback: "Not documented.", heading_level_offset: member_heading_level) %>
|
|
56
56
|
<% end -%>
|
|
57
57
|
<%- end -%>
|
|
@@ -63,7 +63,12 @@
|
|
|
63
63
|
<%= "#" * group_heading_level %> <%= visibility.capitalize %> <%= type.capitalize %> Methods
|
|
64
64
|
<% methods.each do |method| -%>
|
|
65
65
|
|
|
66
|
-
<%= "#" * member_heading_level %>
|
|
66
|
+
<%= "#" * member_heading_level %> <%= Syntax.code(Signatures.render_method_signature(method, store)) %><%= Syntax.anchor(method.aref) %>
|
|
67
|
+
<%- aliases = method_aliases(method) -%>
|
|
68
|
+
<%- if aliases -%>
|
|
69
|
+
<%= aliases %>
|
|
70
|
+
|
|
71
|
+
<%- end -%>
|
|
67
72
|
<%= method_description(method, current_class: klass, heading_level_offset: member_heading_level) %>
|
|
68
73
|
<% end -%>
|
|
69
74
|
<% 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.
|
|
4
|
+
version: 0.22.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stanislav (Stas) Katkov
|
|
@@ -52,7 +52,7 @@ dependencies:
|
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: '8.0'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
|
-
name:
|
|
55
|
+
name: nokogiri
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - ">="
|
|
@@ -65,34 +65,20 @@ dependencies:
|
|
|
65
65
|
- - ">="
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
67
|
version: '0'
|
|
68
|
-
- !ruby/object:Gem::Dependency
|
|
69
|
-
name: bundler
|
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
|
71
|
-
requirements:
|
|
72
|
-
- - ">="
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: '2.0'
|
|
75
|
-
type: :development
|
|
76
|
-
prerelease: false
|
|
77
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - ">="
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: '2.0'
|
|
82
68
|
- !ruby/object:Gem::Dependency
|
|
83
69
|
name: commonmarker
|
|
84
70
|
requirement: !ruby/object:Gem::Requirement
|
|
85
71
|
requirements:
|
|
86
|
-
- - "
|
|
72
|
+
- - "~>"
|
|
87
73
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
89
|
-
type: :
|
|
74
|
+
version: '2.8'
|
|
75
|
+
type: :runtime
|
|
90
76
|
prerelease: false
|
|
91
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
78
|
requirements:
|
|
93
|
-
- - "
|
|
79
|
+
- - "~>"
|
|
94
80
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '
|
|
81
|
+
version: '2.8'
|
|
96
82
|
- !ruby/object:Gem::Dependency
|
|
97
83
|
name: minitest
|
|
98
84
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -149,22 +135,8 @@ dependencies:
|
|
|
149
135
|
- - ">="
|
|
150
136
|
- !ruby/object:Gem::Version
|
|
151
137
|
version: '0'
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
requirement: !ruby/object:Gem::Requirement
|
|
155
|
-
requirements:
|
|
156
|
-
- - ">="
|
|
157
|
-
- !ruby/object:Gem::Version
|
|
158
|
-
version: '0'
|
|
159
|
-
type: :development
|
|
160
|
-
prerelease: false
|
|
161
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
162
|
-
requirements:
|
|
163
|
-
- - ">="
|
|
164
|
-
- !ruby/object:Gem::Version
|
|
165
|
-
version: '0'
|
|
166
|
-
description: RDoc plugin to generate markdown documentation and search index as sqlite
|
|
167
|
-
database for entire content.
|
|
138
|
+
description: RDoc plugin to generate markdown documentation and a CSV search index
|
|
139
|
+
for its entire content.
|
|
168
140
|
email:
|
|
169
141
|
- github@skatkov.com
|
|
170
142
|
executables: []
|
|
@@ -174,16 +146,21 @@ files:
|
|
|
174
146
|
- CHANGELOG.md
|
|
175
147
|
- LICENSE
|
|
176
148
|
- README.md
|
|
177
|
-
- lib/markdown.rb
|
|
178
149
|
- lib/rdoc/discover.rb
|
|
179
150
|
- lib/rdoc/generator/markdown.rb
|
|
180
|
-
- lib/rdoc/generator/markdown/
|
|
181
|
-
- lib/rdoc/generator/markdown/crossref.rb
|
|
151
|
+
- lib/rdoc/generator/markdown/blocks.rb
|
|
182
152
|
- lib/rdoc/generator/markdown/descriptions.rb
|
|
153
|
+
- lib/rdoc/generator/markdown/formatter.rb
|
|
154
|
+
- lib/rdoc/generator/markdown/html_input.rb
|
|
183
155
|
- lib/rdoc/generator/markdown/index.rb
|
|
156
|
+
- lib/rdoc/generator/markdown/inline.rb
|
|
157
|
+
- lib/rdoc/generator/markdown/inline_html.rb
|
|
158
|
+
- lib/rdoc/generator/markdown/markdown_links.rb
|
|
184
159
|
- lib/rdoc/generator/markdown/paths.rb
|
|
160
|
+
- lib/rdoc/generator/markdown/references.rb
|
|
185
161
|
- lib/rdoc/generator/markdown/selection.rb
|
|
186
162
|
- lib/rdoc/generator/markdown/signatures.rb
|
|
163
|
+
- lib/rdoc/generator/markdown/syntax.rb
|
|
187
164
|
- lib/rdoc/markdown/version.rb
|
|
188
165
|
- lib/templates/classfile.md.erb
|
|
189
166
|
- sig/rdoc/markdown.rbs
|
|
@@ -193,7 +170,7 @@ licenses:
|
|
|
193
170
|
metadata:
|
|
194
171
|
homepage_uri: https://poshtui.com
|
|
195
172
|
source_code_uri: https://github.com/skatkov/rdoc-markdown
|
|
196
|
-
changelog_uri: https://github.com/skatkov/rdoc-markdown
|
|
173
|
+
changelog_uri: https://github.com/skatkov/rdoc-markdown/blob/main/CHANGELOG.md
|
|
197
174
|
rdoc_options: []
|
|
198
175
|
require_paths:
|
|
199
176
|
- lib
|
|
@@ -208,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
208
185
|
- !ruby/object:Gem::Version
|
|
209
186
|
version: '0'
|
|
210
187
|
requirements: []
|
|
211
|
-
rubygems_version: 4.0.
|
|
188
|
+
rubygems_version: 4.0.20
|
|
212
189
|
specification_version: 4
|
|
213
190
|
summary: RDoc plugin to generate markdown documentation
|
|
214
191
|
test_files: []
|
data/lib/markdown.rb
DELETED