In Files

  • rdoc/code_objects.rb

Files

Class/Module Index [+]

Quicksearch

RDoc::Context::Section

Attributes

comment[R]
sequence[R]
title[R]

Public Class Methods

new(title, comment) click to toggle source
 
               # File rdoc/code_objects.rb, line 141
def initialize(title, comment)
  @title = title
  @@sequence.succ!
  @sequence = @@sequence.dup
  @comment = nil
  set_comment(comment)
end
            

Public Instance Methods

==(other) click to toggle source
 
               # File rdoc/code_objects.rb, line 149
def ==(other)
  self.class === other and @sequence == other.sequence
end
            
inspect() click to toggle source
 
               # File rdoc/code_objects.rb, line 153
def inspect
  "#<%s:0x%x %s %p>" % [
    self.class, object_id,
    @sequence, title
  ]
end
            
set_comment(comment) click to toggle source

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
# ---------------------
 
               # File rdoc/code_objects.rb, line 171
def set_comment(comment)
  return unless comment

  if comment =~ /^#[ \t]*:section:.*\n/
    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
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus