rdoc 6.1.2.1 → 6.3.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rdoc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +9 -0
- data/README.rdoc +0 -1
- data/Rakefile +28 -18
- data/lib/rdoc/any_method.rb +52 -7
- data/lib/rdoc/class_module.rb +1 -1
- data/lib/rdoc/comment.rb +12 -1
- data/lib/rdoc/context/section.rb +0 -13
- data/lib/rdoc/context.rb +10 -2
- data/lib/rdoc/cross_reference.rb +4 -4
- data/lib/rdoc/erb_partial.rb +1 -1
- data/lib/rdoc/erbio.rb +2 -2
- data/lib/rdoc/generator/darkfish.rb +9 -9
- data/lib/rdoc/generator/pot.rb +3 -3
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +4 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/class.rhtml +44 -44
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +33 -5
- data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
- data/lib/rdoc/i18n.rb +1 -1
- data/lib/rdoc/markdown/literals.rb +7 -8
- data/lib/rdoc/markdown.kpeg +20 -2
- data/lib/rdoc/markdown.rb +458 -61
- data/lib/rdoc/markup/attr_span.rb +8 -2
- data/lib/rdoc/markup/attribute_manager.rb +93 -28
- data/lib/rdoc/markup/formatter.rb +1 -1
- data/lib/rdoc/markup/parser.rb +58 -42
- data/lib/rdoc/markup/pre_process.rb +1 -1
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_html.rb +46 -6
- data/lib/rdoc/markup/to_html_crossref.rb +18 -6
- data/lib/rdoc/markup/to_joined_paragraph.rb +1 -0
- data/lib/rdoc/markup/to_rdoc.rb +28 -0
- data/lib/rdoc/markup/to_table_of_contents.rb +1 -0
- data/lib/rdoc/markup.rb +1 -2
- data/lib/rdoc/options.rb +56 -6
- data/lib/rdoc/parser/c.rb +139 -183
- data/lib/rdoc/parser/changelog.rb +145 -14
- data/lib/rdoc/parser/ripper_state_lex.rb +2 -1
- data/lib/rdoc/parser/ruby.rb +18 -8
- data/lib/rdoc/parser.rb +7 -7
- data/lib/rdoc/rdoc.rb +34 -21
- data/lib/rdoc/ri/driver.rb +9 -5
- data/lib/rdoc/ri/paths.rb +3 -17
- data/lib/rdoc/ri/task.rb +1 -1
- data/lib/rdoc/rubygems_hook.rb +2 -2
- data/lib/rdoc/servlet.rb +16 -8
- data/lib/rdoc/store.rb +6 -14
- data/lib/rdoc/task.rb +1 -1
- data/lib/rdoc/text.rb +8 -2
- data/lib/rdoc/token_stream.rb +8 -3
- data/lib/rdoc/tom_doc.rb +6 -7
- data/lib/rdoc/version.rb +1 -1
- data/lib/rdoc.rb +21 -0
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +196 -9
- metadata +7 -67
- data/.document +0 -5
- data/.gitignore +0 -14
- data/.travis.yml +0 -21
- data/appveyor.yml +0 -36
- data/lib/rdoc/markup/formatter_test_case.rb +0 -764
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'time'
|
3
2
|
|
4
3
|
##
|
5
4
|
# A ChangeLog file parser.
|
@@ -106,14 +105,32 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
|
|
106
105
|
entries.group_by do |title, _|
|
107
106
|
begin
|
108
107
|
time = @time_cache[title]
|
109
|
-
(time ||
|
108
|
+
(time || parse_date(title)).strftime '%Y-%m-%d'
|
110
109
|
rescue NoMethodError, ArgumentError
|
111
110
|
time, = title.split ' ', 2
|
112
|
-
|
111
|
+
parse_date(time).strftime '%Y-%m-%d'
|
113
112
|
end
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
116
|
+
##
|
117
|
+
# Parse date in ISO-8601, RFC-2822, or default of Git
|
118
|
+
|
119
|
+
def parse_date(date)
|
120
|
+
case date
|
121
|
+
when /\A\s*(\d+)-(\d+)-(\d+)(?:[ T](\d+):(\d+):(\d+) *([-+]\d\d):?(\d\d))?\b/
|
122
|
+
Time.new($1, $2, $3, $4, $5, $6, ("#{$7}:#{$8}" if $7))
|
123
|
+
when /\A\s*\w{3}, +(\d+) (\w{3}) (\d+) (\d+):(\d+):(\d+) *(?:([-+]\d\d):?(\d\d))\b/
|
124
|
+
Time.new($3, $2, $1, $4, $5, $6, ("#{$7}:#{$8}" if $7))
|
125
|
+
when /\A\s*\w{3} (\w{3}) +(\d+) (\d+) (\d+):(\d+):(\d+) *(?:([-+]\d\d):?(\d\d))\b/
|
126
|
+
Time.new($3, $1, $2, $4, $5, $6, ("#{$7}:#{$8}" if $7))
|
127
|
+
when /\A\s*\w{3} (\w{3}) +(\d+) (\d+):(\d+):(\d+) (\d+)\b/
|
128
|
+
Time.new($6, $1, $2, $3, $4, $5)
|
129
|
+
else
|
130
|
+
raise ArgumentError, "bad date: #{date}"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
117
134
|
##
|
118
135
|
# Parses the entries in the ChangeLog.
|
119
136
|
#
|
@@ -131,6 +148,13 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
|
|
131
148
|
|
132
149
|
def parse_entries
|
133
150
|
@time_cache ||= {}
|
151
|
+
|
152
|
+
if /\A((?:.*\n){,3})commit\s/ =~ @content
|
153
|
+
class << self; prepend Git; end
|
154
|
+
parse_info($1)
|
155
|
+
return parse_entries
|
156
|
+
end
|
157
|
+
|
134
158
|
entries = []
|
135
159
|
entry_name = nil
|
136
160
|
entry_body = []
|
@@ -145,19 +169,10 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
|
|
145
169
|
entry_name = $&
|
146
170
|
|
147
171
|
begin
|
148
|
-
time =
|
172
|
+
time = parse_date entry_name
|
149
173
|
@time_cache[entry_name] = time
|
150
|
-
# HACK Ruby 1.8 does not raise ArgumentError for Time.parse "Other"
|
151
|
-
entry_name = nil unless entry_name =~ /#{time.year}/
|
152
|
-
rescue NoMethodError
|
153
|
-
# HACK Ruby 2.1.2 and earlier raises NoMethodError if time part is absent
|
154
|
-
entry_name.split ' ', 2
|
155
174
|
rescue ArgumentError
|
156
|
-
|
157
|
-
Time.parse(entry_name.split(' ', 2)[0]) rescue entry_name = nil
|
158
|
-
else
|
159
|
-
entry_name = nil
|
160
|
-
end
|
175
|
+
entry_name = nil
|
161
176
|
end
|
162
177
|
|
163
178
|
entry_body = []
|
@@ -190,6 +205,7 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
|
|
190
205
|
|
191
206
|
def scan
|
192
207
|
@time_cache = {}
|
208
|
+
|
193
209
|
entries = parse_entries
|
194
210
|
grouped_entries = group_entries entries
|
195
211
|
|
@@ -200,5 +216,120 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
|
|
200
216
|
@top_level
|
201
217
|
end
|
202
218
|
|
219
|
+
module Git
|
220
|
+
def parse_info(info)
|
221
|
+
/^\s*base-url\s*=\s*(.*\S)/ =~ info
|
222
|
+
@base_url = $1
|
223
|
+
end
|
224
|
+
|
225
|
+
def parse_entries
|
226
|
+
entries = []
|
227
|
+
|
228
|
+
@content.scan(/^commit\s+(\h{20})\h*\n((?:.+\n)*)\n((?: {4}.*\n+)*)/) do
|
229
|
+
entry_name, header, entry_body = $1, $2, $3.gsub(/^ {4}/, '')
|
230
|
+
# header = header.scan(/^ *(\S+?): +(.*)/).to_h
|
231
|
+
# date = header["CommitDate"] || header["Date"]
|
232
|
+
date = header[/^ *(?:Author)?Date: +(.*)/, 1]
|
233
|
+
author = header[/^ *Author: +(.*)/, 1]
|
234
|
+
begin
|
235
|
+
time = parse_date(header[/^ *CommitDate: +(.*)/, 1] || date)
|
236
|
+
@time_cache[entry_name] = time
|
237
|
+
author.sub!(/\s*<(.*)>/, '')
|
238
|
+
email = $1
|
239
|
+
entries << [entry_name, [author, email, date, entry_body]]
|
240
|
+
rescue ArgumentError
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
entries
|
245
|
+
end
|
246
|
+
|
247
|
+
def create_entries entries
|
248
|
+
# git log entries have no strictly itemized style like the old
|
249
|
+
# style, just assume Markdown.
|
250
|
+
entries.map do |commit, entry|
|
251
|
+
LogEntry.new(@base_url, commit, *entry)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
LogEntry = Struct.new(:base, :commit, :author, :email, :date, :contents) do
|
256
|
+
HEADING_LEVEL = 3
|
257
|
+
|
258
|
+
def initialize(base, commit, author, email, date, contents)
|
259
|
+
case contents
|
260
|
+
when String
|
261
|
+
contents = RDoc::Markdown.parse(contents).parts.each do |body|
|
262
|
+
case body
|
263
|
+
when RDoc::Markup::Heading
|
264
|
+
body.level += HEADING_LEVEL + 1
|
265
|
+
end
|
266
|
+
end
|
267
|
+
case first = contents[0]
|
268
|
+
when RDoc::Markup::Paragraph
|
269
|
+
contents[0] = RDoc::Markup::Heading.new(HEADING_LEVEL + 1, first.text)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
super
|
273
|
+
end
|
274
|
+
|
275
|
+
def level
|
276
|
+
HEADING_LEVEL
|
277
|
+
end
|
278
|
+
|
279
|
+
def aref
|
280
|
+
"label-#{commit}"
|
281
|
+
end
|
282
|
+
|
283
|
+
def label context = nil
|
284
|
+
aref
|
285
|
+
end
|
286
|
+
|
287
|
+
def text
|
288
|
+
case base
|
289
|
+
when nil
|
290
|
+
"#{date}"
|
291
|
+
when /%s/
|
292
|
+
"{#{date}}[#{base % commit}]"
|
293
|
+
else
|
294
|
+
"{#{date}}[#{base}#{commit}]"
|
295
|
+
end + " {#{author}}[mailto:#{email}]"
|
296
|
+
end
|
297
|
+
|
298
|
+
def accept visitor
|
299
|
+
visitor.accept_heading self
|
300
|
+
begin
|
301
|
+
if visitor.respond_to?(:code_object=)
|
302
|
+
code_object = visitor.code_object
|
303
|
+
visitor.code_object = self
|
304
|
+
end
|
305
|
+
contents.each do |body|
|
306
|
+
body.accept visitor
|
307
|
+
end
|
308
|
+
ensure
|
309
|
+
if visitor.respond_to?(:code_object)
|
310
|
+
visitor.code_object = code_object
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
def pretty_print q # :nodoc:
|
316
|
+
q.group(2, '[log_entry: ', ']') do
|
317
|
+
q.text commit
|
318
|
+
q.text ','
|
319
|
+
q.breakable
|
320
|
+
q.group(2, '[date: ', ']') { q.text date }
|
321
|
+
q.text ','
|
322
|
+
q.breakable
|
323
|
+
q.group(2, '[author: ', ']') { q.text author }
|
324
|
+
q.text ','
|
325
|
+
q.breakable
|
326
|
+
q.group(2, '[email: ', ']') { q.text email }
|
327
|
+
q.text ','
|
328
|
+
q.breakable
|
329
|
+
q.pp contents
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
203
334
|
end
|
204
335
|
|
@@ -494,7 +494,8 @@ class RDoc::Parser::RipperStateLex
|
|
494
494
|
private def heredoc_end?(name, indent, tk)
|
495
495
|
result = false
|
496
496
|
if :on_heredoc_end == tk[:kind] then
|
497
|
-
tk_name =
|
497
|
+
tk_name = tk[:text].chomp
|
498
|
+
tk_name.lstrip! if indent
|
498
499
|
if name == tk_name
|
499
500
|
result = true
|
500
501
|
end
|
data/lib/rdoc/parser/ruby.rb
CHANGED
@@ -244,6 +244,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
244
244
|
comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
|
245
245
|
first_line = true
|
246
246
|
first_comment_tk_kind = nil
|
247
|
+
line_no = nil
|
247
248
|
|
248
249
|
tk = get_tk
|
249
250
|
|
@@ -260,6 +261,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
260
261
|
break if first_comment_tk_kind and not first_comment_tk_kind === tk[:kind]
|
261
262
|
first_comment_tk_kind = tk[:kind]
|
262
263
|
|
264
|
+
line_no = tk[:line_no] if first_line
|
263
265
|
first_line = false
|
264
266
|
comment << comment_body
|
265
267
|
tk = get_tk
|
@@ -273,7 +275,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
273
275
|
|
274
276
|
unget_tk tk
|
275
277
|
|
276
|
-
new_comment comment
|
278
|
+
new_comment comment, line_no
|
277
279
|
end
|
278
280
|
|
279
281
|
##
|
@@ -376,7 +378,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
376
378
|
record_location container
|
377
379
|
|
378
380
|
get_tk
|
379
|
-
|
381
|
+
skip_tkspace
|
382
|
+
if :on_lparen == peek_tk[:kind] # ProcObjectInConstant::()
|
383
|
+
parse_method_or_yield_parameters
|
384
|
+
break
|
385
|
+
end
|
380
386
|
name_t = get_tk
|
381
387
|
unless :on_const == name_t[:kind] || :on_ident == name_t[:kind]
|
382
388
|
raise RDoc::Error, "Invalid class or module definition: #{given_name}"
|
@@ -666,8 +672,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
666
672
|
##
|
667
673
|
# Creates a comment with the correct format
|
668
674
|
|
669
|
-
def new_comment comment
|
670
|
-
c = RDoc::Comment.new comment, @top_level
|
675
|
+
def new_comment comment, line_no = nil
|
676
|
+
c = RDoc::Comment.new comment, @top_level, :ruby
|
677
|
+
c.line = line_no
|
671
678
|
c.format = @markup
|
672
679
|
c
|
673
680
|
end
|
@@ -1058,13 +1065,14 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1058
1065
|
def parse_comment container, tk, comment
|
1059
1066
|
return parse_comment_tomdoc container, tk, comment if @markup == 'tomdoc'
|
1060
1067
|
column = tk[:char_no]
|
1061
|
-
line_no = tk[:line_no]
|
1068
|
+
line_no = comment.line.nil? ? tk[:line_no] : comment.line
|
1062
1069
|
|
1063
1070
|
comment.text = comment.text.sub(/(^# +:?)(singleton-)(method:)/, '\1\3')
|
1064
1071
|
singleton = !!$~
|
1065
1072
|
|
1066
1073
|
co =
|
1067
1074
|
if (comment.text = comment.text.sub(/^# +:?method: *(\S*).*?\n/i, '')) && !!$~ then
|
1075
|
+
line_no += $`.count("\n")
|
1068
1076
|
parse_comment_ghost container, comment.text, $1, column, line_no, comment
|
1069
1077
|
elsif (comment.text = comment.text.sub(/# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '')) && !!$~ then
|
1070
1078
|
parse_comment_attr container, $1, $3, comment
|
@@ -1776,18 +1784,20 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1776
1784
|
comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
|
1777
1785
|
end
|
1778
1786
|
|
1787
|
+
line_no = nil
|
1779
1788
|
while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do
|
1780
1789
|
comment_body = retrieve_comment_body(tk)
|
1790
|
+
line_no = tk[:line_no] if comment.empty?
|
1781
1791
|
comment += comment_body
|
1782
|
-
comment
|
1792
|
+
comment << "\n" unless comment_body =~ /\n\z/
|
1783
1793
|
|
1784
|
-
if comment_body.size > 1 &&
|
1794
|
+
if comment_body.size > 1 && comment_body =~ /\n\z/ then
|
1785
1795
|
skip_tkspace_without_nl # leading spaces
|
1786
1796
|
end
|
1787
1797
|
tk = get_tk
|
1788
1798
|
end
|
1789
1799
|
|
1790
|
-
comment = new_comment comment
|
1800
|
+
comment = new_comment comment, line_no
|
1791
1801
|
|
1792
1802
|
unless comment.empty? then
|
1793
1803
|
look_for_directives_in container, comment
|
data/lib/rdoc/parser.rb
CHANGED
@@ -78,7 +78,7 @@ class RDoc::Parser
|
|
78
78
|
|
79
79
|
return true if s[0, 2] == Marshal.dump('')[0, 2] or s.index("\x00")
|
80
80
|
|
81
|
-
mode = 'r:utf-8' # default source encoding has been
|
81
|
+
mode = 'r:utf-8' # default source encoding has been changed to utf-8
|
82
82
|
s.sub!(/\A#!.*\n/, '') # assume shebang line isn't longer than 1024.
|
83
83
|
encoding = s[/^\s*\#\s*(?:-\*-\s*)?(?:en)?coding:\s*([^\s;]+?)(?:-\*-|[\s;])/, 1]
|
84
84
|
mode = "rb:#{encoding}" if encoding
|
@@ -269,9 +269,9 @@ class RDoc::Parser
|
|
269
269
|
end
|
270
270
|
|
271
271
|
# simple must come first in order to show up last in the parsers list
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
272
|
+
require_relative 'parser/simple'
|
273
|
+
require_relative 'parser/c'
|
274
|
+
require_relative 'parser/changelog'
|
275
|
+
require_relative 'parser/markdown'
|
276
|
+
require_relative 'parser/rd'
|
277
|
+
require_relative 'parser/ruby'
|
data/lib/rdoc/rdoc.rb
CHANGED
@@ -24,7 +24,7 @@ require 'time'
|
|
24
24
|
# rdoc.document argv
|
25
25
|
#
|
26
26
|
# Where +argv+ is an array of strings, each corresponding to an argument you'd
|
27
|
-
# give rdoc on the command line. See <tt>rdoc --help
|
27
|
+
# give rdoc on the command line. See <tt>rdoc --help</tt> for details.
|
28
28
|
|
29
29
|
class RDoc::RDoc
|
30
30
|
|
@@ -112,11 +112,17 @@ class RDoc::RDoc
|
|
112
112
|
|
113
113
|
file_list = normalized_file_list files, true, @options.exclude
|
114
114
|
|
115
|
-
file_list = file_list
|
115
|
+
file_list = remove_unparseable(file_list)
|
116
116
|
|
117
|
-
file_list
|
118
|
-
|
119
|
-
|
117
|
+
if file_list.count {|name, mtime|
|
118
|
+
file_list[name] = @last_modified[name] unless mtime
|
119
|
+
mtime
|
120
|
+
} > 0
|
121
|
+
@last_modified.replace file_list
|
122
|
+
file_list.keys.sort
|
123
|
+
else
|
124
|
+
[]
|
125
|
+
end
|
120
126
|
end
|
121
127
|
|
122
128
|
##
|
@@ -160,8 +166,15 @@ class RDoc::RDoc
|
|
160
166
|
rescue Psych::SyntaxError
|
161
167
|
end
|
162
168
|
|
169
|
+
return RDoc::Options.new if options == false # Allow empty file.
|
170
|
+
|
163
171
|
raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
|
164
|
-
RDoc::Options === options
|
172
|
+
RDoc::Options === options or Hash === options
|
173
|
+
|
174
|
+
if Hash === options
|
175
|
+
# Override the default values with the contents of YAML file.
|
176
|
+
options = RDoc::Options.new options
|
177
|
+
end
|
165
178
|
|
166
179
|
options
|
167
180
|
end
|
@@ -254,11 +267,11 @@ option)
|
|
254
267
|
# read and strip comments
|
255
268
|
patterns = File.read(filename).gsub(/#.*/, '')
|
256
269
|
|
257
|
-
result =
|
270
|
+
result = {}
|
258
271
|
|
259
|
-
patterns.split.each do |patt|
|
272
|
+
patterns.split(' ').each do |patt|
|
260
273
|
candidates = Dir.glob(File.join(in_dir, patt))
|
261
|
-
result.
|
274
|
+
result.update normalized_file_list(candidates, false, @options.exclude)
|
262
275
|
end
|
263
276
|
|
264
277
|
result
|
@@ -278,21 +291,21 @@ option)
|
|
278
291
|
|
279
292
|
def normalized_file_list(relative_files, force_doc = false,
|
280
293
|
exclude_pattern = nil)
|
281
|
-
file_list =
|
294
|
+
file_list = {}
|
282
295
|
|
283
296
|
relative_files.each do |rel_file_name|
|
297
|
+
rel_file_name = rel_file_name.sub(/^\.\//, '')
|
284
298
|
next if rel_file_name.end_with? 'created.rid'
|
285
299
|
next if exclude_pattern && exclude_pattern =~ rel_file_name
|
286
300
|
stat = File.stat rel_file_name rescue next
|
287
301
|
|
288
302
|
case type = stat.ftype
|
289
303
|
when "file" then
|
290
|
-
|
291
|
-
|
304
|
+
mtime = (stat.mtime unless (last_modified = @last_modified[rel_file_name] and
|
305
|
+
stat.mtime.to_i <= last_modified.to_i))
|
292
306
|
|
293
307
|
if force_doc or RDoc::Parser.can_parse(rel_file_name) then
|
294
|
-
file_list
|
295
|
-
@last_modified[rel_file_name] = stat.mtime
|
308
|
+
file_list[rel_file_name] = mtime
|
296
309
|
end
|
297
310
|
when "directory" then
|
298
311
|
next if rel_file_name == "CVS" || rel_file_name == ".svn"
|
@@ -303,16 +316,16 @@ option)
|
|
303
316
|
dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
|
304
317
|
|
305
318
|
if File.file? dot_doc then
|
306
|
-
file_list
|
319
|
+
file_list.update(parse_dot_doc_file(rel_file_name, dot_doc))
|
307
320
|
else
|
308
|
-
file_list
|
321
|
+
file_list.update(list_files_in_directory(rel_file_name))
|
309
322
|
end
|
310
323
|
else
|
311
324
|
warn "rdoc can't parse the #{type} #{rel_file_name}"
|
312
325
|
end
|
313
326
|
end
|
314
327
|
|
315
|
-
file_list
|
328
|
+
file_list
|
316
329
|
end
|
317
330
|
|
318
331
|
##
|
@@ -427,7 +440,7 @@ The internal error was:
|
|
427
440
|
# files for emacs and vim.
|
428
441
|
|
429
442
|
def remove_unparseable files
|
430
|
-
files.reject do |file
|
443
|
+
files.reject do |file, *|
|
431
444
|
file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
|
432
445
|
(file =~ /tags$/i and
|
433
446
|
File.open(file, 'rb') { |io|
|
@@ -561,6 +574,6 @@ rescue LoadError
|
|
561
574
|
end
|
562
575
|
|
563
576
|
# require built-in generators after discovery in case they've been replaced
|
564
|
-
|
565
|
-
|
566
|
-
|
577
|
+
require_relative 'generator/darkfish'
|
578
|
+
require_relative 'generator/ri'
|
579
|
+
require_relative 'generator/pot'
|
data/lib/rdoc/ri/driver.rb
CHANGED
@@ -17,7 +17,7 @@ require 'rdoc'
|
|
17
17
|
##
|
18
18
|
# For RubyGems backwards compatibility
|
19
19
|
|
20
|
-
|
20
|
+
require_relative 'formatter'
|
21
21
|
|
22
22
|
##
|
23
23
|
# The RI driver implements the command-line ri tool.
|
@@ -356,7 +356,7 @@ or the PAGER environment variable.
|
|
356
356
|
end
|
357
357
|
end
|
358
358
|
|
359
|
-
argv = ENV['RI'].to_s.split.concat argv
|
359
|
+
argv = ENV['RI'].to_s.split(' ').concat argv
|
360
360
|
|
361
361
|
opts.parse! argv
|
362
362
|
|
@@ -1228,7 +1228,7 @@ or the PAGER environment variable.
|
|
1228
1228
|
# +cache+ indicate if it is a class or instance method.
|
1229
1229
|
|
1230
1230
|
def load_method store, cache, klass, type, name
|
1231
|
-
methods = store.
|
1231
|
+
methods = store.public_send(cache)[klass]
|
1232
1232
|
|
1233
1233
|
return unless methods
|
1234
1234
|
|
@@ -1521,7 +1521,7 @@ or the PAGER environment variable.
|
|
1521
1521
|
pagers.compact.uniq.each do |pager|
|
1522
1522
|
next unless pager
|
1523
1523
|
|
1524
|
-
pager_cmd = pager.split.first
|
1524
|
+
pager_cmd = pager.split(' ').first
|
1525
1525
|
|
1526
1526
|
next unless in_path? pager_cmd
|
1527
1527
|
|
@@ -1551,7 +1551,11 @@ or the PAGER environment variable.
|
|
1551
1551
|
# Starts a WEBrick server for ri.
|
1552
1552
|
|
1553
1553
|
def start_server
|
1554
|
-
|
1554
|
+
begin
|
1555
|
+
require 'webrick'
|
1556
|
+
rescue LoadError
|
1557
|
+
abort "webrick is not found. You may need to `gem install webrick` to install webrick."
|
1558
|
+
end
|
1555
1559
|
|
1556
1560
|
server = WEBrick::HTTPServer.new :Port => @server
|
1557
1561
|
|
data/lib/rdoc/ri/paths.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
require_relative '../rdoc'
|
3
3
|
|
4
4
|
##
|
5
5
|
# The directories where ri data lives. Paths can be enumerated via ::each, or
|
@@ -12,23 +12,9 @@ module RDoc::RI::Paths
|
|
12
12
|
|
13
13
|
version = RbConfig::CONFIG['ruby_version']
|
14
14
|
|
15
|
-
BASE =
|
16
|
-
File.join RbConfig::CONFIG['ridir'], version
|
17
|
-
else
|
18
|
-
File.join RbConfig::CONFIG['datadir'], 'ri', version
|
19
|
-
end
|
15
|
+
BASE = File.join RbConfig::CONFIG['ridir'], version
|
20
16
|
|
21
|
-
|
22
|
-
File.expand_path('~')
|
23
|
-
rescue ArgumentError
|
24
|
-
end
|
25
|
-
|
26
|
-
homedir ||= ENV['HOME'] ||
|
27
|
-
ENV['USERPROFILE'] || ENV['HOMEPATH'] # for 1.8 compatibility
|
28
|
-
|
29
|
-
HOMEDIR = if homedir then
|
30
|
-
File.join homedir, ".rdoc"
|
31
|
-
end
|
17
|
+
HOMEDIR = RDoc.home
|
32
18
|
#:startdoc:
|
33
19
|
|
34
20
|
##
|
data/lib/rdoc/ri/task.rb
CHANGED
data/lib/rdoc/rubygems_hook.rb
CHANGED
@@ -70,7 +70,7 @@ class RDoc::RubygemsHook
|
|
70
70
|
def self.load_rdoc
|
71
71
|
return if @rdoc_version
|
72
72
|
|
73
|
-
|
73
|
+
require_relative 'rdoc'
|
74
74
|
|
75
75
|
@rdoc_version = Gem::Version.new ::RDoc::VERSION
|
76
76
|
end
|
@@ -158,7 +158,7 @@ class RDoc::RubygemsHook
|
|
158
158
|
|
159
159
|
case config_args = Gem.configuration[:rdoc]
|
160
160
|
when String then
|
161
|
-
args = args.concat config_args.split
|
161
|
+
args = args.concat config_args.split(' ')
|
162
162
|
when Array then
|
163
163
|
args = args.concat config_args
|
164
164
|
end
|
data/lib/rdoc/servlet.rb
CHANGED
@@ -3,7 +3,12 @@ require 'rdoc'
|
|
3
3
|
require 'erb'
|
4
4
|
require 'time'
|
5
5
|
require 'json'
|
6
|
-
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'webrick'
|
9
|
+
rescue LoadError
|
10
|
+
abort "webrick is not found. You may need to `gem install webrick` to install webrick."
|
11
|
+
end
|
7
12
|
|
8
13
|
##
|
9
14
|
# This is a WEBrick servlet that allows you to browse ri documentation.
|
@@ -102,9 +107,9 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|
102
107
|
res.body = File.read asset_path
|
103
108
|
|
104
109
|
res.content_type = case req.path
|
105
|
-
when /
|
106
|
-
when /
|
107
|
-
else
|
110
|
+
when /\.css\z/ then 'text/css'
|
111
|
+
when /\.js\z/ then 'application/javascript'
|
112
|
+
else 'application/octet-stream'
|
108
113
|
end
|
109
114
|
end
|
110
115
|
|
@@ -112,7 +117,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|
112
117
|
# GET request entry point. Fills in +res+ for the path, etc. in +req+.
|
113
118
|
|
114
119
|
def do_GET req, res
|
115
|
-
req.path.sub!(
|
120
|
+
req.path.sub!(/\A#{Regexp.escape @mount_path}/, '') if @mount_path
|
116
121
|
|
117
122
|
case req.path
|
118
123
|
when '/' then
|
@@ -145,11 +150,14 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|
145
150
|
# +generator+ is used to create the page.
|
146
151
|
|
147
152
|
def documentation_page store, generator, path, req, res
|
148
|
-
|
153
|
+
text_name = path.chomp '.html'
|
154
|
+
name = text_name.gsub '/', '::'
|
149
155
|
|
150
156
|
if klass = store.find_class_or_module(name) then
|
151
157
|
res.body = generator.generate_class klass
|
152
|
-
elsif page = store.find_text_page(name.sub(/_([^_]*)
|
158
|
+
elsif page = store.find_text_page(name.sub(/_([^_]*)\z/, '.\1')) then
|
159
|
+
res.body = generator.generate_page page
|
160
|
+
elsif page = store.find_text_page(text_name.sub(/_([^_]*)\z/, '.\1')) then
|
153
161
|
res.body = generator.generate_page page
|
154
162
|
else
|
155
163
|
not_found generator, req, res
|
@@ -416,7 +424,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
|
|
416
424
|
RDoc::Store.new RDoc::RI::Paths.system_dir, :system
|
417
425
|
when 'site' then
|
418
426
|
RDoc::Store.new RDoc::RI::Paths.site_dir, :site
|
419
|
-
when
|
427
|
+
when /\Aextra-(\d+)\z/ then
|
420
428
|
index = $1.to_i - 1
|
421
429
|
ri_dir = installed_docs[index][4]
|
422
430
|
RDoc::Store.new ri_dir, :extra
|
data/lib/rdoc/store.rb
CHANGED
@@ -482,7 +482,7 @@ class RDoc::Store
|
|
482
482
|
when :gem then
|
483
483
|
parent = File.expand_path '..', @path
|
484
484
|
"gem #{File.basename parent}"
|
485
|
-
when :home then
|
485
|
+
when :home then RDoc.home
|
486
486
|
when :site then 'ruby site'
|
487
487
|
when :system then 'ruby core'
|
488
488
|
else @path
|
@@ -723,7 +723,7 @@ class RDoc::Store
|
|
723
723
|
|
724
724
|
def page name
|
725
725
|
@text_files_hash.each_value.find do |file|
|
726
|
-
file.page_name == name
|
726
|
+
file.page_name == name or file.base_name == name
|
727
727
|
end
|
728
728
|
end
|
729
729
|
|
@@ -795,10 +795,8 @@ class RDoc::Store
|
|
795
795
|
|
796
796
|
return if @dry_run
|
797
797
|
|
798
|
-
marshal = Marshal.dump @cache
|
799
|
-
|
800
798
|
File.open cache_path, 'wb' do |io|
|
801
|
-
|
799
|
+
Marshal.dump @cache, io
|
802
800
|
end
|
803
801
|
end
|
804
802
|
|
@@ -871,10 +869,8 @@ class RDoc::Store
|
|
871
869
|
|
872
870
|
FileUtils.rm_f to_delete
|
873
871
|
|
874
|
-
marshal = Marshal.dump klass
|
875
|
-
|
876
872
|
File.open path, 'wb' do |io|
|
877
|
-
|
873
|
+
Marshal.dump klass, io
|
878
874
|
end
|
879
875
|
end
|
880
876
|
|
@@ -896,10 +892,8 @@ class RDoc::Store
|
|
896
892
|
|
897
893
|
return if @dry_run
|
898
894
|
|
899
|
-
marshal = Marshal.dump method
|
900
|
-
|
901
895
|
File.open method_file(full_name, method.full_name), 'wb' do |io|
|
902
|
-
|
896
|
+
Marshal.dump method, io
|
903
897
|
end
|
904
898
|
end
|
905
899
|
|
@@ -918,10 +912,8 @@ class RDoc::Store
|
|
918
912
|
|
919
913
|
return if @dry_run
|
920
914
|
|
921
|
-
marshal = Marshal.dump page
|
922
|
-
|
923
915
|
File.open path, 'wb' do |io|
|
924
|
-
|
916
|
+
Marshal.dump page, io
|
925
917
|
end
|
926
918
|
end
|
927
919
|
|