Class: RDoc::TopLevel

### Home Classes Methods

### In Files

- lib/rdoc/generator/markup.rb
- lib/rdoc/top_level.rb

### Parent

RDoc::Context

### Methods

- ::new
- #==
- #add_alias
- #add_constant
- #add_include
- #add_method
- #add_to_classes_or_modules
- #base_name
- #cvs_url
- #display?
- #eql?
- #find_class_or_module
- #find_local_symbol
- #find_module_named
- #full_name
- #hash
- #http_url
- #last_modified
- #marshal_dump
- #name
- #object_class
- #page_name
- #path
- #search_record
- #text?

### Files

- CVE-2013-0256.rdoc
- DEVELOPERS.rdoc
- LICENSE.rdoc
- Manifest.txt
- README.rdoc
- RI.rdoc
- Rakefile
- TODO.rdoc

### Class/Module Index

Quicksearch

- RDoc
- RDoc::Alias
- RDoc::AnonClass
- RDoc::AnyMethod
- RDoc::Attr
- RDoc::ClassModule
- RDoc::CodeObject
- RDoc::Comment
- RDoc::Constant
- RDoc::Context
- RDoc::Context::Section
- RDoc::CrossReference
- RDoc::ERBIO
- RDoc::ERBPartial
- RDoc::Encoding
- RDoc::Error
- RDoc::Extend
- RDoc::Gauntlet
- RDoc::Generator
- RDoc::Generator::Darkfish
- RDoc::Generator::JsonIndex
- RDoc::Generator::Markup
- RDoc::Generator::RI
- RDoc::GhostMethod
- RDoc::Include
- RDoc::Markdown
- RDoc::Markdown::Literals
- RDoc::Markup
- RDoc::Markup::AttrChanger
- RDoc::Markup::AttrSpan
- RDoc::Markup::AttributeManager
- RDoc::Markup::Attributes
- RDoc::Markup::BlankLine
- RDoc::Markup::BlockQuote
- RDoc::Markup::Document
- RDoc::Markup::Formatter
- RDoc::Markup::FormatterTestCase
- RDoc::Markup::HardBreak
- RDoc::Markup::Include
- RDoc::Markup::IndentedParagraph
- RDoc::Markup::List
- RDoc::Markup::ListItem
- RDoc::Markup::Paragraph
- RDoc::Markup::Parser
- RDoc::Markup::Parser::Error
- RDoc::Markup::Parser::ParseError
- RDoc::Markup::PreProcess
- RDoc::Markup::Raw
- RDoc::Markup::Rule
- RDoc::Markup::Special
- RDoc::Markup::TextFormatterTestCase
- RDoc::Markup::ToAnsi
- RDoc::Markup::ToBs
- RDoc::Markup::ToHtml
- RDoc::Markup::ToHtmlCrossref
- RDoc::Markup::ToHtmlSnippet
- RDoc::Markup::ToJoinedParagraph
- RDoc::Markup::ToLabel
- RDoc::Markup::ToMarkdown
- RDoc::Markup::ToRdoc
- RDoc::Markup::ToTableOfContents
- RDoc::Markup::ToTest
- RDoc::Markup::ToTtOnly
- RDoc::Markup::Verbatim
- RDoc::MetaMethod
- RDoc::MethodAttr
- RDoc::NormalClass
- RDoc::NormalModule
- RDoc::Options
- RDoc::Parser
- RDoc::Parser::C
- RDoc::Parser::ChangeLog
- RDoc::Parser::Markdown
- RDoc::Parser::RD
- RDoc::Parser::Ruby
- RDoc::Parser::RubyTools
- RDoc::Parser::Simple
- RDoc::Parser::Text
- RDoc::RD
- RDoc::RD::BlockParser
- RDoc::RD::Inline
- RDoc::RD::InlineParser
- RDoc::RDoc
- RDoc::RI
- RDoc::RI::Driver
- RDoc::RI::Driver::Error
- RDoc::RI::Driver::NotFoundError
- RDoc::RI::Error
- RDoc::RI::Paths
- RDoc::Require
- RDoc::RubyLex
- RDoc::RubyLex::Error
- RDoc::RubyToken
- RDoc::RubygemsHook
- RDoc::Servlet
- RDoc::SingleClass
- RDoc::Stats
- RDoc::Stats::Normal
- RDoc::Stats::Quiet
- RDoc::Stats::Verbose
- RDoc::Store
- RDoc::Store::Error
- RDoc::Store::MissingFileError
- RDoc::Task
- RDoc::Task
- RDoc::TestCase
- RDoc::TokenStream
- RDoc::TomDoc
- RDoc::TopLevel
- Object

No matching classes.

# 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.

file_stat[RW]

This TopLevel's File::Stat struct

parser[RW]

The parser 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.

    # File lib/rdoc/top_level.rb, line 42
    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 # HACK for testing
      @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

    # File lib/rdoc/top_level.rb, line 57
    def == other
      self.class === other and @relative_name == other.relative_name
    end

Also aliased as: eql?
add_alias(an_alias) click to toggle source

Adds `an_alias` to `Object` instead of `self`.

    # File lib/rdoc/top_level.rb, line 66
    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`.

    # File lib/rdoc/top_level.rb, line 75
    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`.

    # File lib/rdoc/top_level.rb, line 84
    def add_include(include)
      object_class.record_location self
      return include unless @document_self
      object_class.add_include include
    end

add_method(method) click to toggle source

Adds `method` to `Object` instead of `self`.

    # File lib/rdoc/top_level.rb, line 93
    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.

    # File lib/rdoc/top_level.rb, line 103
    def add_to_classes_or_modules mod
      @classes_or_modules << mod
    end

base_name() click to toggle source

Base name of this file

    # File lib/rdoc/top_level.rb, line 110
    def base_name
      File.basename @relative_name
    end

Also aliased as: name
cvs_url() click to toggle source

Returns a URL for this source file on some web repository. Use the -W command line option to set.

    # File lib/rdoc/generator/markup.rb, line 158
    def cvs_url
      url = @store.rdoc.options.webcvs

      if /%s/ =~ url then
        url % @relative_name
      else
        url + @relative_name
      end
    end

display?() click to toggle source

Only a TopLevel that contains text file) will be displayed. See also RDoc::CodeObject#display?

    # File lib/rdoc/top_level.rb, line 120
    def display?
      text? and super
    end

eql?(other) click to toggle source
Alias for: ==
find_class_or_module(name) click to toggle source

See RDoc::TopLevel::find_class_or_module

    # File lib/rdoc/top_level.rb, line 130
    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`

    # File lib/rdoc/top_level.rb, line 137
    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`

    # File lib/rdoc/top_level.rb, line 144
    def find_module_named(name)
      find_class_or_module(name)
    end

full_name() click to toggle source

Returns the relative name of this file

    # File lib/rdoc/top_level.rb, line 151
    def full_name
      @relative_name
    end

hash() click to toggle source

An RDoc::TopLevel has the same hash as another with the same relative_name

    # File lib/rdoc/top_level.rb, line 159
    def hash
      @relative_name.hash
    end

http_url(prefix) click to toggle source

URL for this with a `prefix`

    # File lib/rdoc/top_level.rb, line 166
    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

    # File lib/rdoc/top_level.rb, line 184
    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

    # File lib/rdoc/top_level.rb, line 191
    def marshal_dump
      [
        MARSHAL_VERSION,
        @relative_name,
        @parser,
        parse(@comment),
      ]
    end

name() click to toggle source
Alias for: base_name
object_class() click to toggle source

Returns the NormalClass "Object", creating it if not found.

Records `self` as a location in "Object".

    # File lib/rdoc/top_level.rb, line 217
    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

    # File lib/rdoc/top_level.rb, line 228
    def page_name
      basename = File.basename @relative_name
      basename =~ /\.(rb|rdoc|txt|md)$/

      $` || basename
    end

path() click to toggle source

Path to this file for use with HTML generator output.

    # File lib/rdoc/top_level.rb, line 238
    def path
      http_url @store.rdoc.generator.file_dir
    end

search_record() click to toggle source

Search record used by RDoc::Generator::JsonIndex

    # File lib/rdoc/top_level.rb, line 256
    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?

    # File lib/rdoc/top_level.rb, line 273
    def text?
      @parser and @parser.ancestors.include? RDoc::Parser::Text
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.