sprout 1.0.17.pre → 1.0.18.pre
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sprout might be problematic. Click here for more details.
- data/lib/sprout/rdoc_parser.rb +91 -0
- data/lib/sprout/version.rb +1 -1
- data/sprout.gemspec +1 -1
- data/test/unit/rdoc_parser_test.rb +15 -0
- metadata +4 -2
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'rdoc/rdoc'
|
2
|
+
|
3
|
+
module Sprout
|
4
|
+
|
5
|
+
class RDocParser
|
6
|
+
|
7
|
+
def parse content
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse_from_caller_string caller_string
|
11
|
+
class_name, file_name, line_number = parse_caller_string caller_string
|
12
|
+
rdoc_description_for class_name, file_name, line_number
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
##
|
18
|
+
# NOTE: Don't forget that this string *sometimes* contains a colon on Windows...
|
19
|
+
def parse_caller_string caller_string
|
20
|
+
sections = caller_string.split(' ')
|
21
|
+
parts = sections.first.split(':')
|
22
|
+
file_name = parts.shift
|
23
|
+
line_number = parts.shift
|
24
|
+
class_name = class_name_from_caller_string caller_string
|
25
|
+
#puts ">> class_name: #{class_name} file_name: #{file_name} line_number: #{line_number}"
|
26
|
+
[class_name, file_name, line_number]
|
27
|
+
end
|
28
|
+
|
29
|
+
def class_name_from_caller_string caller_string
|
30
|
+
parts = caller_string.split(' ')
|
31
|
+
long = parts.pop
|
32
|
+
matched = long.match /<class:([\w:]+)>/
|
33
|
+
matched[1] unless matched.nil?
|
34
|
+
end
|
35
|
+
|
36
|
+
def rdoc_description_for class_name, file_name, line_number
|
37
|
+
rendered = rendered_rdoc file_name
|
38
|
+
end
|
39
|
+
|
40
|
+
def rendered_rdoc file
|
41
|
+
@rendered_rdoc ||= render_rdoc file
|
42
|
+
end
|
43
|
+
|
44
|
+
def render_rdoc file
|
45
|
+
rdoc = RDoc::RDoc.new
|
46
|
+
puts "==================================="
|
47
|
+
puts ">> generating rdoc for: #{file}"
|
48
|
+
|
49
|
+
rdoc.document [ file, "--format=xml", "--output=temp" ]
|
50
|
+
{}
|
51
|
+
end
|
52
|
+
|
53
|
+
def render_rdoc_from_files
|
54
|
+
# This works to some extent...
|
55
|
+
#rdoc test/fixtures/examples/echo_inputs.rb --fmt=xml --op=tmp --all -q
|
56
|
+
# But the following does not do the same thing:
|
57
|
+
#response = rdoc.document [ file, '--fmt=xml', '--op=tmp', '--all', '-q' ]
|
58
|
+
|
59
|
+
options = RDoc::Options.new
|
60
|
+
options.files = FileList[ file ]
|
61
|
+
options.formatter = 'markup'
|
62
|
+
options.op_dir = './tmp'
|
63
|
+
options.verbosity = 0
|
64
|
+
|
65
|
+
rdoc.options = options
|
66
|
+
|
67
|
+
#rdoc.stats = RDoc::Stats.new 1, options.verbosity
|
68
|
+
#response = rdoc.document []
|
69
|
+
|
70
|
+
response = rdoc.parse_files [ file ]
|
71
|
+
render_rdoc_toplevel response
|
72
|
+
end
|
73
|
+
|
74
|
+
def render_rdoc_toplevel toplevel
|
75
|
+
puts ">> toplevel: #{toplevel}"
|
76
|
+
toplevel.each do |file|
|
77
|
+
puts ">> file: #{file.name}"
|
78
|
+
puts ">> pretty: #{file.pretty_print}"
|
79
|
+
end
|
80
|
+
|
81
|
+
toplevel
|
82
|
+
end
|
83
|
+
|
84
|
+
def render_rdoc_bak file
|
85
|
+
rdoc = RDoc::RDoc.new
|
86
|
+
rdoc.options = RDoc::Options.new
|
87
|
+
rdoc.parse_files [file]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
data/lib/sprout/version.rb
CHANGED
data/sprout.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.required_rubygems_version = ">= 1.3.6"
|
19
19
|
s.rubyforge_project = "sprout"
|
20
20
|
s.require_path = ['lib']
|
21
|
-
s.files = FileList['**/**/*'].exclude /.git|.svn|.DS_Store
|
21
|
+
s.files = FileList['**/**/*'].exclude /.git|.svn|.DS_Store/
|
22
22
|
s.executables = ['sprout', 'sprout-library', 'sprout-tool', 'sprout-generator', 'sprout-class']
|
23
23
|
s.add_bundler_dependencies
|
24
24
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'test/fixtures/examples/echo_inputs'
|
3
|
+
|
4
|
+
class ExecutableOptionParserTest < Test::Unit::TestCase
|
5
|
+
include SproutTestCase
|
6
|
+
|
7
|
+
context "a new RDoc parser" do
|
8
|
+
|
9
|
+
setup do
|
10
|
+
@parser = Sprout::RDocParser.new
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 18
|
9
9
|
- pre
|
10
|
-
version: 1.0.
|
10
|
+
version: 1.0.18.pre
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Luke Bayes
|
@@ -243,6 +243,7 @@ files:
|
|
243
243
|
- lib/sprout/platform.rb
|
244
244
|
- lib/sprout/process_runner.rb
|
245
245
|
- lib/sprout/progress_bar.rb
|
246
|
+
- lib/sprout/rdoc_parser.rb
|
246
247
|
- lib/sprout/remote_file_loader.rb
|
247
248
|
- lib/sprout/remote_file_target.rb
|
248
249
|
- lib/sprout/ruby_feature.rb
|
@@ -351,6 +352,7 @@ files:
|
|
351
352
|
- test/unit/paths_param_test.rb
|
352
353
|
- test/unit/platform_test.rb
|
353
354
|
- test/unit/process_runner_test.rb
|
355
|
+
- test/unit/rdoc_parser_test.rb
|
354
356
|
- test/unit/remote_file_loader_test.rb
|
355
357
|
- test/unit/remote_file_target_test.rb
|
356
358
|
- test/unit/ruby_feature_test.rb
|