Sha256: 3d6e17245dd0b6c267ac38f7ef1a1bb8d7916276558be1b8f446e0b335cad451

Contents?: true

Size: 977 Bytes

Versions: 5

Compression:

Stored size: 977 Bytes

Contents

##
# Parse a non-source file. We basically take the whole thing as one big
# comment. If the first character in the file is '#', we strip leading pound
# signs.

class RDoc::Parser::Simple < RDoc::Parser

  parse_files_matching(//)

  attr_reader :content # :nodoc:

  ##
  # Prepare to parse a plain file

  def initialize(top_level, file_name, content, options, stats)
    super

    preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include

    preprocess.handle @content, @top_level
  end

  ##
  # Extract the file contents and attach them to the TopLevel as a comment

  def scan
    comment = remove_coding_comment @content
    comment = remove_private_comments comment

    @top_level.comment = comment
    @top_level.parser = self.class
    @top_level
  end

  def remove_private_comments(comment)
    comment.gsub(/^--\n.*?^\+\+/m, '').sub(/^--\n.*/m, '')
  end

  def remove_coding_comment text
    text.sub(/\A# .*coding[=:].*$/, '')
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rdoc-2.5.11 lib/rdoc/parser/simple.rb
rdoc-2.5.10 lib/rdoc/parser/simple.rb
rdoc-2.5.9 lib/rdoc/parser/simple.rb
rdoc-2.5.8 lib/rdoc/parser/simple.rb
rdoc-2.5.7 lib/rdoc/parser/simple.rb