зеркало из https://github.com/github/ruby.git
Ignore leading and trailing lines in :section: blocks
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
405a50a594
Коммит
5d8d975434
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Sat Dec 4 14:28:56 2004 Dave Thomas <dave@pragprog.com>
|
||||
|
||||
* lib/rdoc/code_objects.rb (RDoc::Context::Section::set_comment):
|
||||
Section comments may now be bracketed by lines which are
|
||||
ignored. You can now write
|
||||
# -----------
|
||||
# :section: Dave's Section
|
||||
# comment material
|
||||
# -----------
|
||||
The lines before :section: are removed, and identical lines at the end are
|
||||
also removed if present.
|
||||
|
||||
Fri Dec 3 12:25:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* st.h: fix prototype for C++.
|
||||
|
|
|
@ -427,7 +427,17 @@ this margin are formatted verbatim.
|
|||
<tt>:section:</tt> is used as the section heading, and the
|
||||
remainder of the comment containing the section is used as
|
||||
introductory text. Subsequent methods, aliases, attributes,
|
||||
and classes will be documented in this section.
|
||||
and classes will be documented in this section. A :section:
|
||||
comment block may have one or more lines before the :section:
|
||||
directive. These will be removed, and any identical lines at
|
||||
the end of the block are also removed. This allows you to add
|
||||
visual cues such as
|
||||
|
||||
# ----------------------------------------
|
||||
# :section: My Section
|
||||
# This is the section that I wrote.
|
||||
# See it glisten in the noon-day sun.
|
||||
# ----------------------------------------
|
||||
|
||||
[<tt>call-seq:</tt>]
|
||||
lines up to the next blank line in the comment are treated as
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -2312,7 +2312,7 @@ module RDoc
|
|||
when "section"
|
||||
context.set_current_section(param, comment)
|
||||
comment.clear
|
||||
break
|
||||
break
|
||||
else
|
||||
warn "Unrecognized directive '#{directive}'"
|
||||
break
|
||||
|
|
Загрузка…
Ссылка в новой задаче