tdoc 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -2
- data/bin/tdoc.rb +2 -3
- data/lib/rdoc/parsers/tdoc.rb +10 -1
- metadata +1 -1
data/README.rdoc
CHANGED
data/bin/tdoc.rb
CHANGED
@@ -7,7 +7,6 @@ require 'irb'
|
|
7
7
|
$: << 'lib'
|
8
8
|
|
9
9
|
LINST='^[#|\s]*'
|
10
|
-
LINSTM='[#|\s]*'
|
11
10
|
EXTENSIONS={:tests => '.rdoc',:requires => '.rb'}
|
12
11
|
DEFAULT_FILE=["README#{EXTENSIONS[:tests]}"]
|
13
12
|
|
@@ -43,7 +42,7 @@ def mk_test_context(file, test_case=nil)
|
|
43
42
|
end
|
44
43
|
opts[:requires].each {|r| require "#{r}" if FileTest.exist? "#{r}" }
|
45
44
|
opts[:tests].delete_if {|c| c.match(/#{test_name}/)}
|
46
|
-
setup_text=text.
|
45
|
+
setup_text=text.sub(/(.*)\n#{LINST}setup\s*\n/m,'').sub(/\n#{LINST}end(.*)/m,'') if text.match(/#{LINST}setup\s*$/)
|
47
46
|
tests=text.split(/#{LINST}[Ee]xamples?:/).to_a[1..-1].to_a.map do |test|
|
48
47
|
test.gsub!(/#{LINST}>>\s*(.+)\n#{LINST}=>\s*(.+)/) {|m|
|
49
48
|
expected, actual=[$2,$1]
|
@@ -64,7 +63,7 @@ def mk_test_context(file, test_case=nil)
|
|
64
63
|
context_proc=lambda {
|
65
64
|
context test_name do
|
66
65
|
setup do
|
67
|
-
eval setup_text.to_a.join
|
66
|
+
eval setup_text.to_a.join(';')
|
68
67
|
end
|
69
68
|
tests.each do |test|
|
70
69
|
should test[0] do
|
data/lib/rdoc/parsers/tdoc.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
class RDoc::Parser::Tdoc < RDoc::Parser::Simple
|
2
2
|
LINST='^[#|\s]*'
|
3
3
|
LINSTM='[#|\s]*'
|
4
|
+
EXTENSIONS={:tests => '.rdoc',:requires => '.rb'}
|
4
5
|
parse_files_matching(/\.rdoc/)
|
5
6
|
def initialize(top_level, file_name, content, options, stats)
|
6
7
|
super
|
@@ -10,7 +11,15 @@ class RDoc::Parser::Tdoc < RDoc::Parser::Simple
|
|
10
11
|
content=File.read(file_name)
|
11
12
|
test_name=File.basename(file_name,'.rdoc')
|
12
13
|
test_dir=File.dirname(file_name)
|
13
|
-
content.gsub!(/(#{LINST}):include:\s*(.+)/)
|
14
|
+
content.gsub!(/(#{LINST}):include:\s*(.+)/) do |foo|
|
15
|
+
indent=$1
|
16
|
+
fn=$2
|
17
|
+
if fn.match(/#{EXTENSIONS[:requires]}/)
|
18
|
+
"\nThe following examples require the file '#{fn}', whose contents follow:\n#{process_includes(fn).gsub(/^/,indent + ' ')}\n"
|
19
|
+
else
|
20
|
+
process_includes(fn).gsub(/^/,indent)
|
21
|
+
end
|
22
|
+
end
|
14
23
|
content.sub!(/(#{LINST})setup\s+(.*?)#{LINSTM}end\s+/m) {|foo|
|
15
24
|
indent=$1
|
16
25
|
"The following code: \n#{$2.gsub(/^/,indent+' ')}\nprecedes each of the following examples.\n\n"
|