Guest User

Untitled

a guest
Feb 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. +++ rdoc.rb 2006-09-19 21:52:20.078125000 -0500
  2. @@ -221,6 +221,48 @@
  3.  
  4. content = File.open(fn, "r") {|f| f.read}
  5.  
  6. +# BEGIN PATCH
  7. +# command line option simulation
  8. +optparse_help = 'start'#'finish' # 'start' 'override'
  9. +
  10. +if optparse_help
  11. + # most of this code just determines the start and finish of the very top of rdoc documentation
  12. + # then we can place the help_doc before, after, or overriding the top rdoc documentation
  13. + rdoc_start, rdoc_finish = nil, nil
  14. + content.each_with_index do |line, index|
  15. + next if index == 0 and line =~ /^#\!/
  16. + if rdoc_start.nil?
  17. + case line
  18. + when /^\s$/ then next
  19. + when /^#/ then rdoc_start = index
  20. + else break
  21. + end
  22. + elsif rdoc_finish.nil?
  23. + rdoc_finish = index if line =~ /^[^#]/
  24. + elsif line =~ /\s*require|load\s+(['"])[\\\/\w]*optparse(\.rb)*\1/
  25. + content = content.to_a
  26. +
  27. + # this one line give us our documentation
  28. + # do not chomp
  29. + help_doc = %x{ruby #{fn} --help}.map{ |line| '#' << line }
  30. +
  31. + case optparse_help
  32. + when 'start'
  33. + content = content[0...rdoc_start] + help_doc + content[rdoc_start..-1]
  34. + when 'finish'
  35. + content = content[0...rdoc_finish] + help_doc + content[rdoc_finish..-1]
  36. + when 'override'
  37. + content = help_doc + content[rdoc_finish..-1]
  38. + end
  39. +
  40. + content = content.to_s
  41. + break
  42. + end
  43. + end
  44. +end
  45. +puts content
  46. +# END PATCH
  47. +
  48. top_level = TopLevel.new(fn)
  49. parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)
  50. file_info << parser.scan
Add Comment
Please, Sign In to add comment