Class: RDoc::TopLevel
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Context ,
CodeObject
|
|
Instance Chain:
|
|
Inherits: |
RDoc::Context
|
Defined in: | lib/rdoc/top_level.rb, lib/rdoc/generator/markup.rb |
Overview
A TopLevel context is a representation of the contents of a single file
Constant Summary
-
MARSHAL_VERSION =
Internal use only
# File 'lib/rdoc/top_level.rb', line 70
Text
- Included
MARKUP_FORMAT, TO_HTML_CHARACTERS
Context
- Inherited
Class Method Summary
-
.new(absolute_name, relative_name = absolute_name) ⇒ TopLevel
constructor
Creates a new
TopLevel
for the file at #absolute_name.
Context
- Inherited
.new | Creates an unnamed empty context with public current visibility. |
CodeObject
- Inherited
.new | Creates a new |
Instance Attribute Summary
-
#absolute_name
rw
Absolute name of this file.
-
#classes_or_modules
readonly
All the classes or modules that were declared in this file.
-
#display? ⇒ Boolean
readonly
Only a
TopLevel
that contains text file) will be displayed. -
#file_stat
rw
This TopLevel’s
File::Stat
struct. -
#parser
rw
The parser class that processed this file.
- #parser=(val) rw
-
#relative_name
rw
Relative name of this file.
-
#text? ⇒ Boolean
readonly
Is this
TopLevel
from a text file instead of a source code file? - #diagram rw Internal use only
Context
- Inherited
#aliases | Class/module aliases. |
#attributes | All attr* methods. |
#block_params | Block params to be used in the next |
#constants | Constants defined. |
#constants_hash | Hash of registered constants. |
#current_line_visibility= | Current visibility of this line. |
#current_section | The current documentation section that new items will be added to. |
#current_section= | Sets the current documentation section of documentation. |
#extends | Modules this context is extended with. |
#external_aliases | Aliases that could not be resolved. |
#fully_documented? | Does this context and its methods and constants all have documentation? |
#in_files | Files this context is found in. |
#includes | Modules this context includes. |
#method_list | Methods defined in this context. |
#methods_hash | Hash of registered methods. |
#name | Name of this class excluding namespace. |
#ongoing_visibility= | Changes the visibility for new methods to |
#params | Params to be used in the next |
#remove_from_documentation? | Should we remove this context from the documentation? |
#requires | Files this context requires. |
#temporary_section | Use this section for the next method, attribute or constant added. |
#unmatched_alias_lists | Hash |
#visibility | Current visibility of this context. |
CodeObject
- Inherited
#comment | Our comment. |
#comment= | Replaces our comment with |
#display? | Should this |
#document_children | Do we document our children? |
#document_children= | Enables or disables documentation of this CodeObject’s children unless it has been turned off by :enddoc: |
#document_self | Do we document ourselves? |
#document_self= | Enables or disables documentation of this |
#documented? | Does this object have a comment with content or is |
#done_documenting | Are we done documenting (ie, did we come across a :enddoc:)? |
#done_documenting= | Turns documentation on/off, and turns on/off |
#file | Which file this code object was defined in. |
#force_documentation | Force documentation of this |
#force_documentation= | Force the documentation of this object unless documentation has been turned off by :enddoc: |
#full_name= | Sets the full_name overriding any computed full name. |
#ignored? | Has this class been ignored? |
#line | Line in |
#metadata | Hash of arbitrary metadata for this |
#parent | Our parent |
#parent= | Sets the parent |
#received_nodoc | Did we ever receive a |
#section | The section this |
#section= | Set the section this |
#store | The |
#store= | Sets the |
#suppressed? | Has this class been suppressed? |
#viewer | We are the model of the code, but we know that at some point we will be worked on by viewers. |
Text
- Included
Instance Method Summary
-
#==(other)
(also: #eql?)
An
TopLevel
is equal to another with the same relative_name. -
#add_alias(an_alias)
Adds
an_alias
toObject
instead ofself
. -
#add_constant(constant)
Adds
constant
toObject
instead ofself
. -
#add_include(include)
Adds
include
toObject
instead ofself
. -
#add_method(method)
Adds
method
toObject
instead ofself
. -
#add_to_classes_or_modules(mod)
Adds class or module
mod
. -
#base_name
(also: #name)
Base name of this file.
-
#cvs_url
Returns a URL for this source file on some web repository.
- #eql?(other)
- #find_class_or_module(name)
-
#find_local_symbol(symbol)
Finds a class or module named
symbol
-
#find_module_named(name)
Finds a module or class with #name
-
#full_name
Returns the relative name of this file.
-
#hash
An
TopLevel
has the same hash as another with the same relative_name. -
#http_url(prefix)
URL for this with a
prefix
-
#last_modified
Time this file was last modified, if known.
-
#marshal_dump
Dumps this
TopLevel
for use by ri. -
#name
Alias
for #base_name. -
#object_class
Returns the
NormalClass
“Object”, creating it if not found. -
#page_name
Base name of this file without the extension.
-
#path
Path to this file for use with HTML generator output.
-
#search_record
Search record used by
Generator::JsonIndex
- #inspect Internal use only
-
#marshal_load(array)
Internal use only
Loads this
TopLevel
fromarray
. - #pretty_print(q) Internal use only
- #to_s Internal use only
Context
- Inherited
#<=> | Contexts are sorted by full_name. |
#add | Adds an item of type |
#add_alias | Adds |
#add_attribute | Adds |
#add_class | Adds a class named |
#add_class_or_module | Adds the class or module |
#add_constant | Adds |
#add_extend | Adds extension module |
#add_include | Adds included module |
#add_method | Adds |
#add_module | Adds a module named #name. |
#add_module_alias | Adds an alias from |
#add_module_by_normal_module | Adds a module by |
#add_require | Adds |
#add_section | Returns a section with |
#add_to | Adds |
#any_content | Is there any content? |
#child_name | Creates the full name for a child with #name |
#class_attributes | Class attributes. |
#class_method_list | Class methods. |
#classes | Array of classes in this context. |
#classes_and_modules | All classes and modules in this namespace. |
#classes_hash | Hash of classes keyed by class name. |
#defined_in? | Is part of this thing was defined in |
#each_attribute | Iterator for attributes. |
#each_classmodule | Iterator for classes and modules. |
#each_constant | Iterator for constants. |
#each_extend | Iterator for extension modules. |
#each_include | Iterator for included modules. |
#each_method | Iterator for methods. |
#each_section | Iterator for each section’s contents sorted by title. |
#find_attribute | Finds an attribute #name with singleton value |
#find_attribute_named | Finds an attribute with #name in this context. |
#find_class_method_named | Finds a class method with #name in this context. |
#find_constant_named | Finds a constant with #name in this context. |
#find_enclosing_module_named | Find a module at a higher scope. |
#find_external_alias | Finds an external alias #name with singleton value |
#find_external_alias_named | Finds an external alias with #name in this context. |
#find_file_named | Finds a file with #name in this context. |
#find_instance_method_named | Finds an instance method with #name in this context. |
#find_local_symbol | Finds a method, constant, attribute, external alias, module or file named |
#find_method | Finds a method named #name with singleton value |
#find_method_named | Finds a instance or module method with #name in this context. |
#find_module_named | Find a module with #name using ruby’s scoping rules. |
#find_symbol | Look up |
#find_symbol_module | Look up a module named |
#full_name | The full name for this context. |
#http_url | URL for this with a |
#initialize_methods_etc | Sets the defaults for methods and so-forth. |
#instance_attributes | Instance attributes. |
#instance_method_list | Instance methods. |
#methods_by_type | Breaks method_list into a nested hash by type ( |
#methods_matching | Yields AnyMethod and |
#modules | Array of modules in this context. |
#modules_hash | Hash of modules keyed by module name. |
#name_for_path | Name to use to generate the url. |
#record_location | Record |
#remove_invisible | Removes methods and attributes with a visibility less than |
#resolve_aliases | Tries to resolve unmatched aliases when a method or attribute has just been added. |
#section_contents | Returns |
#sections | Sections in this context. |
#set_constant_visibility_for | Given an array |
#set_current_section | Sets the current section to a section with |
#set_visibility_for | Given an array |
#sort_sections | Sorts sections alphabetically (default) or in |
#top_level | Return the |
#upgrade_to_class | Upgrades NormalModule |
#display, | |
#each_ancestor | Iterator for ancestors for duck-typing. |
#remove_invisible_in | Only called when min_visibility == |
#sections_hash, #to_s |
CodeObject
- Inherited
#each_parent | Yields each parent of this |
#file_name | File name where this |
#ignore | Use this to ignore a |
#options | The options instance from the store this |
#parent_file_name | File name of our parent. |
#parent_name | Name of our parent. |
#record_location | Records the |
#start_doc | Enable capture of documentation unless documentation has been turned off by :enddoc: |
#stop_doc | Disable capture of documentation. |
#suppress | Use this to suppress a |
#initialize_visibility | Initializes state for visibility of this |
Generator::Markup
- Included
#aref_to | Generates a relative URL from this object’s path to |
#as_href | Generates a relative URL from |
#cvs_url | Build a webcvs URL starting for the given |
#description | Handy wrapper for marking up this object’s comment. |
#formatter | Creates an |
Text
- Included
#expand_tabs | Expands tab characters in |
#flush_left | Flush |
#markup | Convert a string in markup format into HTML. |
#normalize_comment | Strips hashes, expands tabs then flushes |
#parse | Normalizes |
#snippet | The first |
#strip_hashes | Strips leading # characters from |
#strip_newlines | Strips leading and trailing n characters from |
#strip_stars | Strips /* */ style comments. |
#to_html | Converts ampersand, dashes, ellipsis, quotes, copyright and registered trademark symbols in |
#wrap | Wraps |
Constructor Details
.new(absolute_name, relative_name = absolute_name) ⇒ TopLevel
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 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
Instance Attribute Details
#absolute_name (rw)
Absolute name of this file
# File 'lib/rdoc/top_level.rb', line 22
attr_accessor :absolute_name
#classes_or_modules (readonly)
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 'lib/rdoc/top_level.rb', line 29
attr_reader :classes_or_modules
#diagram (rw)
# File 'lib/rdoc/top_level.rb', line 31
attr_accessor :diagram # :nodoc:
#display? ⇒ Boolean
(readonly)
Only a TopLevel
that contains text file) will be displayed. See also CodeObject#display?
# File 'lib/rdoc/top_level.rb', line 127
def display? text? and super end
#file_stat (rw)
This TopLevel’s File::Stat
struct
# File 'lib/rdoc/top_level.rb', line 12
attr_accessor :file_stat
#parser (rw)
The parser class that processed this file
# File 'lib/rdoc/top_level.rb', line 36
attr_reader :parser
#parser=(val) (rw)
[ GitHub ]# File 'lib/rdoc/top_level.rb', line 55
def parser=(val) @parser = val @store.update_parser_of_file(absolute_name, val) if @store @parser end
#relative_name (rw)
Relative name of this file
# File 'lib/rdoc/top_level.rb', line 17
attr_accessor :relative_name
#text? ⇒ Boolean
(readonly)
Is this TopLevel
from a text file instead of a source code file?
Instance Method Details
#==(other) Also known as: #eql?
An TopLevel
is equal to another with the same relative_name
# File 'lib/rdoc/top_level.rb', line 64
def == other self.class === other and @relative_name == other.relative_name end
#add_alias(an_alias)
Adds an_alias
to Object
instead of self
.
# File 'lib/rdoc/top_level.rb', line 73
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)
Adds constant
to Object
instead of self
.
# File 'lib/rdoc/top_level.rb', line 82
def add_constant constant object_class.record_location self return constant unless @document_self object_class.add_constant constant end
#add_include(include)
Adds include
to Object
instead of self
.
# File 'lib/rdoc/top_level.rb', line 91
def add_include(include) object_class.record_location self return include unless @document_self object_class.add_include include end
#add_method(method)
Adds method
to Object
instead of self
.
# File 'lib/rdoc/top_level.rb', line 100
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)
Adds class or module mod
. Used in the building phase by the Ruby parser.
# File 'lib/rdoc/top_level.rb', line 110
def add_to_classes_or_modules mod @classes_or_modules << mod end
#base_name Also known as: #name
Base name of this file
# File 'lib/rdoc/top_level.rb', line 117
def base_name File.basename @relative_name end
#cvs_url
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 149
def cvs_url url = @store.rdoc. .webcvs if /%s/ =~ url then url % @relative_name else url + @relative_name end end
#eql?(other)
[ GitHub ]# File 'lib/rdoc/top_level.rb', line 68
alias eql? ==
#find_class_or_module(name)
See #find_class_or_module
#find_local_symbol(symbol)
Finds a class or module named symbol
# File 'lib/rdoc/top_level.rb', line 144
def find_local_symbol(symbol) find_class_or_module(symbol) || super end
#find_module_named(name)
Finds a module or class with #name
# File 'lib/rdoc/top_level.rb', line 151
def find_module_named(name) find_class_or_module(name) end
#full_name
Returns the relative name of this file
# File 'lib/rdoc/top_level.rb', line 158
def full_name @relative_name end
#hash
An TopLevel
has the same hash as another with the same relative_name
# File 'lib/rdoc/top_level.rb', line 166
def hash @relative_name.hash end
#http_url(prefix)
URL for this with a prefix
#inspect
# File 'lib/rdoc/top_level.rb', line 179
def inspect # :nodoc: "#<%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
#last_modified
Time this file was last modified, if known
# File 'lib/rdoc/top_level.rb', line 191
def last_modified @file_stat ? file_stat.mtime : nil end
#marshal_dump
Dumps this TopLevel
for use by ri. See also #marshal_load
# File 'lib/rdoc/top_level.rb', line 198
def marshal_dump [ MARSHAL_VERSION, @relative_name, @parser, parse(@comment), ] end
#marshal_load(array)
Loads this TopLevel
from array
.
# File 'lib/rdoc/top_level.rb', line 210
def marshal_load array # :nodoc: initialize array[1] @parser = array[2] @comment = array[3] @file_stat = nil end
#name
Alias
for #base_name.
# File 'lib/rdoc/top_level.rb', line 121
alias name base_name
#object_class
Returns the NormalClass
“Object”, creating it if not found.
Records self
as a location in “Object”.
# File 'lib/rdoc/top_level.rb', line 224
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
Base name of this file without the extension
# File 'lib/rdoc/top_level.rb', line 235
def page_name basename = File.basename @relative_name basename =~ /\.(rb|rdoc|txt|md)$/i $` || basename end
#path
Path to this file for use with HTML generator output.
# File 'lib/rdoc/top_level.rb', line 245
def path http_url @store.rdoc.generator.file_dir end
#pretty_print(q)
#search_record
Search record used by Generator::JsonIndex
#to_s
# File 'lib/rdoc/top_level.rb', line 284
def to_s # :nodoc: "file #{full_name}" end