diff options
author | dave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-04 05:38:17 +0000 |
---|---|---|
committer | dave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-04 05:38:17 +0000 |
commit | 6649247da6be9d9f658090af6726852747f0f42a (patch) | |
tree | 90c49a7df5a3563647243421a3528b50c5eaa02d /lib/rdoc/code_objects.rb | |
parent | 741f44a042ce5ab7e060296e2476d3dc33090a80 (diff) | |
download | ruby-6649247da6be9d9f658090af6726852747f0f42a.tar.gz ruby-6649247da6be9d9f658090af6726852747f0f42a.tar.xz ruby-6649247da6be9d9f658090af6726852747f0f42a.zip |
Ignore leading and trailing lines in :section: blocks
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/code_objects.rb')
-rw-r--r-- | lib/rdoc/code_objects.rb | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/rdoc/code_objects.rb b/lib/rdoc/code_objects.rb index 134ac398e..d6c4f1bdb 100644 --- a/lib/rdoc/code_objects.rb +++ b/lib/rdoc/code_objects.rb @@ -126,10 +126,36 @@ module RDoc @title = title @@sequence.succ! @sequence = @@sequence.dup - if comment - @comment = comment.sub(/.*$/, '') - @comment = nil if @comment.empty? + set_comment(comment) + end + + private + + # Set the comment for this section from the original comment block + # If the first line contains :section:, strip it and use the rest. Otherwise + # remove lines up to the line containing :section:, and look for + # those lines again at the end and remove them. This lets us write + # + # # --------------------- + # # :SECTION: The title + # # The body + # # --------------------- + + def set_comment(comment) + return unless comment + + if comment =~ /^.*?:section:.*$/ + start = $` + rest = $' + if start.empty? + @comment = rest + else + @comment = rest.sub(/#{start.chomp}\Z/, '') + end + else + @comment = comment end + @comment = nil if @comment.empty? end end |