rdoc 7.2.0 → 8.0.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/CONTRIBUTING.md +3 -4
- data/LICENSE.rdoc +4 -0
- data/README.md +43 -2
- data/doc/markup_reference/markdown.md +104 -3
- data/lib/rdoc/code_object/alias.rb +2 -8
- data/lib/rdoc/code_object/any_method.rb +11 -6
- data/lib/rdoc/code_object/attr.rb +11 -6
- data/lib/rdoc/code_object/class_module.rb +62 -32
- data/lib/rdoc/code_object/constant.rb +29 -3
- data/lib/rdoc/code_object/context/section.rb +4 -35
- data/lib/rdoc/code_object/context.rb +39 -34
- data/lib/rdoc/code_object/method_attr.rb +9 -15
- data/lib/rdoc/code_object/mixin.rb +2 -2
- data/lib/rdoc/code_object/top_level.rb +9 -3
- data/lib/rdoc/code_object.rb +2 -4
- data/lib/rdoc/comment.rb +0 -65
- data/lib/rdoc/cross_reference.rb +7 -27
- data/lib/rdoc/encoding.rb +3 -3
- data/lib/rdoc/generator/aliki.rb +17 -0
- data/lib/rdoc/generator/darkfish.rb +12 -6
- data/lib/rdoc/generator/json_index.rb +2 -2
- data/lib/rdoc/generator/markup.rb +56 -31
- data/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
- data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_head.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +8 -6
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +8 -6
- data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +2 -2
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/class.rhtml +56 -46
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +337 -111
- data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/js/aliki.js +20 -18
- data/lib/rdoc/generator/template/aliki/page.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/class.rhtml +18 -21
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +0 -1
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
- data/lib/rdoc/i18n/text.rb +3 -3
- data/lib/rdoc/markdown.kpeg +15 -10
- data/lib/rdoc/markdown.rb +289 -104
- data/lib/rdoc/markup/document.rb +2 -2
- data/lib/rdoc/markup/formatter.rb +24 -34
- data/lib/rdoc/markup/heading.rb +1 -4
- data/lib/rdoc/markup/indented_paragraph.rb +1 -1
- data/lib/rdoc/markup/list.rb +2 -2
- data/lib/rdoc/markup/list_item.rb +2 -2
- data/lib/rdoc/markup/pre_process.rb +0 -25
- data/lib/rdoc/markup/to_ansi.rb +1 -1
- data/lib/rdoc/markup/to_bs.rb +1 -1
- data/lib/rdoc/markup/to_html.rb +131 -53
- data/lib/rdoc/markup/to_html_crossref.rb +97 -71
- data/lib/rdoc/markup/to_html_snippet.rb +5 -5
- data/lib/rdoc/markup/to_joined_paragraph.rb +0 -5
- data/lib/rdoc/markup/to_label.rb +2 -2
- data/lib/rdoc/markup/to_markdown.rb +1 -1
- data/lib/rdoc/markup/to_rdoc.rb +2 -2
- data/lib/rdoc/markup/to_table_of_contents.rb +1 -1
- data/lib/rdoc/markup/to_tt_only.rb +0 -7
- data/lib/rdoc/markup/verbatim.rb +1 -1
- data/lib/rdoc/options.rb +36 -51
- data/lib/rdoc/parser/c.rb +7 -6
- data/lib/rdoc/parser/rbs.rb +275 -0
- data/lib/rdoc/parser/ruby.rb +954 -2066
- data/lib/rdoc/parser/ruby_colorizer.rb +253 -0
- data/lib/rdoc/parser.rb +3 -2
- data/lib/rdoc/rbs_helper.rb +186 -0
- data/lib/rdoc/rdoc.rb +196 -24
- data/lib/rdoc/ri/driver.rb +8 -2
- data/lib/rdoc/ri/paths.rb +1 -1
- data/lib/rdoc/{servlet.rb → ri/servlet.rb} +5 -5
- data/lib/rdoc/ri.rb +4 -3
- data/lib/rdoc/rubygems_hook.rb +11 -11
- data/lib/rdoc/server.rb +460 -0
- data/lib/rdoc/stats.rb +147 -124
- data/lib/rdoc/store.rb +212 -4
- data/lib/rdoc/task.rb +16 -15
- data/lib/rdoc/text.rb +1 -118
- data/lib/rdoc/token_stream.rb +11 -33
- data/lib/rdoc/version.rb +1 -1
- data/lib/rdoc.rb +35 -7
- data/lib/rubygems_plugin.rb +2 -11
- data/rdoc-logo.svg +43 -0
- data/rdoc.gemspec +6 -4
- metadata +35 -18
- data/lib/rdoc/code_object/anon_class.rb +0 -10
- data/lib/rdoc/code_object/ghost_method.rb +0 -6
- data/lib/rdoc/code_object/meta_method.rb +0 -6
- data/lib/rdoc/parser/prism_ruby.rb +0 -1112
- data/lib/rdoc/parser/ripper_state_lex.rb +0 -302
- data/lib/rdoc/parser/ruby_tools.rb +0 -163
|
@@ -8,9 +8,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
|
8
8
|
|
|
9
9
|
# :stopdoc:
|
|
10
10
|
ALL_CROSSREF_REGEXP = RDoc::CrossReference::ALL_CROSSREF_REGEXP
|
|
11
|
-
CLASS_REGEXP_STR = RDoc::CrossReference::CLASS_REGEXP_STR
|
|
12
11
|
CROSSREF_REGEXP = RDoc::CrossReference::CROSSREF_REGEXP
|
|
13
|
-
METHOD_REGEXP_STR = RDoc::CrossReference::METHOD_REGEXP_STR
|
|
14
12
|
# :startdoc:
|
|
15
13
|
|
|
16
14
|
##
|
|
@@ -29,15 +27,19 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
|
29
27
|
# references are removed unless +show_hash+ is true. Only method names
|
|
30
28
|
# preceded by '#' or '::' are linked, unless +hyperlink_all+ is true.
|
|
31
29
|
|
|
32
|
-
def initialize(
|
|
30
|
+
def initialize(from_path, context, pipe: false, output_decoration: true,
|
|
31
|
+
hyperlink_all: false, show_hash: false,
|
|
32
|
+
autolink_excluded_words: [], warn_missing_rdoc_ref: true)
|
|
33
33
|
raise ArgumentError, 'from_path cannot be nil' if from_path.nil?
|
|
34
34
|
|
|
35
|
-
super
|
|
35
|
+
super(pipe: pipe, output_decoration: output_decoration)
|
|
36
36
|
|
|
37
37
|
@context = context
|
|
38
38
|
@from_path = from_path
|
|
39
|
-
@hyperlink_all =
|
|
40
|
-
@show_hash =
|
|
39
|
+
@hyperlink_all = hyperlink_all
|
|
40
|
+
@show_hash = show_hash
|
|
41
|
+
@autolink_excluded_words = autolink_excluded_words
|
|
42
|
+
@warn_missing_rdoc_ref = warn_missing_rdoc_ref
|
|
41
43
|
|
|
42
44
|
@cross_reference = RDoc::CrossReference.new @context
|
|
43
45
|
end
|
|
@@ -48,30 +50,30 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
|
48
50
|
|
|
49
51
|
# The crossref must be linked before tidylink because Klass.method[:sym]
|
|
50
52
|
# will be processed as a tidylink first and will be broken.
|
|
51
|
-
crossref_re = @
|
|
53
|
+
crossref_re = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
|
|
52
54
|
@markup.add_regexp_handling crossref_re, :CROSSREF
|
|
53
55
|
end
|
|
54
56
|
|
|
55
57
|
##
|
|
56
58
|
# Creates a link to the reference +name+ if the name exists. If +text+ is
|
|
57
59
|
# given it is used as the link text, otherwise +name+ is used.
|
|
60
|
+
# Returns +nil+ if the link target could not be resolved.
|
|
58
61
|
|
|
59
62
|
def cross_reference(name, text = nil, code = true, rdoc_ref: false)
|
|
60
|
-
|
|
63
|
+
# Strip '#' for link display text (e.g. #method shows as "method" in links)
|
|
64
|
+
display = !@show_hash && name.start_with?('#') ? name[1..] : name
|
|
61
65
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if !name.end_with?('+@', '-@') && match = name.match(/(.*[^#:])?@(.*)/)
|
|
66
|
+
if !display.end_with?('+@', '-@') && match = display.match(/(.*[^#:])?@(.*)/)
|
|
65
67
|
context_name = match[1]
|
|
66
|
-
label = RDoc::Text.decode_legacy_label(match[2])
|
|
67
|
-
text ||= "#{label} at <code>#{context_name}</code>" if context_name
|
|
68
|
+
label = convert_string(RDoc::Text.decode_legacy_label(match[2]))
|
|
69
|
+
text ||= "#{label} at <code>#{convert_string(context_name)}</code>" if context_name
|
|
68
70
|
text ||= label
|
|
69
71
|
code = false
|
|
70
72
|
else
|
|
71
|
-
text ||=
|
|
73
|
+
text ||= convert_string(display)
|
|
72
74
|
end
|
|
73
75
|
|
|
74
|
-
link
|
|
76
|
+
link(name, text, code, rdoc_ref: rdoc_ref)
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
##
|
|
@@ -83,7 +85,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
|
83
85
|
|
|
84
86
|
def handle_regexp_CROSSREF(name)
|
|
85
87
|
return convert_string(name) if in_tidylink_label?
|
|
86
|
-
return name if @
|
|
88
|
+
return name if @autolink_excluded_words&.include?(name)
|
|
87
89
|
|
|
88
90
|
return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails
|
|
89
91
|
|
|
@@ -93,8 +95,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
|
93
95
|
# cross-references to "new" in text, for instance)
|
|
94
96
|
return name if name =~ /\A[a-z]*\z/
|
|
95
97
|
end
|
|
96
|
-
|
|
97
|
-
cross_reference name, rdoc_ref: false
|
|
98
|
+
cross_reference(name, rdoc_ref: false) || convert_string(name)
|
|
98
99
|
end
|
|
99
100
|
|
|
100
101
|
##
|
|
@@ -106,7 +107,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
|
106
107
|
|
|
107
108
|
case url
|
|
108
109
|
when /\Ardoc-ref:/
|
|
109
|
-
|
|
110
|
+
ref = $'
|
|
111
|
+
cross_reference(ref, rdoc_ref: true) || convert_string(ref)
|
|
110
112
|
else
|
|
111
113
|
super
|
|
112
114
|
end
|
|
@@ -126,7 +128,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
|
126
128
|
if in_tidylink_label?
|
|
127
129
|
convert_string(url)
|
|
128
130
|
else
|
|
129
|
-
|
|
131
|
+
ref = $'
|
|
132
|
+
cross_reference(ref, rdoc_ref: true) || convert_string(ref)
|
|
130
133
|
end
|
|
131
134
|
else
|
|
132
135
|
super
|
|
@@ -140,96 +143,119 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
|
140
143
|
def gen_url(url, text)
|
|
141
144
|
if url =~ /\Ardoc-ref:/
|
|
142
145
|
name = $'
|
|
143
|
-
cross_reference
|
|
146
|
+
cross_reference(name, text, name == text, rdoc_ref: true) || text
|
|
144
147
|
else
|
|
145
148
|
super
|
|
146
149
|
end
|
|
147
150
|
end
|
|
148
151
|
|
|
149
152
|
##
|
|
150
|
-
# Creates an HTML link to +name+ with the given +
|
|
153
|
+
# Creates an HTML link to +name+ with the given +html_string+.
|
|
154
|
+
# +html_string+ should be already escaped and may contain HTML tags.
|
|
155
|
+
# Returns the link HTML string, or +nil+ if the reference could not be resolved.
|
|
151
156
|
|
|
152
|
-
def link(name,
|
|
157
|
+
def link(name, html_string, code = true, rdoc_ref: false)
|
|
153
158
|
if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])?@/
|
|
154
159
|
name = $1
|
|
155
160
|
label = $'
|
|
156
161
|
end
|
|
157
162
|
|
|
158
|
-
ref = @cross_reference.resolve name
|
|
163
|
+
ref = @cross_reference.resolve name if name
|
|
159
164
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
path = ref
|
|
165
|
+
# Non-text source files (C, Ruby, etc.) don't get HTML pages generated,
|
|
166
|
+
# so don't auto-link to them. Explicit rdoc-ref: links are still allowed.
|
|
167
|
+
if !rdoc_ref && RDoc::TopLevel === ref && !ref.text?
|
|
168
|
+
return
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
if ref
|
|
172
|
+
path = ref.as_href(@from_path)
|
|
168
173
|
|
|
169
174
|
if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
|
|
170
|
-
|
|
175
|
+
html_string = "<code>#{html_string}</code>"
|
|
171
176
|
end
|
|
172
|
-
|
|
173
|
-
if
|
|
174
|
-
#
|
|
175
|
-
# then convert to GitHub-style anchor format
|
|
176
|
-
decoded_label = RDoc::Text.decode_legacy_label(label)
|
|
177
|
-
formatted_label = RDoc::Text.to_anchor(decoded_label)
|
|
178
|
-
|
|
179
|
-
# Case 1: Path already has an anchor (e.g., method link)
|
|
180
|
-
# Input: C1#method@label -> path="C1.html#method-i-m"
|
|
181
|
-
# Output: C1.html#method-i-m-label
|
|
182
|
-
if path =~ /#/
|
|
183
|
-
path << "-#{formatted_label}"
|
|
184
|
-
|
|
185
|
-
# Case 2: Label matches a section title
|
|
186
|
-
# Input: C1@Section -> path="C1.html", section "Section" exists
|
|
187
|
-
# Output: C1.html#section (uses section.aref for GitHub-style)
|
|
188
|
-
elsif (section = ref&.sections&.find { |s| decoded_label == s.title })
|
|
189
|
-
path << "##{section.aref}"
|
|
190
|
-
|
|
191
|
-
# Case 3: Ref has an aref (class/module context)
|
|
192
|
-
# Input: C1@heading -> path="C1.html", ref=C1 class
|
|
193
|
-
# Output: C1.html#class-c1-heading
|
|
194
|
-
elsif ref.respond_to?(:aref)
|
|
195
|
-
path << "##{ref.aref}-#{formatted_label}"
|
|
196
|
-
|
|
197
|
-
# Case 4: No context, just the label (e.g., TopLevel/file)
|
|
198
|
-
# Input: README@section -> path="README_md.html"
|
|
199
|
-
# Output: README_md.html#section
|
|
200
|
-
else
|
|
201
|
-
path << "##{formatted_label}"
|
|
202
|
-
end
|
|
177
|
+
elsif name
|
|
178
|
+
if rdoc_ref && @warn_missing_rdoc_ref
|
|
179
|
+
puts "#{@from_path}: `rdoc-ref:#{name}` can't be resolved for `#{html_string}`"
|
|
203
180
|
end
|
|
181
|
+
return
|
|
182
|
+
else
|
|
183
|
+
# A bare label reference like @foo still produces a valid anchor link
|
|
184
|
+
return unless label
|
|
185
|
+
path = +""
|
|
186
|
+
end
|
|
204
187
|
|
|
205
|
-
|
|
188
|
+
if label
|
|
189
|
+
# Decode legacy labels (e.g., "What-27s+Here" -> "What's Here")
|
|
190
|
+
# then convert to GitHub-style anchor format
|
|
191
|
+
decoded_label = RDoc::Text.decode_legacy_label(label)
|
|
192
|
+
formatted_label = RDoc::Text.to_anchor(decoded_label)
|
|
193
|
+
|
|
194
|
+
# Case 1: Path already has an anchor (e.g., method link)
|
|
195
|
+
# Input: C1#method@label -> path="C1.html#method-i-m"
|
|
196
|
+
# Output: C1.html#method-i-m-label
|
|
197
|
+
if path =~ /#/
|
|
198
|
+
path << "-#{formatted_label}"
|
|
199
|
+
|
|
200
|
+
# Case 2: Label matches a section title
|
|
201
|
+
# Input: C1@Section -> path="C1.html", section "Section" exists
|
|
202
|
+
# Output: C1.html#section (uses section.aref for GitHub-style)
|
|
203
|
+
elsif (section = ref&.sections&.find { |s| decoded_label == s.title })
|
|
204
|
+
path << "##{section.aref}"
|
|
205
|
+
|
|
206
|
+
# Case 3: Ref has an aref (class/module context)
|
|
207
|
+
# Input: C1@heading -> path="C1.html", ref=C1 class
|
|
208
|
+
# Output: C1.html#class-c1-heading
|
|
209
|
+
elsif ref.respond_to?(:aref)
|
|
210
|
+
path << "##{ref.aref}-#{formatted_label}"
|
|
211
|
+
|
|
212
|
+
# Case 4: No context, just the label (e.g., TopLevel/file)
|
|
213
|
+
# Input: README@section -> path="README_md.html"
|
|
214
|
+
# Output: README_md.html#section
|
|
215
|
+
else
|
|
216
|
+
path << "##{formatted_label}"
|
|
217
|
+
end
|
|
206
218
|
end
|
|
219
|
+
|
|
220
|
+
"<a href=\"#{path}\">#{html_string}</a>"
|
|
207
221
|
end
|
|
208
222
|
|
|
209
223
|
def handle_TT(code)
|
|
210
|
-
emit_inline(tt_cross_reference(code) || "<code>#{
|
|
224
|
+
emit_inline(tt_cross_reference(code) || "<code>#{convert_string(code)}</code>")
|
|
211
225
|
end
|
|
212
226
|
|
|
213
227
|
# Applies additional special handling on top of the one defined in ToHtml.
|
|
214
228
|
# When a tidy link is <tt>{Foo}[rdoc-ref:Foo]</tt>, the label part is surrounded by <tt><code></code></tt>.
|
|
215
229
|
# TODO: reconsider this workaround.
|
|
216
230
|
def apply_tidylink_label_special_handling(label, url)
|
|
217
|
-
if url == "rdoc-ref:#{label}" && cross_reference(label)
|
|
231
|
+
if url == "rdoc-ref:#{label}" && cross_reference(label)&.include?('<code>')
|
|
218
232
|
"<code>#{convert_string(label)}</code>"
|
|
219
233
|
else
|
|
220
234
|
super
|
|
221
235
|
end
|
|
222
236
|
end
|
|
223
237
|
|
|
238
|
+
# Handles cross-reference and suppressed-crossref inside tt tag.
|
|
239
|
+
# Returns nil if code is not an existing cross-reference nor a suppressed-crossref.
|
|
224
240
|
def tt_cross_reference(code)
|
|
225
241
|
return if in_tidylink_label?
|
|
226
242
|
|
|
227
|
-
crossref_regexp = @
|
|
228
|
-
|
|
243
|
+
crossref_regexp = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
|
|
244
|
+
# REGEXP sometimes matches a string that starts with a backslash but is not a
|
|
245
|
+
# suppressed cross-reference (for example, `\+`), so the backslash-removed
|
|
246
|
+
# part needs to be checked against crossref_regexp.
|
|
247
|
+
match = crossref_regexp.match(code.delete_prefix('\\'))
|
|
229
248
|
return unless match && match.begin(1).zero?
|
|
230
249
|
return unless match.post_match.match?(/\A[[:punct:]\s]*\z/)
|
|
231
250
|
|
|
232
|
-
|
|
233
|
-
|
|
251
|
+
# cross_reference(file_page) may return a link without code tag.
|
|
252
|
+
# We need to check it because this method shouldn't return an html text without code tag.
|
|
253
|
+
if code.start_with?('\\')
|
|
254
|
+
# Remove leading backslash if crossref exists
|
|
255
|
+
"<code>#{convert_string(code[1..])}</code>" if cross_reference(code[1..])&.include?('<code>')
|
|
256
|
+
else
|
|
257
|
+
html = cross_reference(code)
|
|
258
|
+
html if html&.include?('<code>')
|
|
259
|
+
end
|
|
234
260
|
end
|
|
235
261
|
end
|
|
@@ -34,8 +34,8 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
|
|
|
34
34
|
# next word boundary after the given number of +characters+ or +paragraphs+
|
|
35
35
|
# of text have been encountered.
|
|
36
36
|
|
|
37
|
-
def initialize(
|
|
38
|
-
super
|
|
37
|
+
def initialize(characters = 100, paragraphs = 3)
|
|
38
|
+
super()
|
|
39
39
|
|
|
40
40
|
@character_limit = characters
|
|
41
41
|
@paragraph_limit = paragraphs
|
|
@@ -109,7 +109,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
|
|
|
109
109
|
input = verbatim.text.rstrip
|
|
110
110
|
text = truncate(input, @character_limit - @characters)
|
|
111
111
|
@characters += input.length
|
|
112
|
-
text <<
|
|
112
|
+
text << " #{TO_HTML_CHARACTERS[text.encoding][:ellipsis]}" unless text == input
|
|
113
113
|
|
|
114
114
|
super RDoc::Markup::Verbatim.new text
|
|
115
115
|
|
|
@@ -262,14 +262,14 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
|
|
|
262
262
|
return ['', 0] if limit <= 0
|
|
263
263
|
@inline_character_limit = limit
|
|
264
264
|
res = super
|
|
265
|
-
res <<
|
|
265
|
+
res << " #{TO_HTML_CHARACTERS[text.encoding][:ellipsis]}" if @inline_character_limit <= 0
|
|
266
266
|
@characters += limit - @inline_character_limit
|
|
267
267
|
res
|
|
268
268
|
end
|
|
269
269
|
|
|
270
270
|
def to_html(item)
|
|
271
271
|
throw :done if @characters >= @character_limit
|
|
272
|
-
|
|
272
|
+
handle_inline(item)
|
|
273
273
|
end
|
|
274
274
|
|
|
275
275
|
##
|
data/lib/rdoc/markup/to_label.rb
CHANGED
|
@@ -14,8 +14,8 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
|
|
|
14
14
|
##
|
|
15
15
|
# Creates a new formatter that will output HTML-safe labels
|
|
16
16
|
|
|
17
|
-
def initialize
|
|
18
|
-
super
|
|
17
|
+
def initialize
|
|
18
|
+
super
|
|
19
19
|
|
|
20
20
|
@markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
|
|
21
21
|
|
data/lib/rdoc/markup/to_rdoc.rb
CHANGED
|
@@ -52,8 +52,8 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
|
52
52
|
##
|
|
53
53
|
# Creates a new formatter that will output (mostly) \RDoc markup
|
|
54
54
|
|
|
55
|
-
def initialize
|
|
56
|
-
super
|
|
55
|
+
def initialize
|
|
56
|
+
super
|
|
57
57
|
|
|
58
58
|
@markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF)
|
|
59
59
|
@width = 78
|
data/lib/rdoc/markup/verbatim.rb
CHANGED
data/lib/rdoc/options.rb
CHANGED
|
@@ -74,23 +74,6 @@ require 'pathname'
|
|
|
74
74
|
|
|
75
75
|
class RDoc::Options
|
|
76
76
|
|
|
77
|
-
##
|
|
78
|
-
# The deprecated options.
|
|
79
|
-
|
|
80
|
-
DEPRECATED = {
|
|
81
|
-
'--accessor' => 'support discontinued',
|
|
82
|
-
'--diagram' => 'support discontinued',
|
|
83
|
-
'--help-output' => 'support discontinued',
|
|
84
|
-
'--image-format' => 'was an option for --diagram',
|
|
85
|
-
'--inline-source' => 'source code is now always inlined',
|
|
86
|
-
'--merge' => 'ri now always merges class information',
|
|
87
|
-
'--one-file' => 'support discontinued',
|
|
88
|
-
'--op-name' => 'support discontinued',
|
|
89
|
-
'--opname' => 'support discontinued',
|
|
90
|
-
'--promiscuous' => 'files always only document their content',
|
|
91
|
-
'--ri-system' => 'Ruby installers use other techniques',
|
|
92
|
-
}
|
|
93
|
-
|
|
94
77
|
##
|
|
95
78
|
# RDoc options ignored (or handled specially) by --write-options
|
|
96
79
|
|
|
@@ -112,8 +95,8 @@ class RDoc::Options
|
|
|
112
95
|
pipe
|
|
113
96
|
rdoc_include
|
|
114
97
|
root
|
|
98
|
+
server_port
|
|
115
99
|
static_path
|
|
116
|
-
stylesheet_url
|
|
117
100
|
template
|
|
118
101
|
template_dir
|
|
119
102
|
update_output_dir
|
|
@@ -346,6 +329,13 @@ class RDoc::Options
|
|
|
346
329
|
|
|
347
330
|
attr_reader :visibility
|
|
348
331
|
|
|
332
|
+
##
|
|
333
|
+
# When set to a port number, starts a live-reloading server instead of
|
|
334
|
+
# writing files. Defaults to +false+ (no server). Set via
|
|
335
|
+
# <tt>--server[=PORT]</tt>.
|
|
336
|
+
|
|
337
|
+
attr_reader :server_port
|
|
338
|
+
|
|
349
339
|
##
|
|
350
340
|
# Indicates if files of test suites should be skipped
|
|
351
341
|
attr_accessor :skip_tests
|
|
@@ -428,9 +418,9 @@ class RDoc::Options
|
|
|
428
418
|
@output_decoration = true
|
|
429
419
|
@rdoc_include = []
|
|
430
420
|
@root = Pathname(Dir.pwd)
|
|
421
|
+
@server_port = false
|
|
431
422
|
@show_hash = false
|
|
432
423
|
@static_path = []
|
|
433
|
-
@stylesheet_url = nil # TODO remove in RDoc 4
|
|
434
424
|
@tab_width = 8
|
|
435
425
|
@template = nil
|
|
436
426
|
@template_dir = nil
|
|
@@ -609,7 +599,12 @@ class RDoc::Options
|
|
|
609
599
|
ivars.sort.each do |ivar|
|
|
610
600
|
yaml[ivar] = instance_variable_get("@#{ivar}")
|
|
611
601
|
end
|
|
612
|
-
|
|
602
|
+
|
|
603
|
+
if yaml.respond_to?(:to_yaml)
|
|
604
|
+
yaml.to_yaml
|
|
605
|
+
else
|
|
606
|
+
RDoc.yaml_serializer.dump(yaml)
|
|
607
|
+
end
|
|
613
608
|
end
|
|
614
609
|
|
|
615
610
|
##
|
|
@@ -769,14 +764,6 @@ Usage: #{opt.program_name} [options] [names...]
|
|
|
769
764
|
end
|
|
770
765
|
opt.banner += " - TomDoc: Only in ruby files\n"
|
|
771
766
|
|
|
772
|
-
opt.banner += "\n The following options are deprecated:\n\n"
|
|
773
|
-
|
|
774
|
-
name_length = DEPRECATED.keys.sort_by { |k| k.length }.last.length
|
|
775
|
-
|
|
776
|
-
DEPRECATED.sort_by { |k,| k }.each do |name, reason|
|
|
777
|
-
opt.banner += " %*1$2$s %3$s\n" % [-name_length, name, reason]
|
|
778
|
-
end
|
|
779
|
-
|
|
780
767
|
opt.accept Template do |template|
|
|
781
768
|
template_dir = template_dir_for template
|
|
782
769
|
|
|
@@ -913,7 +900,7 @@ Usage: #{opt.program_name} [options] [names...]
|
|
|
913
900
|
|
|
914
901
|
opt.separator nil
|
|
915
902
|
|
|
916
|
-
opt.on("--visibility=VISIBILITY",
|
|
903
|
+
opt.on("--visibility=VISIBILITY", RDoc::VISIBILITIES + [:nodoc],
|
|
917
904
|
"Minimum visibility to document a method.",
|
|
918
905
|
"One of 'public', 'protected' (the default),",
|
|
919
906
|
"'private' or 'nodoc' (show everything)") do |value|
|
|
@@ -1013,14 +1000,6 @@ Usage: #{opt.program_name} [options] [names...]
|
|
|
1013
1000
|
@op_dir = value
|
|
1014
1001
|
end
|
|
1015
1002
|
|
|
1016
|
-
opt.separator nil
|
|
1017
|
-
|
|
1018
|
-
opt.on("-d",
|
|
1019
|
-
"Deprecated --diagram option.",
|
|
1020
|
-
"Prevents firing debug mode",
|
|
1021
|
-
"with legacy invocation.") do |value|
|
|
1022
|
-
end
|
|
1023
|
-
|
|
1024
1003
|
opt.separator nil
|
|
1025
1004
|
opt.separator 'HTML generator options:'
|
|
1026
1005
|
opt.separator nil
|
|
@@ -1158,6 +1137,15 @@ Usage: #{opt.program_name} [options] [names...]
|
|
|
1158
1137
|
opt.separator "Generic options:"
|
|
1159
1138
|
opt.separator nil
|
|
1160
1139
|
|
|
1140
|
+
opt.on("--server[=PORT]", Integer,
|
|
1141
|
+
"Start a web server to preview",
|
|
1142
|
+
"documentation with live reload.",
|
|
1143
|
+
"Defaults to port 4000.") do |port|
|
|
1144
|
+
@server_port = port || 4000
|
|
1145
|
+
end
|
|
1146
|
+
|
|
1147
|
+
opt.separator nil
|
|
1148
|
+
|
|
1161
1149
|
opt.on("--write-options",
|
|
1162
1150
|
"Write .rdoc_options to the current",
|
|
1163
1151
|
"directory with the given options. Not all",
|
|
@@ -1230,15 +1218,12 @@ Usage: #{opt.program_name} [options] [names...]
|
|
|
1230
1218
|
opt.separator nil
|
|
1231
1219
|
end
|
|
1232
1220
|
|
|
1233
|
-
deprecated = []
|
|
1234
1221
|
invalid = []
|
|
1235
1222
|
|
|
1236
1223
|
begin
|
|
1237
1224
|
opts.parse! argv
|
|
1238
1225
|
rescue OptionParser::ParseError => e
|
|
1239
|
-
if
|
|
1240
|
-
deprecated << e.args.first
|
|
1241
|
-
elsif %w[--format --ri -r --ri-site -R].include? e.args.first then
|
|
1226
|
+
if %w[--format --ri -r --ri-site -R].include? e.args.first then
|
|
1242
1227
|
raise
|
|
1243
1228
|
else
|
|
1244
1229
|
invalid << e.args.join(' ')
|
|
@@ -1254,12 +1239,6 @@ Usage: #{opt.program_name} [options] [names...]
|
|
|
1254
1239
|
invalid << '-p (with files)'
|
|
1255
1240
|
end
|
|
1256
1241
|
|
|
1257
|
-
unless quiet then
|
|
1258
|
-
deprecated.each do |opt|
|
|
1259
|
-
$stderr.puts 'option ' + opt + ' is deprecated: ' + DEPRECATED[opt]
|
|
1260
|
-
end
|
|
1261
|
-
end
|
|
1262
|
-
|
|
1263
1242
|
unless invalid.empty? then
|
|
1264
1243
|
invalid = "invalid options: #{invalid.join ', '}"
|
|
1265
1244
|
|
|
@@ -1405,10 +1384,16 @@ Usage: #{opt.program_name} [options] [names...]
|
|
|
1405
1384
|
|
|
1406
1385
|
RDoc.load_yaml
|
|
1407
1386
|
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1387
|
+
content = File.read('.rdoc_options')
|
|
1388
|
+
|
|
1389
|
+
if defined?(Psych)
|
|
1390
|
+
begin
|
|
1391
|
+
options = Psych.safe_load content, permitted_classes: [RDoc::Options, Symbol]
|
|
1392
|
+
rescue Psych::SyntaxError
|
|
1393
|
+
raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
|
|
1394
|
+
end
|
|
1395
|
+
else
|
|
1396
|
+
options = RDoc.yaml_serializer.load(content)
|
|
1412
1397
|
end
|
|
1413
1398
|
|
|
1414
1399
|
return RDoc::Options.new unless options # Allow empty file.
|
data/lib/rdoc/parser/c.rb
CHANGED
|
@@ -248,7 +248,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
|
248
248
|
# method that reference the same function.
|
|
249
249
|
|
|
250
250
|
def add_alias(var_name, class_obj, old_name, new_name, comment)
|
|
251
|
-
al = RDoc::Alias.new
|
|
251
|
+
al = RDoc::Alias.new old_name, new_name, comment, singleton: @singleton_classes.key?(var_name)
|
|
252
252
|
al.record_location @top_level
|
|
253
253
|
class_obj.add_alias al
|
|
254
254
|
@stats.add_alias al
|
|
@@ -683,6 +683,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
|
683
683
|
container.name = base_name if base_name
|
|
684
684
|
|
|
685
685
|
container.record_location @top_level
|
|
686
|
+
@top_level.add_to_classes_or_modules container
|
|
686
687
|
@classes[raw_name] = container
|
|
687
688
|
end
|
|
688
689
|
@classes[raw_name]
|
|
@@ -847,7 +848,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
|
847
848
|
|
|
848
849
|
name = attr_name.gsub(/rb_intern(?:_const)?\("([^"]+)"\)/, '\1')
|
|
849
850
|
|
|
850
|
-
attr = RDoc::Attr.new
|
|
851
|
+
attr = RDoc::Attr.new name, rw, comment
|
|
851
852
|
|
|
852
853
|
attr.record_location @top_level
|
|
853
854
|
class_obj.add_attribute attr
|
|
@@ -898,6 +899,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
|
898
899
|
end
|
|
899
900
|
|
|
900
901
|
cm.record_location enclosure.top_level
|
|
902
|
+
enclosure.top_level.add_to_classes_or_modules cm
|
|
901
903
|
|
|
902
904
|
find_class_comment cm.full_name, cm
|
|
903
905
|
|
|
@@ -1005,7 +1007,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
|
1005
1007
|
end
|
|
1006
1008
|
|
|
1007
1009
|
singleton = singleton || %w[singleton_method module_function].include?(type)
|
|
1008
|
-
meth_obj = RDoc::AnyMethod.new
|
|
1010
|
+
meth_obj = RDoc::AnyMethod.new meth_name, singleton: singleton
|
|
1009
1011
|
meth_obj.c_function = function
|
|
1010
1012
|
|
|
1011
1013
|
p_count = Integer(param_count) rescue -1
|
|
@@ -1014,7 +1016,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
|
1014
1016
|
file_name = File.join @file_dir, source_file
|
|
1015
1017
|
|
|
1016
1018
|
if File.exist? file_name then
|
|
1017
|
-
file_content =
|
|
1019
|
+
file_content = RDoc::Encoding.read_file file_name, @options.encoding
|
|
1018
1020
|
else
|
|
1019
1021
|
@options.warn "unknown source #{source_file} for #{meth_name} in #{@file_name}"
|
|
1020
1022
|
end
|
|
@@ -1089,11 +1091,10 @@ class RDoc::Parser::C < RDoc::Parser
|
|
|
1089
1091
|
# Look for directives in a normal comment block:
|
|
1090
1092
|
#
|
|
1091
1093
|
# /*
|
|
1092
|
-
# * :
|
|
1094
|
+
# * :nodoc:
|
|
1093
1095
|
# */
|
|
1094
1096
|
#
|
|
1095
1097
|
# This method modifies the +comment+
|
|
1096
|
-
# Both :main: and :title: directives are deprecated and will be removed in RDoc 7.
|
|
1097
1098
|
|
|
1098
1099
|
def look_for_directives_in(context, comment)
|
|
1099
1100
|
comment.text, format = @preprocess.run_pre_processes(comment.text, context, comment.line || 1, :c)
|