Class RDoc::Context::Section

  1. lib/rdoc/code_objects.rb
Parent: Object
ClassModule NormalModule AnonClass SingleClass NormalClass AnyMethod GhostMethod MetaMethod CodeObject Context Alias Attr Constant Require Include TopLevel RubyLex IRB RuntimeError Error Error Token TkUnknownChar TkVal TkNode TkOp TkId TkError TkOPASGN TkKW AttributeFormatter HtmlFormatter OverstrikeFormatter AnsiFormatter NamedThing AliasName IncludedModule Constant Attribute MethodSummary DefaultDisplay ClassEntry TopLevelEntry Formatter SimpleFormatter Description MethodDescription ModuleDescription ClassDescription HTML XML HTMLInOne CHM Method Context Class File Generator::MarkUp TEXINFO SimpleElement Port Element Node Subgraph Edge Digraph Stats Parser Options RDoc TemplatePage Markup Diagram NameDescriptor Cache Reader Writer Driver MethodEntry RI TexinfoTemplate AllReferences RubyToken Display Paths RI MarkUp Generator TokenStream DOT RDoc dot/f_5.png

Methods

public class

  1. new

public instance

  1. ==
  2. inspect
  3. set_comment

Attributes

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

Public class methods

new (title, comment)
[show source]
# File lib/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)
[show source]
# File lib/rdoc/code_objects.rb, line 149
      def ==(other)
        self.class === other and @sequence == other.sequence
      end
inspect ()
[show source]
# File lib/rdoc/code_objects.rb, line 153
      def inspect
        "#<%s:0x%x %s %p>" % [
          self.class, object_id,
          @sequence, title
        ]
      end
set_comment (comment)

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
  # ---------------------
[show source]
# File lib/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