class RDoc::Parser::Simple
解析非源代码文件。我们基本上把整个文件视为一个大的注释。
公共类方法
源代码
# File lib/rdoc/parser/simple.rb, line 17 def initialize(top_level, file_name, content, options, stats) super preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include @content = preprocess.handle @content, @top_level end
准备解析一个纯文本文件
调用父类方法
RDoc::Parser::new
公共实例方法
源代码
# File lib/rdoc/parser/simple.rb, line 41 def remove_coding_comment text text.sub(/\A# .*coding[=:].*$/, '') end
从 text
中移除编码魔术注释
源代码
# File lib/rdoc/parser/simple.rb, line 52 def remove_private_comment comment # Workaround for gsub encoding for Ruby 1.9.2 and earlier empty = '' empty = RDoc::Encoding.change_encoding empty, comment.encoding comment = comment.gsub(%r%^--\n.*?^\+\+\n?%m, empty) comment.sub(%r%^--\n.*%m, empty) end
移除私有注释。
与 RDoc::Comment#remove_private
不同,此实现仅查找行首的两个破折号。三个或更多的破折号被视为规则并被忽略。
源代码
# File lib/rdoc/parser/simple.rb, line 28 def scan comment = remove_coding_comment @content comment = remove_private_comment comment comment = RDoc::Comment.new comment, @top_level @top_level.comment = comment @top_level end
提取文件内容并将其作为注释附加到 TopLevel