public
Description: Rubinius, the Ruby VM
Homepage: http://rubini.us
Clone URL: git://github.com/evanphx/rubinius.git
Update to RDoc r104
drbrain (author)
Fri Jul 18 14:24:53 -0700 2008
commit  94d307e85d0dd242c0229cf963d33bbb7271ae4b
tree    f1f28928c4b3eb983c9493530a131c93cfaffca7
parent  0704787739d87e7d62ccc656092238369ee99a5f
...
154
155
156
157
 
158
159
160
...
613
614
615
616
617
 
 
618
619
620
...
154
155
156
 
157
158
159
160
...
613
614
615
 
 
616
617
618
619
620
0
@@ -154,7 +154,7 @@ class RDoc::Options
0
 
0
   attr_reader :webcvs
0
 
0
- def initialize(generators) # :nodoc:
0
+ def initialize(generators = {}) # :nodoc:
0
     @op_dir = "doc"
0
     @op_name = nil
0
     @show_all = false
0
@@ -613,8 +613,8 @@ Usage: #{opt.program_name} [options] [names...]
0
 
0
   def check_files
0
     @files.each do |f|
0
- stat = File.stat f rescue abort("File not found: #{f}")
0
- abort("File '#{f}' not readable") unless stat.readable?
0
+ stat = File.stat f
0
+ raise RDoc::Error, "file '#{f}' not readable" unless stat.readable?
0
     end
0
   end
0
 
...
53
54
55
 
 
 
56
57
58
59
 
60
61
62
...
53
54
55
56
57
58
59
60
61
 
62
63
64
65
0
@@ -53,10 +53,13 @@ class RDoc::Parser
0
   # "new_ext" will be parsed using the same parser as "old_ext"
0
 
0
   def self.alias_extension(old_ext, new_ext)
0
+ old_ext = old_ext.sub(/^\.(.*)/, '\1')
0
+ new_ext = new_ext.sub(/^\.(.*)/, '\1')
0
+
0
     parser = can_parse "xxx.#{old_ext}"
0
     return false unless parser
0
 
