Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- +++ rdoc.rb 2006-09-19 21:52:20.078125000 -0500
- @@ -221,6 +221,48 @@
- content = File.open(fn, "r") {|f| f.read}
- +# BEGIN PATCH
- +# command line option simulation
- +optparse_help = 'start'#'finish' # 'start' 'override'
- +
- +if optparse_help
- + # most of this code just determines the start and finish of the very top of rdoc documentation
- + # then we can place the help_doc before, after, or overriding the top rdoc documentation
- + rdoc_start, rdoc_finish = nil, nil
- + content.each_with_index do |line, index|
- + next if index == 0 and line =~ /^#\!/
- + if rdoc_start.nil?
- + case line
- + when /^\s$/ then next
- + when /^#/ then rdoc_start = index
- + else break
- + end
- + elsif rdoc_finish.nil?
- + rdoc_finish = index if line =~ /^[^#]/
- + elsif line =~ /\s*require|load\s+(['"])[\\\/\w]*optparse(\.rb)*\1/
- + content = content.to_a
- +
- + # this one line give us our documentation
- + # do not chomp
- + help_doc = %x{ruby #{fn} --help}.map{ |line| '#' << line }
- +
- + case optparse_help
- + when 'start'
- + content = content[0...rdoc_start] + help_doc + content[rdoc_start..-1]
- + when 'finish'
- + content = content[0...rdoc_finish] + help_doc + content[rdoc_finish..-1]
- + when 'override'
- + content = help_doc + content[rdoc_finish..-1]
- + end
- +
- + content = content.to_s
- + break
- + end
- + end
- +end
- +puts content
- +# END PATCH
- +
- top_level = TopLevel.new(fn)
- parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)
- file_info << parser.scan
Add Comment
Please, Sign In to add comment