rdoc 4.1.2 → 4.2.0
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/.autotest +3 -1
- data/History.rdoc +70 -3
- data/LEGAL.rdoc +11 -0
- data/Manifest.txt +6 -2
- data/Rakefile +8 -1
- data/lib/rdoc.rb +3 -1
- data/lib/rdoc/context.rb +2 -0
- data/lib/rdoc/encoding.rb +3 -1
- data/lib/rdoc/generator.rb +1 -0
- data/lib/rdoc/generator/darkfish.rb +3 -2
- data/lib/rdoc/generator/json_index.rb +44 -0
- data/lib/rdoc/generator/pot.rb +97 -0
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +9 -12
- data/lib/rdoc/generator/template/darkfish/{fonts.css → css/fonts.css} +0 -0
- data/lib/rdoc/generator/template/darkfish/{rdoc.css → css/rdoc.css} +11 -1
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +32 -11
- data/lib/rdoc/markdown.kpeg +6 -1
- data/lib/rdoc/markdown.rb +174 -2
- data/lib/rdoc/markup.rb +2 -2
- data/lib/rdoc/markup/attribute_manager.rb +1 -1
- data/lib/rdoc/markup/to_html.rb +5 -4
- data/lib/rdoc/markup/to_label.rb +1 -1
- data/lib/rdoc/method_attr.rb +11 -3
- data/lib/rdoc/options.rb +55 -3
- data/lib/rdoc/parser.rb +1 -1
- data/lib/rdoc/parser/c.rb +5 -6
- data/lib/rdoc/parser/changelog.rb +7 -3
- data/lib/rdoc/parser/ruby.rb +8 -12
- data/lib/rdoc/rd/block_parser.rb +1 -1
- data/lib/rdoc/rd/inline_parser.rb +1 -1
- data/lib/rdoc/rdoc.rb +5 -3
- data/lib/rdoc/ruby_lex.rb +3 -3
- data/lib/rdoc/ruby_token.rb +7 -7
- data/lib/rdoc/single_class.rb +4 -0
- data/lib/rdoc/stats.rb +4 -0
- data/lib/rdoc/stats/normal.rb +22 -11
- data/lib/rdoc/task.rb +1 -1
- data/lib/rdoc/test_case.rb +1 -1
- data/lib/rdoc/text.rb +9 -0
- data/lib/rdoc/token_stream.rb +1 -1
- data/test/test_rdoc_context.rb +2 -0
- data/test/test_rdoc_encoding.rb +23 -0
- data/test/test_rdoc_generator_darkfish.rb +2 -2
- data/test/test_rdoc_generator_json_index.rb +55 -0
- data/test/test_rdoc_generator_markup.rb +1 -1
- data/test/test_rdoc_generator_pot.rb +91 -0
- data/test/test_rdoc_generator_pot_po.rb +51 -0
- data/test/test_rdoc_generator_pot_po_entry.rb +139 -0
- data/test/test_rdoc_i18n_locale.rb +73 -0
- data/test/test_rdoc_i18n_text.rb +123 -0
- data/test/test_rdoc_markup_attribute_manager.rb +6 -0
- data/test/test_rdoc_markup_heading.rb +4 -4
- data/test/test_rdoc_markup_pre_process.rb +1 -1
- data/test/test_rdoc_markup_to_html.rb +46 -26
- data/test/test_rdoc_markup_to_html_snippet.rb +8 -7
- data/test/test_rdoc_markup_to_label.rb +4 -4
- data/test/test_rdoc_method_attr.rb +31 -1
- data/test/test_rdoc_normal_class.rb +4 -4
- data/test/test_rdoc_options.rb +19 -0
- data/test/test_rdoc_parser.rb +16 -1
- data/test/test_rdoc_parser_c.rb +31 -1
- data/test/test_rdoc_parser_changelog.rb +1 -1
- data/test/test_rdoc_parser_markdown.rb +1 -1
- data/test/test_rdoc_parser_rd.rb +1 -1
- data/test/test_rdoc_parser_ruby.rb +22 -25
- data/test/test_rdoc_parser_simple.rb +1 -1
- data/test/test_rdoc_rd_block_parser.rb +3 -1
- data/test/test_rdoc_rdoc.rb +24 -3
- data/test/test_rdoc_ruby_lex.rb +11 -0
- data/test/test_rdoc_rubygems_hook.rb +0 -3
- data/test/test_rdoc_single_class.rb +13 -5
- data/test/test_rdoc_stats.rb +55 -0
- data/test/test_rdoc_task.rb +1 -0
- metadata +18 -7
data/lib/rdoc/parser.rb
CHANGED
@@ -83,7 +83,7 @@ class RDoc::Parser
|
|
83
83
|
mode = "r"
|
84
84
|
s.sub!(/\A#!.*\n/, '') # assume shebang line isn't longer than 1024.
|
85
85
|
encoding = s[/^\s*\#\s*(?:-\*-\s*)?(?:en)?coding:\s*([^\s;]+?)(?:-\*-|[\s;])/, 1]
|
86
|
-
mode = "
|
86
|
+
mode = "rb:#{encoding}" if encoding
|
87
87
|
s = File.open(file, mode) {|f| f.gets(nil, 1024)}
|
88
88
|
|
89
89
|
not s.valid_encoding?
|
data/lib/rdoc/parser/c.rb
CHANGED
@@ -611,7 +611,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
611
611
|
def find_body class_name, meth_name, meth_obj, file_content, quiet = false
|
612
612
|
case file_content
|
613
613
|
when %r%((?>/\*.*?\*/\s*)?)
|
614
|
-
((?:(
|
614
|
+
((?:(?:\w+)\s+)?
|
615
615
|
(?:intern\s+)?VALUE\s+#{meth_name}
|
616
616
|
\s*(\([^)]*\))([^;]|$))%xm then
|
617
617
|
comment = RDoc::Comment.new $1, @top_level
|
@@ -745,11 +745,11 @@ class RDoc::Parser::C < RDoc::Parser
|
|
745
745
|
elsif @content =~ %r%Document-(?:class|module):\s+#{class_name}\s*?
|
746
746
|
(?:<\s+[:,\w]+)?\n((?>.*?\*/))%xm then
|
747
747
|
comment = "/*\n#{$1}"
|
748
|
-
elsif @content =~ %r
|
749
|
-
([\w\.\s]+\s* = \s+)?rb_define_(class|module)
|
748
|
+
elsif @content =~ %r%((?>/\*.*?\*/\s+))
|
749
|
+
([\w\.\s]+\s* = \s+)?rb_define_(class|module)[\t (]*?"(#{class_name})"%xm then
|
750
750
|
comment = $1
|
751
|
-
elsif @content =~ %r
|
752
|
-
([\w
|
751
|
+
elsif @content =~ %r%((?>/\*.*?\*/\s+))
|
752
|
+
([\w\. \t]+ = \s+)?rb_define_(class|module)_under[\t\w, (]*?"(#{class_name.split('::').last})"%xm then
|
753
753
|
comment = $1
|
754
754
|
else
|
755
755
|
comment = ''
|
@@ -1186,7 +1186,6 @@ class RDoc::Parser::C < RDoc::Parser
|
|
1186
1186
|
|
1187
1187
|
if hash then
|
1188
1188
|
args << "p#{position} = {}"
|
1189
|
-
position += 1
|
1190
1189
|
end
|
1191
1190
|
|
1192
1191
|
args << '&block' if block
|
@@ -145,10 +145,14 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
|
|
145
145
|
# HACK Ruby 1.8 does not raise ArgumentError for Time.parse "Other"
|
146
146
|
entry_name = nil unless entry_name =~ /#{time.year}/
|
147
147
|
rescue NoMethodError
|
148
|
-
|
149
|
-
|
148
|
+
# HACK Ruby 2.1.2 and earlier raises NoMethodError if time part is absent
|
149
|
+
entry_name.split ' ', 2
|
150
150
|
rescue ArgumentError
|
151
|
-
|
151
|
+
if /out of range/ =~ $!.message
|
152
|
+
Time.parse(entry_name.split(' ', 2)[0]) rescue entry_name = nil
|
153
|
+
else
|
154
|
+
entry_name = nil
|
155
|
+
end
|
152
156
|
end
|
153
157
|
|
154
158
|
entry_body = []
|
data/lib/rdoc/parser/ruby.rb
CHANGED
@@ -187,15 +187,16 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
187
187
|
end
|
188
188
|
|
189
189
|
##
|
190
|
-
# Extracts the visibility information for the visibility token +tk
|
190
|
+
# Extracts the visibility information for the visibility token +tk+
|
191
|
+
# and +single+ class type identifier.
|
191
192
|
#
|
192
193
|
# Returns the visibility type (a string), the visibility (a symbol) and
|
193
194
|
# +singleton+ if the methods following should be converted to singleton
|
194
195
|
# methods.
|
195
196
|
|
196
|
-
def get_visibility_information tk # :nodoc:
|
197
|
+
def get_visibility_information tk, single # :nodoc:
|
197
198
|
vis_type = tk.name
|
198
|
-
singleton =
|
199
|
+
singleton = single == SINGLE
|
199
200
|
|
200
201
|
vis =
|
201
202
|
case vis_type
|
@@ -845,7 +846,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
845
846
|
# true, no found constants will be added to RDoc.
|
846
847
|
|
847
848
|
def parse_constant container, tk, comment, ignore_constants = false
|
848
|
-
prev_container = container
|
849
849
|
offset = tk.seek
|
850
850
|
line_no = tk.line_no
|
851
851
|
|
@@ -868,8 +868,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
868
868
|
end
|
869
869
|
|
870
870
|
unless TkASSIGN === eq_tk then
|
871
|
-
suppress_parents container, prev_container
|
872
|
-
|
873
871
|
unget_tk eq_tk
|
874
872
|
return false
|
875
873
|
end
|
@@ -893,7 +891,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
893
891
|
read_documentation_modifiers con, RDoc::CONSTANT_MODIFIERS
|
894
892
|
|
895
893
|
@stats.add_constant con
|
896
|
-
|
894
|
+
container.add_constant con
|
897
895
|
|
898
896
|
true
|
899
897
|
end
|
@@ -1309,7 +1307,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1309
1307
|
return unless name
|
1310
1308
|
|
1311
1309
|
meth = RDoc::AnyMethod.new get_tkread, name
|
1312
|
-
meth.singleton = singleton
|
1310
|
+
meth.singleton = single == SINGLE ? true : singleton
|
1313
1311
|
|
1314
1312
|
record_location meth
|
1315
1313
|
meth.offset = offset
|
@@ -1879,9 +1877,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1879
1877
|
# Determines the visibility in +container+ from +tk+
|
1880
1878
|
|
1881
1879
|
def parse_visibility(container, single, tk)
|
1882
|
-
singleton =
|
1883
|
-
|
1884
|
-
vis_type, vis, singleton = get_visibility_information tk
|
1880
|
+
vis_type, vis, singleton = get_visibility_information tk, single
|
1885
1881
|
|
1886
1882
|
skip_tkspace_comment false
|
1887
1883
|
|
@@ -2082,7 +2078,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
2082
2078
|
|
2083
2079
|
def skip_for_variable
|
2084
2080
|
skip_tkspace false
|
2085
|
-
|
2081
|
+
get_tk
|
2086
2082
|
skip_tkspace false
|
2087
2083
|
tk = get_tk
|
2088
2084
|
unget_tk(tk) unless TkIN === tk
|
data/lib/rdoc/rd/block_parser.rb
CHANGED
data/lib/rdoc/rdoc.rb
CHANGED
@@ -305,6 +305,9 @@ option)
|
|
305
305
|
when "directory" then
|
306
306
|
next if rel_file_name == "CVS" || rel_file_name == ".svn"
|
307
307
|
|
308
|
+
created_rid = File.join rel_file_name, "created.rid"
|
309
|
+
next if File.file? created_rid
|
310
|
+
|
308
311
|
dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
|
309
312
|
|
310
313
|
if File.file? dot_doc then
|
@@ -336,7 +339,7 @@ option)
|
|
336
339
|
# Parses +filename+ and returns an RDoc::TopLevel
|
337
340
|
|
338
341
|
def parse_file filename
|
339
|
-
if
|
342
|
+
if Object.const_defined? :Encoding then
|
340
343
|
encoding = @options.encoding
|
341
344
|
filename = filename.encode encoding
|
342
345
|
end
|
@@ -411,8 +414,6 @@ The internal error was:
|
|
411
414
|
|
412
415
|
return [] if file_list.empty?
|
413
416
|
|
414
|
-
file_info = []
|
415
|
-
|
416
417
|
@stats.begin_adding
|
417
418
|
|
418
419
|
file_info = file_list.map do |filename|
|
@@ -565,4 +566,5 @@ end
|
|
565
566
|
# require built-in generators after discovery in case they've been replaced
|
566
567
|
require 'rdoc/generator/darkfish'
|
567
568
|
require 'rdoc/generator/ri'
|
569
|
+
require 'rdoc/generator/pot'
|
568
570
|
|
data/lib/rdoc/ruby_lex.rb
CHANGED
@@ -434,7 +434,7 @@ class RDoc::RubyLex
|
|
434
434
|
|op, io|
|
435
435
|
@ltype = "="
|
436
436
|
res = ''
|
437
|
-
nil until
|
437
|
+
nil until getc == "\n"
|
438
438
|
|
439
439
|
until ( peek_equal?("=end") && peek(4) =~ /\s/ ) do
|
440
440
|
(ch = getc)
|
@@ -1184,9 +1184,9 @@ class RDoc::RubyLex
|
|
1184
1184
|
str = if ltype == quoted and %w[" ' /].include? ltype then
|
1185
1185
|
ltype.dup
|
1186
1186
|
elsif RUBY_VERSION > '1.9' then
|
1187
|
-
"%#{type or PERCENT_LTYPE.key ltype}#{PERCENT_PAREN_REV[quoted]}"
|
1187
|
+
"%#{type or PERCENT_LTYPE.key ltype}#{PERCENT_PAREN_REV[quoted]||quoted}"
|
1188
1188
|
else
|
1189
|
-
"%#{type or PERCENT_LTYPE.index ltype}#{PERCENT_PAREN_REV[quoted]}"
|
1189
|
+
"%#{type or PERCENT_LTYPE.index ltype}#{PERCENT_PAREN_REV[quoted]||quoted}"
|
1190
1190
|
end
|
1191
1191
|
|
1192
1192
|
subtype = nil
|
data/lib/rdoc/ruby_token.rb
CHANGED
@@ -38,9 +38,9 @@ module RDoc::RubyToken
|
|
38
38
|
@text = text
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
attr_reader :seek
|
42
|
+
attr_reader :line_no
|
43
|
+
attr_reader :char_no
|
44
44
|
|
45
45
|
attr_accessor :text
|
46
46
|
|
@@ -73,7 +73,7 @@ module RDoc::RubyToken
|
|
73
73
|
@node = node
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
attr_reader:node
|
77
77
|
|
78
78
|
def ==(other)
|
79
79
|
self.class == other.class and
|
@@ -101,7 +101,7 @@ module RDoc::RubyToken
|
|
101
101
|
super(seek, line_no, char_no)
|
102
102
|
@name = name
|
103
103
|
end
|
104
|
-
|
104
|
+
attr_reader:name
|
105
105
|
|
106
106
|
def ==(other)
|
107
107
|
self.class == other.class and
|
@@ -192,7 +192,7 @@ module RDoc::RubyToken
|
|
192
192
|
@text = nil
|
193
193
|
end
|
194
194
|
|
195
|
-
|
195
|
+
attr_reader:op
|
196
196
|
|
197
197
|
def ==(other)
|
198
198
|
self.class == other.class and
|
@@ -217,7 +217,7 @@ module RDoc::RubyToken
|
|
217
217
|
super(seek, line_no, char_no)
|
218
218
|
@name = name
|
219
219
|
end
|
220
|
-
|
220
|
+
attr_reader:name
|
221
221
|
|
222
222
|
def ==(other)
|
223
223
|
self.class == other.class and
|
data/lib/rdoc/single_class.rb
CHANGED
data/lib/rdoc/stats.rb
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
class RDoc::Stats
|
6
6
|
|
7
|
+
include RDoc::Text
|
8
|
+
|
7
9
|
##
|
8
10
|
# Output level for the coverage report
|
9
11
|
|
@@ -438,6 +440,8 @@ class RDoc::Stats
|
|
438
440
|
|
439
441
|
params = method.param_list
|
440
442
|
|
443
|
+
params = params.map { |param| param.gsub(/^\*\*?/, '') }
|
444
|
+
|
441
445
|
return 0, [] if params.empty?
|
442
446
|
|
443
447
|
document = parse method.comment
|
data/lib/rdoc/stats/normal.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
begin
|
2
|
+
require 'io/console/size'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
1
6
|
##
|
2
7
|
# Stats printer that prints just the files being documented with a progress
|
3
8
|
# bar
|
@@ -5,15 +10,14 @@
|
|
5
10
|
class RDoc::Stats::Normal < RDoc::Stats::Quiet
|
6
11
|
|
7
12
|
def begin_adding # :nodoc:
|
8
|
-
puts "Parsing sources..."
|
13
|
+
puts "Parsing sources..."
|
14
|
+
@last_width = 0
|
9
15
|
end
|
10
16
|
|
11
17
|
##
|
12
18
|
# Prints a file with a progress bar
|
13
19
|
|
14
20
|
def print_file files_so_far, filename
|
15
|
-
return unless $stdout.tty?
|
16
|
-
|
17
21
|
progress_bar = sprintf("%3d%% [%2d/%2d] ",
|
18
22
|
100 * files_so_far / @num_files,
|
19
23
|
files_so_far,
|
@@ -21,7 +25,11 @@ class RDoc::Stats::Normal < RDoc::Stats::Quiet
|
|
21
25
|
|
22
26
|
# Print a progress bar, but make sure it fits on a single line. Filename
|
23
27
|
# will be truncated if necessary.
|
24
|
-
terminal_width = (
|
28
|
+
terminal_width = if defined?(IO) && IO.respond_to?(:console_size)
|
29
|
+
IO.console_size[1].to_i.nonzero? || 80
|
30
|
+
else
|
31
|
+
80
|
32
|
+
end
|
25
33
|
max_filename_size = terminal_width - progress_bar.size
|
26
34
|
|
27
35
|
if filename.size > max_filename_size then
|
@@ -30,18 +38,21 @@ class RDoc::Stats::Normal < RDoc::Stats::Quiet
|
|
30
38
|
filename[0..2] = "..."
|
31
39
|
end
|
32
40
|
|
33
|
-
# Pad the line with whitespaces so that leftover output from the
|
34
|
-
# previous line doesn't show up.
|
35
41
|
line = "#{progress_bar}#{filename}"
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
42
|
+
if $stdout.tty?
|
43
|
+
# Clean the line with whitespaces so that leftover output from the
|
44
|
+
# previous line doesn't show up.
|
45
|
+
$stdout.print("\r" << (" " * @last_width) << ("\b" * @last_width) << "\r") if @last_width && @last_width > 0
|
46
|
+
@last_width = line.size
|
47
|
+
$stdout.print("#{line}\r")
|
48
|
+
else
|
49
|
+
$stdout.puts(line)
|
50
|
+
end
|
40
51
|
$stdout.flush
|
41
52
|
end
|
42
53
|
|
43
54
|
def done_adding # :nodoc:
|
44
|
-
puts
|
55
|
+
puts
|
45
56
|
end
|
46
57
|
|
47
58
|
end
|
data/lib/rdoc/task.rb
CHANGED
data/lib/rdoc/test_case.rb
CHANGED
data/lib/rdoc/text.rb
CHANGED
@@ -103,6 +103,15 @@ module RDoc::Text
|
|
103
103
|
# Requires the including class to implement #formatter
|
104
104
|
|
105
105
|
def markup text
|
106
|
+
if @store.rdoc.options
|
107
|
+
locale = @store.rdoc.options.locale
|
108
|
+
else
|
109
|
+
locale = nil
|
110
|
+
end
|
111
|
+
if locale
|
112
|
+
i18n_text = RDoc::I18n::Text.new(text)
|
113
|
+
text = i18n_text.translate(locale)
|
114
|
+
end
|
106
115
|
parse(text).accept formatter
|
107
116
|
end
|
108
117
|
|
data/lib/rdoc/token_stream.rb
CHANGED
data/test/test_rdoc_context.rb
CHANGED
data/test/test_rdoc_encoding.rb
CHANGED
@@ -10,6 +10,12 @@ class TestRDocEncoding < RDoc::TestCase
|
|
10
10
|
@tempfile = Tempfile.new 'test_rdoc_encoding'
|
11
11
|
end
|
12
12
|
|
13
|
+
def teardown
|
14
|
+
@tempfile.close!
|
15
|
+
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
13
19
|
def test_class_read_file
|
14
20
|
@tempfile.write "hi everybody"
|
15
21
|
@tempfile.flush
|
@@ -125,6 +131,23 @@ class TestRDocEncoding < RDoc::TestCase
|
|
125
131
|
assert_equal "hi everybody", content, bug3360
|
126
132
|
end
|
127
133
|
|
134
|
+
def test_class_read_file_encoding_iso_2022_jp
|
135
|
+
skip "Encoding not implemented" unless Object.const_defined? :Encoding
|
136
|
+
|
137
|
+
input = "# coding: ISO-2022-JP\n:\e$B%3%^%s%I\e(B:"
|
138
|
+
|
139
|
+
@tempfile.write input
|
140
|
+
@tempfile.flush
|
141
|
+
|
142
|
+
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
|
143
|
+
|
144
|
+
expected = ":\xe3\x82\xb3\xe3\x83\x9e\xe3\x83\xb3\xe3\x83\x89:"
|
145
|
+
expected.force_encoding Encoding::UTF_8
|
146
|
+
|
147
|
+
assert_equal expected, contents
|
148
|
+
assert_equal Encoding::UTF_8, contents.encoding
|
149
|
+
end
|
150
|
+
|
128
151
|
def test_class_set_encoding
|
129
152
|
s = "# coding: UTF-8\n"
|
130
153
|
RDoc::Encoding.set_encoding s
|
@@ -76,8 +76,8 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
|
|
76
76
|
assert_file 'table_of_contents.html'
|
77
77
|
assert_file 'js/search_index.js'
|
78
78
|
|
79
|
-
assert_hard_link 'rdoc.css'
|
80
|
-
assert_hard_link 'fonts.css'
|
79
|
+
assert_hard_link 'css/rdoc.css'
|
80
|
+
assert_hard_link 'css/fonts.css'
|
81
81
|
|
82
82
|
assert_hard_link 'fonts/SourceCodePro-Bold.ttf'
|
83
83
|
assert_hard_link 'fonts/SourceCodePro-Regular.ttf'
|