0
- RDoc::Parser.parsers.unshift [/\.#{new_ext}$/, parser.last]
0
+ RDoc::Parser.parsers.unshift [/\.#{new_ext}$/, parser]
0
 
0
     true
0
   end
...
540
541
542
543
544
 
 
 
 
545
546
547
...
540
541
542
 
 
543
544
545
546
547
548
549
0
@@ -540,8 +540,10 @@ class RDoc::RubyLex
0
       begin
0
         tk = @OP.match(self)
0
         @space_seen = TkSPACE === tk
0
- rescue SyntaxError
0
- abort if @exception_on_syntax_error
0
+ rescue SyntaxError => e
0
+ raise RDoc::Error, "syntax error: #{e.message}" if
0
+ @exception_on_syntax_error
0
+
0
         tk = TkError.new(line_no, char_no)
0
       end
0
     end while @skip_space and TkSPACE === tk
...
1
2
 
3
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
 
 
 
 
 
 
 
 
 
18
19
20
21
22
23
24
 
 
 
 
25
26
27
28
29
30
 
 
31
32
33
...
35
36
37
38
39
 
40
41
42
43
 
44
45
46
47
 
48
49
50
51
 
52
53
54
55
56
 
 
57
58
59
60
61
 
62
63
64
65
 
 
 
 
 
 
66
67
68
...
82
83
84
85
86
87
88
89
90
91
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
...
 
1
2
3
4
5
6
 
7
8
9
10
11
12
 
13
14
 
 
 
15
16
17
18
19
20
21
22
23
24
25
26
 
 
 
 
 
27
28
29
30
31
32
33
 
 
 
34
35
36
37
38
...
40
41
42
 
 
43
44
45
46
 
47
48
49
50
 
51
52
53
54
 
55
56
57
58
 
 
59
60
61
62
63
 
 
64
65
66
67
 
68
69
70
71
72
73
74
75
76
...
90
91
92
 
93
94
95
96
 
 
 
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
0
@@ -1,33 +1,38 @@
0
-$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib/'
0
 require 'fileutils'
0
+require 'tempfile'
0
 require 'test/unit'
0
+require 'tmpdir'
0
+
0
 require 'rdoc/generator/texinfo'
0
-require 'yaml'
0
 
0
 # give us access to check this stuff before it's rendered
0
 class RDoc::Generator::Texinfo; attr_reader :files, :classes; end
0
 class RDoc::RDoc; attr_reader :options; attr_reader :gen; end
0
 
0
 class TestRdocInfoSections < Test::Unit::TestCase
0
- OUTPUT_DIR = "/tmp/rdoc-#{$$}"
0
 
0
   def setup
0
- # supress stdout
0
- $stdout = File.new('/dev/null','w')
0
- $stderr = File.new('/dev/null','w')
0
+ @output_dir = File.join Dir.tmpdir, "test_rdoc_info_sections_#{$$}"
0
+ @output_file = File.join @output_dir, 'rdoc.texinfo'
0
+
0
+ @input_file = Tempfile.new 'my_file.rb'
0
+
0
+ open @input_file.path, 'w' do |io|
0
+ io.write TEST_DOC
0
+ end
0
+
0
+ RDoc::Parser.alias_extension '.rb', File.extname(@input_file.path)
0
 
0
     @rdoc = RDoc::RDoc.new
0
- @rdoc.document(['--fmt=texinfo',
0
- File.expand_path(File.dirname(__FILE__) + '/../lib/rdoc/generator/texinfo.rb'),
0
- File.expand_path(File.dirname(__FILE__) + '/../README.txt'),
0
- "--op=#{OUTPUT_DIR}"])
0
- @text = File.read(OUTPUT_DIR + '/rdoc.texinfo')
0
+ @rdoc.document(['--fmt=texinfo', '--quiet', @input_file.path,
0
+ "--op=#{@output_dir}"])
0
+
0
+ @text = File.read @output_file
0
   end
0
 
0
   def teardown
0
- $stdout = STDOUT
0
- $stderr = STDERR
0
- FileUtils.rm_rf OUTPUT_DIR
0
+ @input_file.close
0
+ FileUtils.rm_rf @output_dir
0
   end
0
 
0
   def test_output_exists
0
@@ -35,34 +40,37 @@ class TestRdocInfoSections < Test::Unit::TestCase
0
   end
0
 
0
   def test_each_class_has_a_chapter
0
- assert_section "Class RDoc::Generator::Texinfo", '@chapter'
0
- assert_section "Class RDoc::Generator::TexinfoTemplate", '@chapter'
0
+ assert_section "Class MyClass", '@chapter'
0
   end
0
 
0
   def test_class_descriptions_are_given
0
- assert_match(/This generates .*Texinfo.* files for viewing with GNU Info or Emacs from .*RDoc.* extracted from Ruby source files/, @text.gsub("\n", ' '))
0
+ assert_match(/Documentation for my class/, @text.gsub("\n", ' '))
0
   end
0
 
0
   def test_included_modules_are_given
0
- assert_match(/Includes.* Generator::MarkUp/m, @text)
0
+ assert_match(/Includes.* MyModule/m, @text)
0
   end
0
 
0
   def test_class_methods_are_given
0
- assert_match(/new\(options\)/, @text)
0
+ assert_match(/my_class_method\(my_first_argument\)/, @text)
0
   end
0
 
0
   def test_classes_instance_methods_are_given
0
- assert_section 'Class RDoc::Generator::Texinfo#generate'
0
- assert_match(/generate\(toplevels\)/, @text)
0
+ assert_section 'Class MyClass#my_method'
0
+ assert_match(/my_method\(my_first_argument\)/, @text)
0
   end
0
 
0
   def test_each_module_has_a_chapter
0
- assert_section "RDoc", '@chapter'
0
- assert_section "Generator", '@chapter'
0
+ assert_section 'MyModule', '@chapter'
0
   end
0
 
0
   def test_methods_are_shown_only_once
0
- methods = @rdoc.gen.classes.map { |c| c.methods.map{ |m| c.name + '#' + m.name } }.flatten
0
+ methods = @rdoc.gen.classes.map do |c|
0
+ c.methods.map do |m|
0
+ c.name + '#' + m.name
0
+ end
0
+ end.flatten
0
+
0
     assert_equal methods, methods.uniq
0
   end
0
 
0
@@ -82,12 +90,47 @@ class TestRdocInfoSections < Test::Unit::TestCase
0
 # def test_oh_yeah_dont_forget_files
0
 # end
0
 
0
- private
0
   def assert_section(name, command = '@section')
0
     assert_match Regexp.new("^#{command}.*#{Regexp.escape name}"), @text, "Could not find a #{command} #{name}"
0
   end
0
 
0
-# def puts(*args)
0
-# @real_stdout.puts(*args)
0
-# end
0
+ TEST_DOC = <<-DOC
0
+##
0
+# Documentation for my module
0
+
0
+module MyModule
0
+
0
+ ##
0
+ # Documentation for my included method
0
+
0
+ def my_included_method() end
0
+
0
+end
0
+
0
+##
0
+# Documentation for my class
0
+
0
+class MyClass
0
+
0
+ include MyModule
0
+
0
+ ##
0
+ # Documentation for my constant
0
+
0
+ MY_CONSTANT = 'my value'
0
+
0
+ ##
0
+ # Documentation for my class method
0
+
0
+ def self.my_class_method(my_first_argument) end
0
+
0
+ ##
0
+ # Documentation for my method
0
+
0
+ def my_method(my_first_argument) end
0
+
0
+end
0
+
0
+ DOC
0
+
0
 end

Comments

    No one has commented yet.