2008-07-17 20:46:16 -04:00
|
|
|
##
|
|
|
|
# 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(//)
|
|
|
|
|
2010-04-22 22:32:20 -04:00
|
|
|
attr_reader :content # :nodoc:
|
|
|
|
|
2008-07-17 20:46:16 -04:00
|
|
|
##
|
|
|
|
# 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
|
|
|
|
|
2010-04-26 23:45:22 -04:00
|
|
|
preprocess.handle @content, @top_level
|
2008-07-17 20:46:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
2010-04-01 03:45:16 -04:00
|
|
|
# Extract the file contents and attach them to the TopLevel as a comment
|
2008-07-17 20:46:16 -04:00
|
|
|
|
|
|
|
def scan
|
2010-04-10 02:36:13 -04:00
|
|
|
comment = remove_coding_comment @content
|
|
|
|
comment = remove_private_comments comment
|
|
|
|
|
|
|
|
@top_level.comment = comment
|
2010-04-01 03:45:16 -04:00
|
|
|
@top_level.parser = self.class
|
2008-07-17 20:46:16 -04:00
|
|
|
@top_level
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_private_comments(comment)
|
2008-09-24 22:43:03 -04:00
|
|
|
comment.gsub(/^--\n.*?^\+\+/m, '').sub(/^--\n.*/m, '')
|
2008-07-17 20:46:16 -04:00
|
|
|
end
|
|
|
|
|
2010-04-10 02:36:13 -04:00
|
|
|
def remove_coding_comment text
|
|
|
|
text.sub(/\A# .*coding[=:].*$/, '')
|
|
|
|
end
|
|
|
|
|
2008-07-17 20:46:16 -04:00
|
|
|
end
|
|
|
|
|