From 1c279a7d2753949c725754e1302f791b76358114 Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 27 Nov 2012 04:28:14 +0000 Subject: * lib/rdoc*: Updated to RDoc 4.0 (pre-release) * bin/rdoc: ditto * test/rdoc: ditto * NEWS: Updated with RDoc 4.0 information git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/parser/simple.rb | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'lib/rdoc/parser/simple.rb') diff --git a/lib/rdoc/parser/simple.rb b/lib/rdoc/parser/simple.rb index 1e82eb5097..65cfc1b2e7 100644 --- a/lib/rdoc/parser/simple.rb +++ b/lib/rdoc/parser/simple.rb @@ -4,6 +4,8 @@ class RDoc::Parser::Simple < RDoc::Parser + include RDoc::Parser::Text + parse_files_matching(//) attr_reader :content # :nodoc: @@ -24,20 +26,14 @@ class RDoc::Parser::Simple < RDoc::Parser def scan comment = remove_coding_comment @content - comment = remove_private_comments comment + comment = remove_private_comment comment + + comment = RDoc::Comment.new comment, @top_level @top_level.comment = comment - @top_level.parser = self.class @top_level end - ## - # Removes comments wrapped in --/++ - - def remove_private_comments text - text.gsub(/^--\n.*?^\+\+/m, '').sub(/^--\n.*/m, '') - end - ## # Removes the encoding magic comment from +text+ @@ -45,5 +41,21 @@ class RDoc::Parser::Simple < RDoc::Parser text.sub(/\A# .*coding[=:].*$/, '') end + ## + # Removes private comments. + # + # Unlike RDoc::Comment#remove_private this implementation only looks for two + # dashes at the beginning of the line. Three or more dashes are considered + # to be a rule and ignored. + + def remove_private_comment comment + # Workaround for gsub encoding for Ruby 1.9.2 and earlier + empty = '' + empty.force_encoding comment.encoding if Object.const_defined? :Encoding + + comment = comment.gsub(%r%^--\n.*?^\+\+\n?%m, empty) + comment.sub(%r%^--\n.*%m, empty) + end + end -- cgit v1.2.3