Sha256: 4378f64586545e68406e69813a8d68e629de57348b10c1d0e27c6394c0612758

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

Contents

require 'rdoc/parser'

##
# 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(//)

  ##
  # 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 do |directive, param|
      warn "Unrecognized directive '#{directive}' in #{@file_name}"
    end
  end

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

  def scan
    @top_level.comment = remove_private_comments(@content)
    @top_level
  end

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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rdoc-2.1.0 lib/rdoc/parser/simple.rb