A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.ruby-lang.org/en/3.0/RDoc/TopLevel.html below:

class RDoc::TopLevel - RDoc Documentation

class RDoc::TopLevel

A TopLevel context is a representation of the contents of a single file

Attributes

absolute_name[RW]

Absolute name of this file

classes_or_modules[R]

All the classes or modules that were declared in this file. These are assigned to either #classes_hash or #modules_hash once we know what they really are.

parser[R]

The parser class that processed this file

relative_name[RW]

Relative name of this file

Public Class Methods

new(absolute_name, relative_name = absolute_name) click to toggle source

Creates a new TopLevel for the file at absolute_name. If documentation is being generated outside the source dir relative_name is relative to the source directory.

def initialize absolute_name, relative_name = absolute_name
  super()
  @name = nil
  @absolute_name = absolute_name
  @relative_name = relative_name
  @file_stat     = File.stat(absolute_name) rescue nil 
  @diagram       = nil
  @parser        = nil

  @classes_or_modules = []
end
Public Instance Methods

==(other) click to toggle source

An RDoc::TopLevel is equal to another with the same relative_name

def == other
  self.class === other and @relative_name == other.relative_name
end

add_alias(an_alias) click to toggle source

Adds an_alias to Object instead of self.

def add_alias(an_alias)
  object_class.record_location self
  return an_alias unless @document_self
  object_class.add_alias an_alias
end

add_constant(constant) click to toggle source

Adds constant to Object instead of self.

def add_constant constant
  object_class.record_location self
  return constant unless @document_self
  object_class.add_constant constant
end

add_include(include) click to toggle source

Adds include to Object instead of self.

  def add_include(include)
    object_class.record_location self
    return include unless @document_self
    object_class.add_include include
  end

  
  

  def add_method(method)
    object_class.record_location self
    return method unless @document_self
    object_class.add_method method
  end

  
  
  

  def add_to_classes_or_modules mod
    @classes_or_modules << mod
  end

  
  

  def base_name
    File.basename @relative_name
  end

  alias name base_name

  
  
  

  def display?
    text? and super
  end

  
  
  
  
  

  def find_class_or_module name
    @store.find_class_or_module name
  end

  
  

  def find_local_symbol(symbol)
    find_class_or_module(symbol) || super
  end

  
  

  def find_module_named(name)
    find_class_or_module(name)
  end

  
  

  def full_name
    @relative_name
  end

  
  
  

  def hash
    @relative_name.hash
  end

  
  

  def http_url(prefix)
    path = [prefix, @relative_name.tr('.', '_')]

    File.join(*path.compact) + '.html'
  end

  def inspect 
    "#<%s:0x%x %p modules: %p classes: %p>" % [
      self.class, object_id,
      base_name,
      @modules.map { |n,m| m },
      @classes.map { |n,c| c }
    ]
  end

  
  

  def last_modified
    @file_stat ? file_stat.mtime : nil
  end

  
  

  def marshal_dump
    [
      MARSHAL_VERSION,
      @relative_name,
      @parser,
      parse(@comment),
    ]
  end

  
  

  def marshal_load array 
    initialize array[1]

    @parser  = array[2]
    @comment = array[3]

    @file_stat          = nil
  end

  
  
  
  

  def object_class
    @object_class ||= begin
      oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object')
      oc.record_location self
      oc
    end
  end

  
  

  def page_name
    basename = File.basename @relative_name
    basename =~ /\.(rb|rdoc|txt|md)$/i

    $` || basename
  end

  
  

  def path
    http_url @store.rdoc.generator.file_dir
  end

  def pretty_print q 
    q.group 2, "[#{self.class}: ", "]" do
      q.text "base name: #{base_name.inspect}"
      q.breakable

      items = @modules.map { |n,m| m }
      items.concat @modules.map { |n,c| c }
      q.seplist items do |mod| q.pp mod end
    end
  end

  
  

  def search_record
    return unless @parser < RDoc::Parser::Text

    [
      page_name,
      '',
      page_name,
      '',
      path,
      '',
      snippet(@comment),
    ]
  end

  
  

  def text?
    @parser and @parser.include? RDoc::Parser::Text
  end

  def to_s 
    "file #{full_name}"
  end

end

add_method(method) click to toggle source

Adds method to Object instead of self.

def add_method(method)
  object_class.record_location self
  return method unless @document_self
  object_class.add_method method
end

add_to_classes_or_modules(mod) click to toggle source

Adds class or module mod. Used in the building phase by the Ruby parser.

def add_to_classes_or_modules mod
  @classes_or_modules << mod
end

base_name() click to toggle source

Base name of this file

def base_name
  File.basename @relative_name
end

display?() click to toggle source

find_class_or_module(name) click to toggle source

See RDoc::TopLevel::find_class_or_module

def find_class_or_module name
  @store.find_class_or_module name
end

find_local_symbol(symbol) click to toggle source

Finds a class or module named symbol

def find_local_symbol(symbol)
  find_class_or_module(symbol) || super
end

find_module_named(name) click to toggle source

Finds a module or class with name

def find_module_named(name)
  find_class_or_module(name)
end

full_name() click to toggle source

Returns the relative name of this file

def full_name
  @relative_name
end

hash() click to toggle source

http_url(prefix) click to toggle source

URL for this with a prefix

def http_url(prefix)
  path = [prefix, @relative_name.tr('.', '_')]

  File.join(*path.compact) + '.html'
end

last_modified() click to toggle source

Time this file was last modified, if known

def last_modified
  @file_stat ? file_stat.mtime : nil
end

marshal_dump() click to toggle source

Dumps this TopLevel for use by ri. See also marshal_load

def marshal_dump
  [
    MARSHAL_VERSION,
    @relative_name,
    @parser,
    parse(@comment),
  ]
end

object_class() click to toggle source

Returns the NormalClass “Object”, creating it if not found.

Records self as a location in “Object”.

def object_class
  @object_class ||= begin
    oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object')
    oc.record_location self
    oc
  end
end

page_name() click to toggle source

Base name of this file without the extension

def page_name
  basename = File.basename @relative_name
  basename =~ /\.(rb|rdoc|txt|md)$/i

  $` || basename
end

parser=(val) click to toggle source

def parser=(val)
  @parser = val
  @store.update_parser_of_file(absolute_name, val) if @store
  @parser
end

path() click to toggle source

Path to this file for use with HTML generator output.

def path
  http_url @store.rdoc.generator.file_dir
end

search_record() click to toggle source

Search record used by RDoc::Generator::JsonIndex

def search_record
  return unless @parser < RDoc::Parser::Text

  [
    page_name,
    '',
    page_name,
    '',
    path,
    '',
    snippet(@comment),
  ]
end

text?() click to toggle source

Is this TopLevel from a text file instead of a source code file?

def text?
  @parser and @parser.include? RDoc::Parser::Text
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4