PageRenderTime 132ms CodeModel.GetById 128ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 5
 6require "rdoc/code_objects"
 7require "rdoc/markup/simple_markup/preprocess"
 8
 9module RDoc
10  # See rdoc/parsers/parse_c.rb
11
12  class SimpleParser
13    
14    # prepare to parse a plain file
15    def initialize(top_level, file_name, body, options, stats)
16      
17      preprocess = SM::PreProcess.new(file_name, options.rdoc_include)
18      
19      preprocess.handle(body) do |directive, param|
20        $stderr.puts "Unrecognized directive '#{directive}' in #{file_name}"
21      end
22      
23      @body = body
24      @options = options
25      @top_level = top_level
26    end
27    
28    # Extract the file contents and attach them to the toplevel as a
29    # comment
30    
31    def scan
32      #    @body.gsub(/^(\s\n)+/, '')
33      @top_level.comment = remove_private_comments(@body)
34      @top_level
35    end
36
37    def remove_private_comments(comment)
38      comment.gsub(/^--.*?^\+\+/m, '').sub(/^--.*/m, '')
39    end
40  end
41end