In Files
- rdoc/generator/markup.rb
- rdoc/top_level.rb
Parent
Methods
Class/Module Index
- 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::Generator
- RDoc::Generator::Darkfish
- RDoc::Generator::JsonIndex
- RDoc::Generator::Markup
- RDoc::Generator::POT
- RDoc::Generator::POT::MessageExtractor
- RDoc::Generator::POT::PO
- RDoc::Generator::POT::POEntry
- RDoc::Generator::RI
- RDoc::GhostMethod
- RDoc::I18n
- RDoc::I18n::Locale
- RDoc::I18n::Text
- 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::Mixin
- 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::RI::Task
- 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::TestCase
- RDoc::Text
- RDoc::TokenStream
- RDoc::TomDoc
- RDoc::TopLevel
- RDocTask
- Test
RDoc::TopLevel
frozen_string_literal: false
A TopLevel context is a representation of the contents of a single file
Attributes
Public Class Methods
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 rdoc/top_level.rb, line 43 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
An RDoc::TopLevel is equal to another with the same #relative_name
# File rdoc/top_level.rb, line 58 def == other self.class === other and @relative_name == other.relative_name end
Adds an_alias
to Object
instead of
self
.
# File rdoc/top_level.rb, line 67 def add_alias(an_alias) object_class.record_location self return an_alias unless @document_self object_class.add_alias an_alias end
Adds constant
to Object
instead of
self
.
# File rdoc/top_level.rb, line 76 def add_constant constant object_class.record_location self return constant unless @document_self object_class.add_constant constant end
Adds include
to Object
instead of
self
.
# File rdoc/top_level.rb, line 85 def add_include(include) object_class.record_location self return include unless @document_self object_class.add_include include end
Adds method
to Object
instead of
self
.
# File rdoc/top_level.rb, line 94 def add_method(method) object_class.record_location self return method unless @document_self object_class.add_method method end
Adds class or module mod
. Used in the building phase by the
Ruby parser.
# File rdoc/top_level.rb, line 104 def add_to_classes_or_modules mod @classes_or_modules << mod end
Base name of this file
# File rdoc/top_level.rb, line 111 def base_name File.basename @relative_name end
Returns a URL for this source file on some web repository. Use the -W command line option to set.
# File rdoc/generator/markup.rb, line 159 def cvs_url url = @store.rdoc.options.webcvs if /%s/ =~ url then url % @relative_name else url + @relative_name end end
Only a TopLevel that contains text file) will be displayed. See also RDoc::CodeObject#display?
# File rdoc/top_level.rb, line 121 def display? text? and super end
See RDoc::TopLevel::find_class_or_module
# File rdoc/top_level.rb, line 131 def find_class_or_module name @store.find_class_or_module name end
Finds a class or module named symbol
# File rdoc/top_level.rb, line 138 def find_local_symbol(symbol) find_class_or_module(symbol) || super end
Finds a module or class with name
# File rdoc/top_level.rb, line 145 def find_module_named(name) find_class_or_module(name) end
Returns the relative name of this file
# File rdoc/top_level.rb, line 152 def full_name @relative_name end
An RDoc::TopLevel has the same hash as another with the same #relative_name
# File rdoc/top_level.rb, line 160 def hash @relative_name.hash end
URL for this with a prefix
# File rdoc/top_level.rb, line 167 def http_url(prefix) path = [prefix, @relative_name.tr('.', '_')] File.join(*path.compact) + '.html' end
Time this file was last modified, if known
# File rdoc/top_level.rb, line 185 def last_modified @file_stat ? file_stat.mtime : nil end
Dumps this TopLevel for use by ri. See also marshal_load
# File rdoc/top_level.rb, line 192 def marshal_dump [ MARSHAL_VERSION, @relative_name, @parser, parse(@comment), ] end
Returns the NormalClass “Object”, creating it if not found.
Records self
as a location in “Object”.
# File rdoc/top_level.rb, line 218 def object_class @object_class ||= begin oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object') oc.record_location self oc end end
Base name of this file without the extension
# File rdoc/top_level.rb, line 229 def page_name basename = File.basename @relative_name basename =~ /\.(rb|rdoc|txt|md)$/i $` || basename end
Path to this file for use with HTML generator output.
# File rdoc/top_level.rb, line 239 def path http_url @store.rdoc.generator.file_dir end
Search record used by RDoc::Generator::JsonIndex
# File rdoc/top_level.rb, line 257 def search_record return unless @parser < RDoc::Parser::Text [ page_name, '', page_name, '', path, '', snippet(@comment), ] end
Is this TopLevel from a text file instead of a source code file?
# File rdoc/top_level.rb, line 274 def text? @parser and @parser.ancestors.include? RDoc::Parser::Text end