2008-07-17 20:46:16 -04:00
|
|
|
##
|
|
|
|
# Parse a non-source file. We basically take the whole thing as one big
|
2010-12-19 22:22:49 -05:00
|
|
|
# comment.
|
2008-07-17 20:46:16 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2010-12-19 22:22:49 -05:00
|
|
|
##
|
|
|
|
# Removes comments wrapped in <tt>--/++</tt>
|
|
|
|
|
|
|
|
def remove_private_comments text
|
|
|
|
text.gsub(/^--\n.*?^\+\+/m, '').sub(/^--\n.*/m, '')
|
2008-07-17 20:46:16 -04:00
|
|
|
end
|
|
|
|
|
2010-12-19 22:22:49 -05:00
|
|
|
##
|
|
|
|
# Removes the encoding magic comment from +text+
|
|
|
|
|
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
|
|
|
|
|