rdoc 6.1.2.1 → 6.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/.gitignore +1 -0
- data/Gemfile +9 -0
- data/README.rdoc +0 -1
- data/Rakefile +1 -1
- data/lib/rdoc/class_module.rb +1 -1
- data/lib/rdoc/comment.rb +7 -1
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +13 -5
- data/lib/rdoc/markup/parser.rb +58 -42
- data/lib/rdoc/markup/to_html_crossref.rb +5 -1
- data/lib/rdoc/markup.rb +0 -2
- data/lib/rdoc/options.rb +4 -1
- data/lib/rdoc/parser/c.rb +116 -126
- data/lib/rdoc/parser/ripper_state_lex.rb +2 -1
- data/lib/rdoc/parser/ruby.rb +3 -3
- data/lib/rdoc/rd/block_parser.rb +2 -2
- data/lib/rdoc/rd/inline_parser.rb +2 -2
- data/lib/rdoc/rdoc.rb +2 -2
- data/lib/rdoc/ri/paths.rb +1 -1
- data/lib/rdoc/servlet.rb +10 -7
- data/lib/rdoc/store.rb +4 -12
- 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/rdoc.gemspec +1 -7
- metadata +7 -81
- 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
data/lib/rdoc/parser/c.rb
CHANGED
@@ -3,15 +3,15 @@ require 'tsort'
|
|
3
3
|
|
4
4
|
##
|
5
5
|
# RDoc::Parser::C attempts to parse C extension files. It looks for
|
6
|
-
# the standard patterns that you find in extensions:
|
7
|
-
# rb_define_method
|
6
|
+
# the standard patterns that you find in extensions: +rb_define_class+,
|
7
|
+
# +rb_define_method+ and so on. It tries to find the corresponding
|
8
8
|
# C source for the methods and extract comments, but if we fail
|
9
9
|
# we don't worry too much.
|
10
10
|
#
|
11
11
|
# The comments associated with a Ruby method are extracted from the C
|
12
12
|
# comment block associated with the routine that _implements_ that
|
13
13
|
# method, that is to say the method whose name is given in the
|
14
|
-
#
|
14
|
+
# +rb_define_method+ call. For example, you might write:
|
15
15
|
#
|
16
16
|
# /*
|
17
17
|
# * Returns a new array that is a one-dimensional flattening of this
|
@@ -24,8 +24,7 @@ require 'tsort'
|
|
24
24
|
# * a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
25
25
|
# */
|
26
26
|
# static VALUE
|
27
|
-
# rb_ary_flatten(ary)
|
28
|
-
# VALUE ary;
|
27
|
+
# rb_ary_flatten(VALUE ary)
|
29
28
|
# {
|
30
29
|
# ary = rb_obj_dup(ary);
|
31
30
|
# rb_ary_flatten_bang(ary);
|
@@ -35,16 +34,16 @@ require 'tsort'
|
|
35
34
|
# ...
|
36
35
|
#
|
37
36
|
# void
|
38
|
-
# Init_Array()
|
37
|
+
# Init_Array(void)
|
39
38
|
# {
|
40
39
|
# ...
|
41
40
|
# rb_define_method(rb_cArray, "flatten", rb_ary_flatten, 0);
|
42
41
|
#
|
43
|
-
# Here RDoc will determine from the rb_define_method line that there's a
|
42
|
+
# Here RDoc will determine from the +rb_define_method+ line that there's a
|
44
43
|
# method called "flatten" in class Array, and will look for the implementation
|
45
|
-
# in the method rb_ary_flatten
|
44
|
+
# in the method +rb_ary_flatten+. It will then use the comment from that
|
46
45
|
# method in the HTML output. This method must be in the same source file
|
47
|
-
# as the rb_define_method
|
46
|
+
# as the +rb_define_method+.
|
48
47
|
#
|
49
48
|
# The comment blocks may include special directives:
|
50
49
|
#
|
@@ -70,15 +69,15 @@ require 'tsort'
|
|
70
69
|
# [Document-variable: +name+]
|
71
70
|
# Documentation for the named +rb_define_variable+
|
72
71
|
#
|
73
|
-
# [Document-method
|
72
|
+
# [Document-method\: +method_name+]
|
74
73
|
# Documentation for the named method. Use this when the method name is
|
75
74
|
# unambiguous.
|
76
75
|
#
|
77
|
-
# [Document-method
|
76
|
+
# [Document-method\: <tt>ClassName::method_name</tt>]
|
78
77
|
# Documentation for a singleton method in the given class. Use this when
|
79
78
|
# the method name alone is ambiguous.
|
80
79
|
#
|
81
|
-
# [Document-method
|
80
|
+
# [Document-method\: <tt>ClassName#method_name</tt>]
|
82
81
|
# Documentation for a instance method in the given class. Use this when the
|
83
82
|
# method name alone is ambiguous.
|
84
83
|
#
|
@@ -325,12 +324,100 @@ class RDoc::Parser::C < RDoc::Parser
|
|
325
324
|
# Scans #content for rb_define_class, boot_defclass, rb_define_class_under
|
326
325
|
# and rb_singleton_class
|
327
326
|
|
328
|
-
def
|
329
|
-
do_boot_defclass
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
327
|
+
def do_classes_and_modules
|
328
|
+
do_boot_defclass if @file_name == "class.c"
|
329
|
+
|
330
|
+
@content.scan(
|
331
|
+
%r(
|
332
|
+
(?<var_name>[\w\.]+)\s* =
|
333
|
+
\s*rb_(?:
|
334
|
+
define_(?:
|
335
|
+
class(?: # rb_define_class(class_name_1, parent_name_1)
|
336
|
+
\s*\(
|
337
|
+
\s*"(?<class_name_1>\w+)",
|
338
|
+
\s*(?<parent_name_1>\w+)\s*
|
339
|
+
\)
|
340
|
+
|
|
341
|
+
_under\s*\( # rb_define_class_under(class_under, class_name2, parent_name2...)
|
342
|
+
\s* (?<class_under>\w+),
|
343
|
+
\s* "(?<class_name_2>\w+)",
|
344
|
+
\s*
|
345
|
+
(?:
|
346
|
+
(?<parent_name_2>[\w\*\s\(\)\.\->]+) |
|
347
|
+
rb_path2class\("(?<path>[\w:]+)"\)
|
348
|
+
)
|
349
|
+
\s*\)
|
350
|
+
)
|
351
|
+
|
|
352
|
+
module(?: # rb_define_module(module_name_1)
|
353
|
+
\s*\(
|
354
|
+
\s*"(?<module_name_1>\w+)"\s*
|
355
|
+
\)
|
356
|
+
|
|
357
|
+
_under\s*\( # rb_define_module_under(module_under, module_name_1)
|
358
|
+
\s*(?<module_under>\w+),
|
359
|
+
\s*"(?<module_name_2>\w+)"
|
360
|
+
\s*\)
|
361
|
+
)
|
362
|
+
)
|
363
|
+
|
|
364
|
+
struct_define_without_accessor\s*\( # rb_struct_define_without_accessor(class_name_3, parent_name_3, ...)
|
365
|
+
\s*"(?<class_name_3>\w+)",
|
366
|
+
\s*(?<parent_name_3>\w+),
|
367
|
+
\s*\w+, # Allocation function
|
368
|
+
(?:\s*"\w+",)* # Attributes
|
369
|
+
\s*NULL
|
370
|
+
\)
|
371
|
+
|
|
372
|
+
singleton_class\s*\( # rb_singleton_class(target_class_name)
|
373
|
+
\s*(?<target_class_name>\w+)
|
374
|
+
\)
|
375
|
+
)
|
376
|
+
)mx
|
377
|
+
) do
|
378
|
+
class_name = $~[:class_name_1]
|
379
|
+
type = :class
|
380
|
+
if class_name
|
381
|
+
# rb_define_class(class_name_1, parent_name_1)
|
382
|
+
parent_name = $~[:parent_name_1]
|
383
|
+
#under = nil
|
384
|
+
else
|
385
|
+
class_name = $~[:class_name_2]
|
386
|
+
if class_name
|
387
|
+
# rb_define_class_under(class_under, class_name2, parent_name2...)
|
388
|
+
parent_name = $~[:parent_name_2] || $~[:path]
|
389
|
+
under = $~[:class_under]
|
390
|
+
else
|
391
|
+
class_name = $~[:class_name_3]
|
392
|
+
if class_name
|
393
|
+
# rb_struct_define_without_accessor(class_name_3, parent_name_3, ...)
|
394
|
+
parent_name = $~[:parent_name_3]
|
395
|
+
#under = nil
|
396
|
+
else
|
397
|
+
type = :module
|
398
|
+
class_name = $~[:module_name_1]
|
399
|
+
#parent_name = nil
|
400
|
+
if class_name
|
401
|
+
# rb_define_module(module_name_1)
|
402
|
+
#under = nil
|
403
|
+
else
|
404
|
+
class_name = $~[:module_name_2]
|
405
|
+
if class_name
|
406
|
+
# rb_define_module_under(module_under, module_name_1)
|
407
|
+
under = $~[:module_under]
|
408
|
+
else
|
409
|
+
# rb_singleton_class(target_class_name)
|
410
|
+
target_class_name = $~[:target_class_name]
|
411
|
+
handle_singleton $~[:var_name], target_class_name
|
412
|
+
next
|
413
|
+
end
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
handle_class_module($~[:var_name], type, class_name, parent_name, under)
|
420
|
+
end
|
334
421
|
end
|
335
422
|
|
336
423
|
##
|
@@ -379,65 +466,6 @@ class RDoc::Parser::C < RDoc::Parser
|
|
379
466
|
end
|
380
467
|
end
|
381
468
|
|
382
|
-
##
|
383
|
-
# Scans #content for rb_define_class
|
384
|
-
|
385
|
-
def do_define_class
|
386
|
-
# The '.' lets us handle SWIG-generated files
|
387
|
-
@content.scan(/([\w\.]+)\s* = \s*rb_define_class\s*
|
388
|
-
\(
|
389
|
-
\s*"(\w+)",
|
390
|
-
\s*(\w+)\s*
|
391
|
-
\)/mx) do |var_name, class_name, parent|
|
392
|
-
handle_class_module(var_name, :class, class_name, parent, nil)
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
##
|
397
|
-
# Scans #content for rb_define_class_under
|
398
|
-
|
399
|
-
def do_define_class_under
|
400
|
-
@content.scan(/([\w\.]+)\s* = # var_name
|
401
|
-
\s*rb_define_class_under\s*
|
402
|
-
\(
|
403
|
-
\s* (\w+), # under
|
404
|
-
\s* "(\w+)", # class_name
|
405
|
-
\s*
|
406
|
-
(?:
|
407
|
-
([\w\*\s\(\)\.\->]+) | # parent_name
|
408
|
-
rb_path2class\("([\w:]+)"\) # path
|
409
|
-
)
|
410
|
-
\s*
|
411
|
-
\)
|
412
|
-
/mx) do |var_name, under, class_name, parent_name, path|
|
413
|
-
parent = path || parent_name
|
414
|
-
|
415
|
-
handle_class_module var_name, :class, class_name, parent, under
|
416
|
-
end
|
417
|
-
end
|
418
|
-
|
419
|
-
##
|
420
|
-
# Scans #content for rb_define_module
|
421
|
-
|
422
|
-
def do_define_module
|
423
|
-
@content.scan(/(\w+)\s* = \s*rb_define_module\s*\(\s*"(\w+)"\s*\)/mx) do
|
424
|
-
|var_name, class_name|
|
425
|
-
handle_class_module(var_name, :module, class_name, nil, nil)
|
426
|
-
end
|
427
|
-
end
|
428
|
-
|
429
|
-
##
|
430
|
-
# Scans #content for rb_define_module_under
|
431
|
-
|
432
|
-
def do_define_module_under
|
433
|
-
@content.scan(/(\w+)\s* = \s*rb_define_module_under\s*
|
434
|
-
\(
|
435
|
-
\s*(\w+),
|
436
|
-
\s*"(\w+)"
|
437
|
-
\s*\)/mx) do |var_name, in_module, class_name|
|
438
|
-
handle_class_module(var_name, :module, class_name, nil, in_module)
|
439
|
-
end
|
440
|
-
end
|
441
469
|
|
442
470
|
##
|
443
471
|
# Scans #content for rb_include_module
|
@@ -447,7 +475,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
447
475
|
next unless cls = @classes[c]
|
448
476
|
m = @known_classes[m] || m
|
449
477
|
|
450
|
-
comment = RDoc::Comment.new '', @top_level
|
478
|
+
comment = RDoc::Comment.new '', @top_level, :c
|
451
479
|
incl = cls.add_include RDoc::Include.new(m, comment)
|
452
480
|
incl.record_location @top_level
|
453
481
|
end
|
@@ -519,42 +547,6 @@ class RDoc::Parser::C < RDoc::Parser
|
|
519
547
|
end
|
520
548
|
end
|
521
549
|
|
522
|
-
##
|
523
|
-
# Scans #content for rb_define_module and rb_define_module_under
|
524
|
-
|
525
|
-
def do_modules
|
526
|
-
do_define_module
|
527
|
-
do_define_module_under
|
528
|
-
end
|
529
|
-
|
530
|
-
##
|
531
|
-
# Scans #content for rb_singleton_class
|
532
|
-
|
533
|
-
def do_singleton_class
|
534
|
-
@content.scan(/([\w\.]+)\s* = \s*rb_singleton_class\s*
|
535
|
-
\(
|
536
|
-
\s*(\w+)
|
537
|
-
\s*\)/mx) do |sclass_var, class_var|
|
538
|
-
handle_singleton sclass_var, class_var
|
539
|
-
end
|
540
|
-
end
|
541
|
-
|
542
|
-
##
|
543
|
-
# Scans #content for struct_define_without_accessor
|
544
|
-
|
545
|
-
def do_struct_define_without_accessor
|
546
|
-
@content.scan(/([\w\.]+)\s* = \s*rb_struct_define_without_accessor\s*
|
547
|
-
\(
|
548
|
-
\s*"(\w+)", # Class name
|
549
|
-
\s*(\w+), # Parent class
|
550
|
-
\s*\w+, # Allocation function
|
551
|
-
(\s*"\w+",)* # Attributes
|
552
|
-
\s*NULL
|
553
|
-
\)/mx) do |var_name, class_name, parent|
|
554
|
-
handle_class_module(var_name, :class, class_name, parent, nil)
|
555
|
-
end
|
556
|
-
end
|
557
|
-
|
558
550
|
##
|
559
551
|
# Finds the comment for an alias on +class_name+ from +new_name+ to
|
560
552
|
# +old_name+
|
@@ -565,7 +557,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
565
557
|
\s*"#{Regexp.escape new_name}"\s*,
|
566
558
|
\s*"#{Regexp.escape old_name}"\s*\);%xm
|
567
559
|
|
568
|
-
RDoc::Comment.new($1 || '', @top_level)
|
560
|
+
RDoc::Comment.new($1 || '', @top_level, :c)
|
569
561
|
end
|
570
562
|
|
571
563
|
##
|
@@ -604,7 +596,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
604
596
|
''
|
605
597
|
end
|
606
598
|
|
607
|
-
RDoc::Comment.new comment, @top_level
|
599
|
+
RDoc::Comment.new comment, @top_level, :c
|
608
600
|
end
|
609
601
|
|
610
602
|
##
|
@@ -644,7 +636,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
644
636
|
|
645
637
|
case type
|
646
638
|
when :func_def
|
647
|
-
comment = RDoc::Comment.new args[0], @top_level
|
639
|
+
comment = RDoc::Comment.new args[0], @top_level, :c
|
648
640
|
body = args[1]
|
649
641
|
offset, = args[2]
|
650
642
|
|
@@ -674,7 +666,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
674
666
|
|
675
667
|
body
|
676
668
|
when :macro_def
|
677
|
-
comment = RDoc::Comment.new args[0], @top_level
|
669
|
+
comment = RDoc::Comment.new args[0], @top_level, :c
|
678
670
|
body = args[1]
|
679
671
|
offset, = args[2]
|
680
672
|
|
@@ -781,7 +773,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
781
773
|
comment = ''
|
782
774
|
end
|
783
775
|
|
784
|
-
comment = RDoc::Comment.new comment, @top_level
|
776
|
+
comment = RDoc::Comment.new comment, @top_level, :c
|
785
777
|
comment.normalize
|
786
778
|
|
787
779
|
look_for_directives_in class_mod, comment
|
@@ -826,7 +818,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
826
818
|
table[const_name] ||
|
827
819
|
''
|
828
820
|
|
829
|
-
RDoc::Comment.new comment, @top_level
|
821
|
+
RDoc::Comment.new comment, @top_level, :c
|
830
822
|
end
|
831
823
|
|
832
824
|
##
|
@@ -857,7 +849,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
857
849
|
|
858
850
|
return unless comment
|
859
851
|
|
860
|
-
RDoc::Comment.new comment, @top_level
|
852
|
+
RDoc::Comment.new comment, @top_level, :c
|
861
853
|
end
|
862
854
|
|
863
855
|
##
|
@@ -953,7 +945,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
953
945
|
# can override the C value of the comment to give a friendly definition.
|
954
946
|
#
|
955
947
|
# /* 300: The perfect score in bowling */
|
956
|
-
# rb_define_const(cFoo, "PERFECT", INT2FIX(300);
|
948
|
+
# rb_define_const(cFoo, "PERFECT", INT2FIX(300));
|
957
949
|
#
|
958
950
|
# Will override <tt>INT2FIX(300)</tt> with the value +300+ in the output
|
959
951
|
# RDoc. Values may include quotes and escaped colons (\:).
|
@@ -991,7 +983,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
991
983
|
|
992
984
|
new_comment = "#{$1}#{new_comment.lstrip}"
|
993
985
|
|
994
|
-
new_comment = RDoc::Comment.new new_comment, @top_level
|
986
|
+
new_comment = RDoc::Comment.new new_comment, @top_level, :c
|
995
987
|
|
996
988
|
con = RDoc::Constant.new const_name, new_definition, new_comment
|
997
989
|
else
|
@@ -1248,8 +1240,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
1248
1240
|
def scan
|
1249
1241
|
remove_commented_out_lines
|
1250
1242
|
|
1251
|
-
|
1252
|
-
do_classes
|
1243
|
+
do_classes_and_modules
|
1253
1244
|
do_missing
|
1254
1245
|
|
1255
1246
|
do_constants
|
@@ -1266,4 +1257,3 @@ class RDoc::Parser::C < RDoc::Parser
|
|
1266
1257
|
end
|
1267
1258
|
|
1268
1259
|
end
|
1269
|
-
|
@@ -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
@@ -667,7 +667,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
667
667
|
# Creates a comment with the correct format
|
668
668
|
|
669
669
|
def new_comment comment
|
670
|
-
c = RDoc::Comment.new comment, @top_level
|
670
|
+
c = RDoc::Comment.new comment, @top_level, :ruby
|
671
671
|
c.format = @markup
|
672
672
|
c
|
673
673
|
end
|
@@ -1779,9 +1779,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
|
1779
1779
|
while tk and (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) do
|
1780
1780
|
comment_body = retrieve_comment_body(tk)
|
1781
1781
|
comment += comment_body
|
1782
|
-
comment
|
1782
|
+
comment << "\n" unless comment_body =~ /\n\z/
|
1783
1783
|
|
1784
|
-
if comment_body.size > 1 &&
|
1784
|
+
if comment_body.size > 1 && comment_body =~ /\n\z/ then
|
1785
1785
|
skip_tkspace_without_nl # leading spaces
|
1786
1786
|
end
|
1787
1787
|
tk = get_tk
|
data/lib/rdoc/rd/block_parser.rb
CHANGED
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
|
|
@@ -430,7 +430,7 @@ The internal error was:
|
|
430
430
|
files.reject do |file|
|
431
431
|
file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
|
432
432
|
(file =~ /tags$/i and
|
433
|
-
|
433
|
+
open(file, 'rb') { |io|
|
434
434
|
io.read(100) =~ /\A(\f\n[^,]+,\d+$|!_TAG_)/
|
435
435
|
})
|
436
436
|
end
|
data/lib/rdoc/ri/paths.rb
CHANGED
data/lib/rdoc/servlet.rb
CHANGED
@@ -102,9 +102,9 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|
102
102
|
res.body = File.read asset_path
|
103
103
|
|
104
104
|
res.content_type = case req.path
|
105
|
-
when /
|
106
|
-
when /
|
107
|
-
else
|
105
|
+
when /\.css\z/ then 'text/css'
|
106
|
+
when /\.js\z/ then 'application/javascript'
|
107
|
+
else 'application/octet-stream'
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -112,7 +112,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|
112
112
|
# GET request entry point. Fills in +res+ for the path, etc. in +req+.
|
113
113
|
|
114
114
|
def do_GET req, res
|
115
|
-
req.path.sub!(
|
115
|
+
req.path.sub!(/\A#{Regexp.escape @mount_path}/, '') if @mount_path
|
116
116
|
|
117
117
|
case req.path
|
118
118
|
when '/' then
|
@@ -145,11 +145,14 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|
145
145
|
# +generator+ is used to create the page.
|
146
146
|
|
147
147
|
def documentation_page store, generator, path, req, res
|
148
|
-
|
148
|
+
text_name = path.chomp '.html'
|
149
|
+
name = text_name.gsub '/', '::'
|
149
150
|
|
150
151
|
if klass = store.find_class_or_module(name) then
|
151
152
|
res.body = generator.generate_class klass
|
152
|
-
elsif page = store.find_text_page(name.sub(/_([^_]*)
|
153
|
+
elsif page = store.find_text_page(name.sub(/_([^_]*)\z/, '.\1')) then
|
154
|
+
res.body = generator.generate_page page
|
155
|
+
elsif page = store.find_text_page(text_name.sub(/_([^_]*)\z/, '.\1')) then
|
153
156
|
res.body = generator.generate_page page
|
154
157
|
else
|
155
158
|
not_found generator, req, res
|
@@ -416,7 +419,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
|
|
416
419
|
RDoc::Store.new RDoc::RI::Paths.system_dir, :system
|
417
420
|
when 'site' then
|
418
421
|
RDoc::Store.new RDoc::RI::Paths.site_dir, :site
|
419
|
-
when
|
422
|
+
when /\Aextra-(\d+)\z/ then
|
420
423
|
index = $1.to_i - 1
|
421
424
|
ri_dir = installed_docs[index][4]
|
422
425
|
RDoc::Store.new ri_dir, :extra
|
data/lib/rdoc/store.rb
CHANGED
@@ -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
|
|
data/lib/rdoc/task.rb
CHANGED
@@ -128,7 +128,7 @@ class RDoc::Task < Rake::TaskLib
|
|
128
128
|
attr_accessor :template
|
129
129
|
|
130
130
|
##
|
131
|
-
# Name of format generator (<tt>--format
|
131
|
+
# Name of format generator (<tt>--format</tt>) used by rdoc. (defaults to
|
132
132
|
# rdoc's default)
|
133
133
|
|
134
134
|
attr_accessor :generator
|
data/lib/rdoc/text.rb
CHANGED
@@ -10,6 +10,8 @@ require 'strscan'
|
|
10
10
|
|
11
11
|
module RDoc::Text
|
12
12
|
|
13
|
+
attr_accessor :language
|
14
|
+
|
13
15
|
##
|
14
16
|
# Maps markup formats to classes that can parse them. If the format is
|
15
17
|
# unknown, "rdoc" format is used.
|
@@ -111,8 +113,12 @@ module RDoc::Text
|
|
111
113
|
def normalize_comment text
|
112
114
|
return text if text.empty?
|
113
115
|
|
114
|
-
|
115
|
-
|
116
|
+
case language
|
117
|
+
when :ruby
|
118
|
+
text = strip_hashes text
|
119
|
+
when :c
|
120
|
+
text = strip_stars text
|
121
|
+
end
|
116
122
|
text = expand_tabs text
|
117
123
|
text = flush_left text
|
118
124
|
text = strip_newlines text
|
data/lib/rdoc/token_stream.rb
CHANGED
@@ -74,11 +74,16 @@ module RDoc::TokenStream
|
|
74
74
|
##
|
75
75
|
# Adds +tokens+ to the collected tokens
|
76
76
|
|
77
|
-
def add_tokens(
|
78
|
-
|
77
|
+
def add_tokens(tokens)
|
78
|
+
@token_stream.concat(tokens)
|
79
79
|
end
|
80
80
|
|
81
|
-
|
81
|
+
##
|
82
|
+
# Adds one +token+ to the collected tokens
|
83
|
+
|
84
|
+
def add_token(token)
|
85
|
+
@token_stream.push(token)
|
86
|
+
end
|
82
87
|
|
83
88
|
##
|
84
89
|
# Starts collecting tokens
|
data/lib/rdoc/tom_doc.rb
CHANGED
@@ -242,19 +242,18 @@ class RDoc::TomDoc < RDoc::Markup::Parser
|
|
242
242
|
|
243
243
|
@tokens << case
|
244
244
|
when @s.scan(/\r?\n/) then
|
245
|
-
token = [:NEWLINE, @s.matched, *
|
246
|
-
@
|
247
|
-
@line += 1
|
245
|
+
token = [:NEWLINE, @s.matched, *pos]
|
246
|
+
@s.newline!
|
248
247
|
token
|
249
248
|
when @s.scan(/(Examples|Signature)$/) then
|
250
|
-
@tokens << [:HEADER, 3, *
|
249
|
+
@tokens << [:HEADER, 3, *pos]
|
251
250
|
|
252
|
-
[:TEXT, @s[1], *
|
251
|
+
[:TEXT, @s[1], *pos]
|
253
252
|
when @s.scan(/([:\w][\w\[\]]*)[ ]+- /) then
|
254
|
-
[:NOTE, @s[1], *
|
253
|
+
[:NOTE, @s[1], *pos]
|
255
254
|
else
|
256
255
|
@s.scan(/.*/)
|
257
|
-
[:TEXT, @s.matched.sub(/\r$/, ''), *
|
256
|
+
[:TEXT, @s.matched.sub(/\r$/, ''), *pos]
|
258
257
|
end
|
259
258
|
end
|
260
259
|
|