A section of documentation like:

# :section: The title
# The body

Sections can be referenced multiple times and will be collapsed into a single section.

Methods
#
A
C
E
N
S
Included Modules
Attributes
[R] comment

Section comment

[R] parent

Context this Section lives in

[R] title

Section title

Class Public methods
new(parent, title, comment)

Creates a new section with title and comment

# File ../ruby/lib/rdoc/context.rb, line 128
def initialize parent, title, comment
  @parent = parent
  @title = title ? title.strip : title

  @@sequence.succ!
  @sequence = @@sequence.dup

  @comment = extract_comment comment
end
Instance Public methods
==(other)

Sections are equal when they have the same title

# File ../ruby/lib/rdoc/context.rb, line 141
def == other
  self.class === other and @title == other.title
end
aref()

Anchor reference for linking to this section

# File ../ruby/lib/rdoc/context.rb, line 148
def aref
  title = @title || '[untitled]'

  CGI.escape(title).gsub('%', '-').sub(/^-/, '')
end
comment=(comment)

Appends comment to the current comment separated by a rule.

# File ../ruby/lib/rdoc/context.rb, line 157
def comment= comment
  comment = extract_comment comment

  return if comment.empty?

  if @comment then
    @comment += "\n# ---\n#{comment}"
  else
    @comment = comment
  end
end
extract_comment(comment)

Extracts 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
# File ../ruby/lib/rdoc/context.rb, line 178
def extract_comment comment
  if comment =~ /^#[ \t]*:section:.*\n/ then
    start = $`
    rest = $'

    if start.empty? then
      rest
    else
      rest.sub(/#{start.chomp}\Z/, '')
    end
  else
    comment
  end
end
sequence()

Section sequence number (deprecated)

# File ../ruby/lib/rdoc/context.rb, line 200
def sequence
  warn "RDoc::Context::Section#sequence is deprecated, use #aref"
  @sequence
end