123456789_123456789_123456789_123456789_123456789_

Class: RDoc::Markup::Heading

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Struct
Instance Chain:
self, Struct
Inherits: Struct
  • Object
Defined in: lib/rdoc/markup/heading.rb

Overview

A heading with a level (1-6) and text

Class Method Summary

Instance Attribute Summary

  • #level rw

    A heading with a level (1-6) and text.

  • #text rw

    A heading with a level (1-6) and text.

Instance Method Summary

Class Method Details

.handle_regexp_CROSSREF(target)

[ GitHub ]

  
# File 'lib/rdoc/markup/heading.rb', line 30

def @to_html.handle_regexp_CROSSREF(target)
  target.text.sub(/^\\/, '')
end

.to_html

A singleton plain HTML formatter for headings. Used for creating labels for the Table of Contents

[ GitHub ]

  
# File 'lib/rdoc/markup/heading.rb', line 22

def self.to_html
  return @to_html if @to_html

  markup = RDoc::Markup.new
  markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF

  @to_html = RDoc::Markup::ToHtml.new nil

  def @to_html.handle_regexp_CROSSREF(target)
    target.text.sub(/^\\/, '')
  end

  @to_html
end

.to_label

A singleton ToLabel formatter for headings.

[ GitHub ]

  
# File 'lib/rdoc/markup/heading.rb', line 14

def self.to_label
  @to_label ||= RDoc::Markup::ToLabel.new
end

Instance Attribute Details

#level (rw)

A heading with a level (1-6) and text

[ GitHub ]

  
# File 'lib/rdoc/markup/heading.rb', line 5

RDoc::Markup::Heading =
  Struct.new :level, :text do

  @to_html = nil
  @to_label = nil

  ##
  # A singleton RDoc::Markup::ToLabel formatter for headings.

  def self.to_label
@to_label ||= RDoc::Markup::ToLabel.new
  end

  ##
  # A singleton plain HTML formatter for headings.  Used for creating labels
  # for the Table of Contents

  def self.to_html
return @to_html if @to_html

markup = RDoc::Markup.new
markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF

@to_html = RDoc::Markup::ToHtml.new nil

def @to_html.handle_regexp_CROSSREF(target)

#text (rw)

A heading with a level (1-6) and text

[ GitHub ]

  
# File 'lib/rdoc/markup/heading.rb', line 5

RDoc::Markup::Heading =
  Struct.new :level, :text do

  @to_html = nil
  @to_label = nil

  ##
  # A singleton RDoc::Markup::ToLabel formatter for headings.

  def self.to_label
@to_label ||= RDoc::Markup::ToLabel.new
  end

  ##
  # A singleton plain HTML formatter for headings.  Used for creating labels
  # for the Table of Contents

  def self.to_html
return @to_html if @to_html

markup = RDoc::Markup.new
markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF

@to_html = RDoc::Markup::ToHtml.new nil

def @to_html.handle_regexp_CROSSREF(target)

Instance Method Details

#accept(visitor)

Calls #accept_heading on visitor

[ GitHub ]

  
# File 'lib/rdoc/markup/heading.rb', line 40

def accept(visitor)
  visitor.accept_heading self
end

#aref

An HTML-safe anchor reference for this header.

[ GitHub ]

  
# File 'lib/rdoc/markup/heading.rb', line 47

def aref
  "label-#{self.class.to_label.convert text.dup}"
end

#label(context = nil)

Creates a fully-qualified label which will include the label from context. This helps keep ids unique in HTML.

[ GitHub ]

  
# File 'lib/rdoc/markup/heading.rb', line 55

def label(context = nil)
  label = aref

  label = [context.aref, label].compact.join '-' if
    context and context.respond_to? :aref

  label
end

#plain_html

HTML markup of the text of this label without the surrounding header element.

[ GitHub ]

  
# File 'lib/rdoc/markup/heading.rb', line 68

def plain_html
  text = self.text.dup

  if matched = text.match(/rdoc-image:[^:]+:(.*)/)
    text = matched[1]
  end

  self.class.to_html.to_html(text)
end

#pretty_print(q)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rdoc/markup/heading.rb', line 78

def pretty_print(q) # :nodoc:
  q.group 2, "[head: #{level} ", ']' do
    q.pp text
  end
end