/tools/Ruby/lib/ruby/1.8/rdoc/parsers/parse_simple.rb

http://github.com/agross/netopenspace · Ruby · 41 lines · 22 code · 11 blank · 8 comment · 0 complexity · 5e00f0d90acdc7488260a5dcf7301dd4 MD5 · raw file

  1. # Parse a non-source file. We basically take the whole thing
  2. # as one big comment. If the first character in the file
  3. # is '#', we strip leading pound signs.
  4. require "rdoc/code_objects"
  5. require "rdoc/markup/simple_markup/preprocess"
  6. module RDoc
  7. # See rdoc/parsers/parse_c.rb
  8. class SimpleParser
  9. # prepare to parse a plain file
  10. def initialize(top_level, file_name, body, options, stats)
  11. preprocess = SM::PreProcess.new(file_name, options.rdoc_include)
  12. preprocess.handle(body) do |directive, param|
  13. $stderr.puts "Unrecognized directive '#{directive}' in #{file_name}"
  14. end
  15. @body = body
  16. @options = options
  17. @top_level = top_level
  18. end
  19. # Extract the file contents and attach them to the toplevel as a
  20. # comment
  21. def scan
  22. # @body.gsub(/^(\s\n)+/, '')
  23. @top_level.comment = remove_private_comments(@body)
  24. @top_level
  25. end
  26. def remove_private_comments(comment)
  27. comment.gsub(/^--.*?^\+\+/m, '').sub(/^--.*/m, '')
  28. end
  29. end
  30. end