Class: RDoc::Require

Inherits:
CodeObject show all
Defined in:
lib/rdoc/require.rb

Overview

A file loaded by #require

Constant Summary

Constants included from Text

Text::MARKUP_FORMAT, Text::TO_HTML_CHARACTERS

Instance Attribute Summary collapse

Attributes inherited from CodeObject

#comment, #document_children, #document_self, #done_documenting, #file, #force_documentation, #line, #metadata, #offset, #parent, #received_nodoc, #section, #store, #viewer

Instance Method Summary collapse

Methods inherited from CodeObject

#display?, #documented?, #each_parent, #file_name, #full_name=, #ignore, #ignored?, #initialize_visibility, #options, #parent_file_name, #parent_name, #record_location, #start_doc, #stop_doc, #suppress, #suppressed?

Methods included from Generator::Markup

#aref_to, #as_href, #cvs_url, #description, #formatter

Methods included from Text

encode_fallback, #expand_tabs, #flush_left, #markup, #normalize_comment, #parse, #snippet, #strip_hashes, #strip_newlines, #strip_stars, #to_html, #wrap

Constructor Details

#initialize(name, comment) ⇒ Require

Creates a new Require that loads name with comment



14
15
16
17
18
19
# File 'lib/rdoc/require.rb', line 14

def initialize(name, comment)
  super()
  @name = name.gsub(/'|"/, "") #'
  @top_level = nil
  self.comment = comment
end

Instance Attribute Details

#nameObject

Name of the required file



9
10
11
# File 'lib/rdoc/require.rb', line 9

def name
  @name
end

Instance Method Details

#inspectObject

:nodoc:



21
22
23
24
25
26
27
28
# File 'lib/rdoc/require.rb', line 21

def inspect # :nodoc:
  "#<%s:0x%x require '%s' in %s>" % [
    self.class,
    object_id,
    @name,
    parent_file_name,
  ]
end

#to_sObject

:nodoc:



30
31
32
# File 'lib/rdoc/require.rb', line 30

def to_s # :nodoc:
  "require #{name} in: #{parent}"
end

#top_levelObject

The RDoc::TopLevel corresponding to this require, or nil if not found.



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rdoc/require.rb', line 37

def top_level
  @top_level ||= begin
    tl = RDoc::TopLevel.all_files_hash[name + '.rb']

    if tl.nil? and RDoc::TopLevel.all_files.first.full_name =~ %r(^lib/) then
      # second chance
      tl = RDoc::TopLevel.all_files_hash['lib/' + name + '.rb']
    end

    tl
  end
end