class RDoc::TopLevel
A TopLevel context is a representation of the contents of a single file
A TopLevel context is a representation of the contents of a single file
Constants
- MARSHAL_VERSION
Attributes
Absolute name of this file
Base name of this file
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.
Base name of this file
Base name of this file without the extension
The parser class that processed this file
Relative name of this file
Public Class Methods
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/rdoc/0/top_level.rbs, line 22
def initialize: (String absolute_name, ?String relative_name) -> void
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 vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 46 def initialize(absolute_name, relative_name = absolute_name) super() @name = nil @absolute_name = absolute_name @relative_name = relative_name @parser = nil if relative_name @base_name = File.basename(relative_name) @page_name = @base_name.sub(/\.(rb|rdoc|txt|md)\z/i, '') else @base_name = nil @page_name = nil end @classes_or_modules = [] end
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.
RDoc::Context::new
Public Instance Methods
(untyped other) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/rdoc/0/top_level.rbs, line 30
def ==: (untyped other) -> bool
An RDoc::TopLevel is equal to another with the same relative_name
(RDoc::Alias an_alias) → RDoc::Alias
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/rdoc/0/top_level.rbs, line 45
def add_alias: (RDoc::Alias an_alias) -> RDoc::Alias
Adds an_alias to Object instead of self.
(RDoc::Constant constant) → RDoc::Constant
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/rdoc/0/top_level.rbs, line 53
def add_constant: (RDoc::Constant constant) -> RDoc::Constant
Adds constant to Object instead of self.
(RDoc::Include include) → RDoc::Include
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/rdoc/0/top_level.rbs, line 61
def add_include: (RDoc::Include `include`) -> RDoc::Include
Adds include to Object instead of self.
(RDoc::AnyMethod method) → RDoc::AnyMethod
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/rdoc/0/top_level.rbs, line 69
def add_method: (RDoc::AnyMethod method) -> RDoc::AnyMethod
Adds method to Object instead of self.
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 122 def add_to_classes_or_modules(mod) @classes_or_modules << mod end
Adds class or module mod. Used in the building phase by the Ruby parser.
Source
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/generator/markup.rb, line 186 def cvs_url url = @store.options.webcvs if /%s/ =~ url then url % @relative_name else url + @relative_name end end
Returns a URL for this source file on some web repository. Use the -W command line option to set.
(::String name) → RDoc::Context
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/rdoc/0/top_level.rbs, line 77
def find_class_or_module: (::String name) -> RDoc::Context
See RDoc::TopLevel::find_class_or_module
Source
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 141 def find_local_symbol(symbol) find_class_or_module(symbol) || super end
Finds a class or module named symbol
RDoc::Context#find_local_symbol
(String name) → RDoc::Context
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/rdoc/0/top_level.rbs, line 85
def find_module_named: (String name) -> RDoc::Context
Finds a module or class with name
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/rdoc/0/top_level.rbs, line 93
def full_name: () -> String
Returns the relative name of this file
Source
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 165 def hash @relative_name.hash end
An RDoc::TopLevel has the same hash as another with the same relative_name
Source
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 172 def http_url @relative_name.tr('.', '_') + '.html' end
URL for this with a prefix
Source
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 188 def marshal_dump [ MARSHAL_VERSION, @relative_name, @parser, parse(@comment), ] end
Dumps this TopLevel for use by ri. See also #marshal_load
Source
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 212 def object_class @object_class ||= begin oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object') oc.record_location self oc end end
Returns the NormalClass “Object”, creating it if not found.
Records self as a location in “Object”.
Source
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 67 def parser=(val) @parser = val @store&.cache_text_file(relative_name) @parser end
Sets the parser for this toplevel context, also the store.
Source
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 223 def path base = if options.main_page == full_name 'index.html' else http_url end prefix = options.file_path_prefix return base unless prefix File.join(prefix, base) end
Path to this file for use with HTML generator output.
Source
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 252 def search_record return unless @parser < RDoc::Parser::Text [ page_name, '', page_name, '', path, '', search_snippet, ] end
Search record used by RDoc::Generator::JsonIndex
TODO: Remove this method after dropping the darkfish theme and JsonIndex generator. Use search_snippet instead for getting documentation snippets.
Source
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 269 def search_snippet return '' if @comment.empty? snippet(@comment) end
Returns an HTML snippet of the comment for search results.
Source
# File vendor/bundle/ruby/4.0.0/gems/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb, line 278 def text? @parser and @parser.include? RDoc::Parser::Text end
Is this TopLevel from a text file instead of a source code file?