diff --git a/gems/bundled_gems b/gems/bundled_gems index dade781356..73407736bf 100644 --- a/gems/bundled_gems +++ b/gems/bundled_gems @@ -39,3 +39,4 @@ ostruct 0.6.1 https://github.com/ruby/ostruct pstore 0.1.4 https://github.com/ruby/pstore b563c4d354615e12a6fa54ffaa4ed711c3d1ba9f benchmark 0.4.0 https://github.com/ruby/benchmark logger 1.6.5 https://github.com/ruby/logger +rdoc 6.10.0 https://github.com/ruby/rdoc diff --git a/lib/rdoc.rb b/lib/rdoc.rb deleted file mode 100644 index b42059c712..0000000000 --- a/lib/rdoc.rb +++ /dev/null @@ -1,211 +0,0 @@ -# frozen_string_literal: true -$DEBUG_RDOC = nil - -## -# RDoc produces documentation for Ruby source files by parsing the source and -# extracting the definition for classes, modules, methods, includes and -# requires. It associates these with optional documentation contained in an -# immediately preceding comment block then renders the result using an output -# formatter. -# -# For a simple introduction to writing or generating documentation using RDoc -# see the README. -# -# == Roadmap -# -# If you think you found a bug in RDoc see CONTRIBUTING@Bugs -# -# If you want to use RDoc to create documentation for your Ruby source files, -# see RDoc::Markup and refer to rdoc --help for command line usage. -# -# If you want to set the default markup format see -# RDoc::Markup@Markup+Formats -# -# If you want to store rdoc configuration in your gem (such as the default -# markup format) see RDoc::Options@Saved+Options -# -# If you want to write documentation for Ruby files see RDoc::Parser::Ruby -# -# If you want to write documentation for extensions written in C see -# RDoc::Parser::C -# -# If you want to generate documentation using rake see RDoc::Task. -# -# If you want to drive RDoc programmatically, see RDoc::RDoc. -# -# If you want to use the library to format text blocks into HTML or other -# formats, look at RDoc::Markup. -# -# If you want to make an RDoc plugin such as a generator or directive handler -# see RDoc::RDoc. -# -# If you want to write your own output generator see RDoc::Generator. -# -# If you want an overview of how RDoc works see CONTRIBUTING -# -# == Credits -# -# RDoc is currently being maintained by Eric Hodel . -# -# Dave Thomas is the original author of RDoc. -# -# * The Ruby parser in rdoc/parse.rb is based heavily on the outstanding -# work of Keiju ISHITSUKA of Nippon Rational Inc, who produced the Ruby -# parser for irb and the rtags package. - -module RDoc - - ## - # Exception thrown by any rdoc error. - - class Error < RuntimeError; end - - require_relative 'rdoc/version' - - ## - # Method visibilities - - VISIBILITIES = [:public, :protected, :private] - - ## - # Name of the dotfile that contains the description of files to be processed - # in the current directory - - DOT_DOC_FILENAME = ".document" - - ## - # General RDoc modifiers - - GENERAL_MODIFIERS = %w[nodoc].freeze - - ## - # RDoc modifiers for classes - - CLASS_MODIFIERS = GENERAL_MODIFIERS - - ## - # RDoc modifiers for attributes - - ATTR_MODIFIERS = GENERAL_MODIFIERS - - ## - # RDoc modifiers for constants - - CONSTANT_MODIFIERS = GENERAL_MODIFIERS - - ## - # RDoc modifiers for methods - - METHOD_MODIFIERS = GENERAL_MODIFIERS + - %w[arg args yield yields notnew not-new not_new doc] - - ## - # Loads the best available YAML library. - - def self.load_yaml - begin - gem 'psych' - rescue NameError => e # --disable-gems - raise unless e.name == :gem - rescue Gem::LoadError - end - - begin - require 'psych' - rescue ::LoadError - ensure - require 'yaml' - end - end - - ## - # Searches and returns the directory for settings. - # - # 1. $HOME/.rdoc directory, if it exists. - # 2. The +rdoc+ directory under the path specified by the - # +XDG_DATA_HOME+ environment variable, if it is set. - # 3. $HOME/.local/share/rdoc directory. - # - # Other than the home directory, the containing directory will be - # created automatically. - - def self.home - rdoc_dir = begin - File.expand_path('~/.rdoc') - rescue ArgumentError - end - - if File.directory?(rdoc_dir) - rdoc_dir - else - require 'fileutils' - begin - # XDG - xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share') - unless File.exist?(xdg_data_home) - FileUtils.mkdir_p xdg_data_home - end - File.join xdg_data_home, "rdoc" - rescue Errno::EACCES - end - end - end - - autoload :RDoc, "#{__dir__}/rdoc/rdoc" - - autoload :CrossReference, "#{__dir__}/rdoc/cross_reference" - autoload :ERBIO, "#{__dir__}/rdoc/erbio" - autoload :ERBPartial, "#{__dir__}/rdoc/erb_partial" - autoload :Encoding, "#{__dir__}/rdoc/encoding" - autoload :Generator, "#{__dir__}/rdoc/generator" - autoload :Options, "#{__dir__}/rdoc/options" - autoload :Parser, "#{__dir__}/rdoc/parser" - autoload :Servlet, "#{__dir__}/rdoc/servlet" - autoload :RI, "#{__dir__}/rdoc/ri" - autoload :Stats, "#{__dir__}/rdoc/stats" - autoload :Store, "#{__dir__}/rdoc/store" - autoload :Task, "#{__dir__}/rdoc/task" - autoload :Text, "#{__dir__}/rdoc/text" - - autoload :Markdown, "#{__dir__}/rdoc/markdown" - autoload :Markup, "#{__dir__}/rdoc/markup" - autoload :RD, "#{__dir__}/rdoc/rd" - autoload :TomDoc, "#{__dir__}/rdoc/tom_doc" - - autoload :KNOWN_CLASSES, "#{__dir__}/rdoc/known_classes" - - autoload :TokenStream, "#{__dir__}/rdoc/token_stream" - - autoload :Comment, "#{__dir__}/rdoc/comment" - - require_relative 'rdoc/i18n' - - # code objects - # - # We represent the various high-level code constructs that appear in Ruby - # programs: classes, modules, methods, and so on. - autoload :CodeObject, "#{__dir__}/rdoc/code_object" - - autoload :Context, "#{__dir__}/rdoc/code_object/context" - autoload :TopLevel, "#{__dir__}/rdoc/code_object/top_level" - - autoload :AnonClass, "#{__dir__}/rdoc/code_object/anon_class" - autoload :ClassModule, "#{__dir__}/rdoc/code_object/class_module" - autoload :NormalClass, "#{__dir__}/rdoc/code_object/normal_class" - autoload :NormalModule, "#{__dir__}/rdoc/code_object/normal_module" - autoload :SingleClass, "#{__dir__}/rdoc/code_object/single_class" - - autoload :Alias, "#{__dir__}/rdoc/code_object/alias" - autoload :AnyMethod, "#{__dir__}/rdoc/code_object/any_method" - autoload :MethodAttr, "#{__dir__}/rdoc/code_object/method_attr" - autoload :GhostMethod, "#{__dir__}/rdoc/code_object/ghost_method" - autoload :MetaMethod, "#{__dir__}/rdoc/code_object/meta_method" - autoload :Attr, "#{__dir__}/rdoc/code_object/attr" - - autoload :Constant, "#{__dir__}/rdoc/code_object/constant" - autoload :Mixin, "#{__dir__}/rdoc/code_object/mixin" - autoload :Include, "#{__dir__}/rdoc/code_object/include" - autoload :Extend, "#{__dir__}/rdoc/code_object/extend" - autoload :Require, "#{__dir__}/rdoc/code_object/require" - -end diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb deleted file mode 100644 index 83997c2580..0000000000 --- a/lib/rdoc/code_object.rb +++ /dev/null @@ -1,427 +0,0 @@ -# frozen_string_literal: true -## -# Base class for the RDoc code tree. -# -# We contain the common stuff for contexts (which are containers) and other -# elements (methods, attributes and so on) -# -# Here's the tree of the CodeObject subclasses: -# -# * RDoc::Context -# * RDoc::TopLevel -# * RDoc::ClassModule -# * RDoc::AnonClass (never used so far) -# * RDoc::NormalClass -# * RDoc::NormalModule -# * RDoc::SingleClass -# * RDoc::MethodAttr -# * RDoc::Attr -# * RDoc::AnyMethod -# * RDoc::GhostMethod -# * RDoc::MetaMethod -# * RDoc::Alias -# * RDoc::Constant -# * RDoc::Mixin -# * RDoc::Require -# * RDoc::Include - -class RDoc::CodeObject - - include RDoc::Text - - ## - # Our comment - - attr_reader :comment - - ## - # Do we document our children? - - attr_reader :document_children - - ## - # Do we document ourselves? - - attr_reader :document_self - - ## - # Are we done documenting (ie, did we come across a :enddoc:)? - - attr_reader :done_documenting - - ## - # Which file this code object was defined in - - attr_reader :file - - ## - # Force documentation of this CodeObject - - attr_reader :force_documentation - - ## - # Line in #file where this CodeObject was defined - - attr_accessor :line - - ## - # Hash of arbitrary metadata for this CodeObject - - attr_reader :metadata - - ## - # Sets the parent CodeObject - - attr_writer :parent - - ## - # Did we ever receive a +:nodoc:+ directive? - - attr_reader :received_nodoc - - ## - # Set the section this CodeObject is in - - attr_writer :section - - ## - # The RDoc::Store for this object. - - attr_reader :store - - ## - # We are the model of the code, but we know that at some point we will be - # worked on by viewers. By implementing the Viewable protocol, viewers can - # associated themselves with these objects. - - attr_accessor :viewer - - ## - # When mixed-in to a class, this points to the Context in which it was originally defined. - - attr_accessor :mixin_from - - ## - # Creates a new CodeObject that will document itself and its children - - def initialize - @metadata = {} - @comment = '' - @parent = nil - @parent_name = nil # for loading - @parent_class = nil # for loading - @section = nil - @section_title = nil # for loading - @file = nil - @full_name = nil - @store = nil - @track_visibility = true - @mixin_from = nil - - initialize_visibility - end - - ## - # Initializes state for visibility of this CodeObject and its children. - - def initialize_visibility # :nodoc: - @document_children = true - @document_self = true - @done_documenting = false - @force_documentation = false - @received_nodoc = false - @ignored = false - @suppressed = false - @track_visibility = true - end - - ## - # Replaces our comment with +comment+, unless it is empty. - - def comment=(comment) - @comment = case comment - when NilClass then '' - when RDoc::Markup::Document then comment - when RDoc::Comment then comment.normalize - else - if comment and not comment.empty? then - normalize_comment comment - else - # HACK correct fix is to have #initialize create @comment - # with the correct encoding - if String === @comment and @comment.empty? then - @comment = RDoc::Encoding.change_encoding @comment, comment.encoding - end - @comment - end - end - end - - ## - # Should this CodeObject be displayed in output? - # - # A code object should be displayed if: - # - # * The item didn't have a nodoc or wasn't in a container that had nodoc - # * The item wasn't ignored - # * The item has documentation and was not suppressed - - def display? - @document_self and not @ignored and - (documented? or not @suppressed) - end - - ## - # Enables or disables documentation of this CodeObject's children unless it - # has been turned off by :enddoc: - - def document_children=(document_children) - return unless @track_visibility - - @document_children = document_children unless @done_documenting - end - - ## - # Enables or disables documentation of this CodeObject unless it has been - # turned off by :enddoc:. If the argument is +nil+ it means the - # documentation is turned off by +:nodoc:+. - - def document_self=(document_self) - return unless @track_visibility - return if @done_documenting - - @document_self = document_self - @received_nodoc = true if document_self.nil? - end - - ## - # Does this object have a comment with content or is #received_nodoc true? - - def documented? - @received_nodoc or !@comment.empty? - end - - ## - # Turns documentation on/off, and turns on/off #document_self - # and #document_children. - # - # Once documentation has been turned off (by +:enddoc:+), - # the object will refuse to turn #document_self or - # #document_children on, so +:doc:+ and +:start_doc:+ directives - # will have no effect in the current file. - - def done_documenting=(value) - return unless @track_visibility - @done_documenting = value - @document_self = !value - @document_children = @document_self - end - - ## - # Yields each parent of this CodeObject. See also - # RDoc::ClassModule#each_ancestor - - def each_parent - code_object = self - - while code_object = code_object.parent do - yield code_object - end - - self - end - - ## - # File name where this CodeObject was found. - # - # See also RDoc::Context#in_files - - def file_name - return unless @file - - @file.absolute_name - end - - ## - # Force the documentation of this object unless documentation - # has been turned off by :enddoc: - #-- - # HACK untested, was assigning to an ivar - - def force_documentation=(value) - @force_documentation = value unless @done_documenting - end - - ## - # Sets the full_name overriding any computed full name. - # - # Set to +nil+ to clear RDoc's cached value - - def full_name= full_name - @full_name = full_name - end - - ## - # Use this to ignore a CodeObject and all its children until found again - # (#record_location is called). An ignored item will not be displayed in - # documentation. - # - # See github issue #55 - # - # The ignored status is temporary in order to allow implementation details - # to be hidden. At the end of processing a file RDoc allows all classes - # and modules to add new documentation to previously created classes. - # - # If a class was ignored (via stopdoc) then reopened later with additional - # documentation it should be displayed. If a class was ignored and never - # reopened it should not be displayed. The ignore flag allows this to - # occur. - - def ignore - return unless @track_visibility - - @ignored = true - - stop_doc - end - - ## - # Has this class been ignored? - # - # See also #ignore - - def ignored? - @ignored - end - - ## - # The options instance from the store this CodeObject is attached to, or a - # default options instance if the CodeObject is not attached. - # - # This is used by Text#snippet - - def options - if @store and @store.rdoc then - @store.rdoc.options - else - RDoc::Options.new - end - end - - ## - # Our parent CodeObject. The parent may be missing for classes loaded from - # legacy RI data stores. - - def parent - return @parent if @parent - return nil unless @parent_name - - if @parent_class == RDoc::TopLevel then - @parent = @store.add_file @parent_name - else - @parent = @store.find_class_or_module @parent_name - - return @parent if @parent - - begin - @parent = @store.load_class @parent_name - rescue RDoc::Store::MissingFileError - nil - end - end - end - - ## - # File name of our parent - - def parent_file_name - @parent ? @parent.base_name : '(unknown)' - end - - ## - # Name of our parent - - def parent_name - @parent ? @parent.full_name : '(unknown)' - end - - ## - # Records the RDoc::TopLevel (file) where this code object was defined - - def record_location top_level - @ignored = false - @suppressed = false - @file = top_level - end - - ## - # The section this CodeObject is in. Sections allow grouping of constants, - # attributes and methods inside a class or module. - - def section - return @section if @section - - @section = parent.add_section @section_title if parent - end - - ## - # Enable capture of documentation unless documentation has been - # turned off by :enddoc: - - def start_doc - return if @done_documenting - - @document_self = true - @document_children = true - @ignored = false - @suppressed = false - end - - ## - # Disable capture of documentation - - def stop_doc - return unless @track_visibility - - @document_self = false - @document_children = false - end - - ## - # Sets the +store+ that contains this CodeObject - - def store= store - @store = store - - return unless @track_visibility - - if :nodoc == options.visibility then - initialize_visibility - @track_visibility = false - end - end - - ## - # Use this to suppress a CodeObject and all its children until the next file - # it is seen in or documentation is discovered. A suppressed item with - # documentation will be displayed while an ignored item with documentation - # may not be displayed. - - def suppress - return unless @track_visibility - - @suppressed = true - - stop_doc - end - - ## - # Has this class been suppressed? - # - # See also #suppress - - def suppressed? - @suppressed - end - -end diff --git a/lib/rdoc/code_object/alias.rb b/lib/rdoc/code_object/alias.rb deleted file mode 100644 index 92df7e448f..0000000000 --- a/lib/rdoc/code_object/alias.rb +++ /dev/null @@ -1,111 +0,0 @@ -# frozen_string_literal: true -## -# Represent an alias, which is an old_name/new_name pair associated with a -# particular context -#-- -# TODO implement Alias as a proxy to a method/attribute, inheriting from -# MethodAttr - -class RDoc::Alias < RDoc::CodeObject - - ## - # Aliased method's name - - attr_reader :new_name - - alias name new_name - - ## - # Aliasee method's name - - attr_reader :old_name - - ## - # Is this an alias declared in a singleton context? - - attr_accessor :singleton - - ## - # Source file token stream - - attr_reader :text - - ## - # Creates a new Alias with a token stream of +text+ that aliases +old_name+ - # to +new_name+, has +comment+ and is a +singleton+ context. - - def initialize(text, old_name, new_name, comment, singleton = false) - super() - - @text = text - @singleton = singleton - @old_name = old_name - @new_name = new_name - self.comment = comment - end - - ## - # Order by #singleton then #new_name - - def <=>(other) - [@singleton ? 0 : 1, new_name] <=> [other.singleton ? 0 : 1, other.new_name] - end - - ## - # HTML fragment reference for this alias - - def aref - type = singleton ? 'c' : 'i' - "#alias-#{type}-#{html_name}" - end - - ## - # Full old name including namespace - - def full_old_name - @full_name || "#{parent.name}#{pretty_old_name}" - end - - ## - # HTML id-friendly version of +#new_name+. - - def html_name - CGI.escape(@new_name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '') - end - - def inspect # :nodoc: - parent_name = parent ? parent.name : '(unknown)' - "#<%s:0x%x %s.alias_method %s, %s>" % [ - self.class, object_id, - parent_name, @old_name, @new_name, - ] - end - - ## - # '::' for the alias of a singleton method/attribute, '#' for instance-level. - - def name_prefix - singleton ? '::' : '#' - end - - ## - # Old name with prefix '::' or '#'. - - def pretty_old_name - "#{singleton ? '::' : '#'}#{@old_name}" - end - - ## - # New name with prefix '::' or '#'. - - def pretty_new_name - "#{singleton ? '::' : '#'}#{@new_name}" - end - - alias pretty_name pretty_new_name - - def to_s # :nodoc: - "alias: #{self.new_name} -> #{self.pretty_old_name} in: #{parent}" - end - -end diff --git a/lib/rdoc/code_object/anon_class.rb b/lib/rdoc/code_object/anon_class.rb deleted file mode 100644 index 3c2f0e1877..0000000000 --- a/lib/rdoc/code_object/anon_class.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true -## -# An anonymous class like: -# -# c = Class.new do end -# -# AnonClass is currently not used. - -class RDoc::AnonClass < RDoc::ClassModule -end diff --git a/lib/rdoc/code_object/any_method.rb b/lib/rdoc/code_object/any_method.rb deleted file mode 100644 index 465c4a4fb2..0000000000 --- a/lib/rdoc/code_object/any_method.rb +++ /dev/null @@ -1,379 +0,0 @@ -# frozen_string_literal: true -## -# AnyMethod is the base class for objects representing methods - -class RDoc::AnyMethod < RDoc::MethodAttr - - ## - # 2:: - # RDoc 4 - # Added calls_super - # Added parent name and class - # Added section title - # 3:: - # RDoc 4.1 - # Added is_alias_for - - MARSHAL_VERSION = 3 # :nodoc: - - ## - # Don't rename \#initialize to \::new - - attr_accessor :dont_rename_initialize - - ## - # The C function that implements this method (if it was defined in a C file) - - attr_accessor :c_function - - # The section title of the method (if defined in a C file via +:category:+) - attr_accessor :section_title - - # Parameters for this method - - attr_accessor :params - - ## - # If true this method uses +super+ to call a superclass version - - attr_accessor :calls_super - - include RDoc::TokenStream - - ## - # Creates a new AnyMethod with a token stream +text+ and +name+ - - def initialize text, name - super - - @c_function = nil - @dont_rename_initialize = false - @token_stream = nil - @calls_super = false - @superclass_method = nil - end - - ## - # Adds +an_alias+ as an alias for this method in +context+. - - def add_alias an_alias, context = nil - method = self.class.new an_alias.text, an_alias.new_name - - method.record_location an_alias.file - method.singleton = self.singleton - method.params = self.params - method.visibility = self.visibility - method.comment = an_alias.comment - method.is_alias_for = self - @aliases << method - context.add_method method if context - method - end - - ## - # Prefix for +aref+ is 'method'. - - def aref_prefix - 'method' - end - - ## - # The call_seq or the param_seq with method name, if there is no call_seq. - # - # Use this for displaying a method's argument lists. - - def arglists - if @call_seq then - @call_seq - elsif @params then - "#{name}#{param_seq}" - end - end - - ## - # Different ways to call this method - - def call_seq - unless call_seq = _call_seq - call_seq = is_alias_for._call_seq if is_alias_for - end - - return unless call_seq - - deduplicate_call_seq(call_seq) - end - - ## - # Sets the different ways you can call this method. If an empty +call_seq+ - # is given nil is assumed. - # - # See also #param_seq - - def call_seq= call_seq - return if call_seq.empty? - - @call_seq = call_seq - end - - ## - # Whether the method has a call-seq. - - def has_call_seq? - !!(@call_seq || is_alias_for&._call_seq) - end - - ## - # Loads is_alias_for from the internal name. Returns nil if the alias - # cannot be found. - - def is_alias_for # :nodoc: - case @is_alias_for - when RDoc::MethodAttr then - @is_alias_for - when Array then - return nil unless @store - - klass_name, singleton, method_name = @is_alias_for - - return nil unless klass = @store.find_class_or_module(klass_name) - - @is_alias_for = klass.find_method method_name, singleton - end - end - - ## - # Dumps this AnyMethod for use by ri. See also #marshal_load - - def marshal_dump - aliases = @aliases.map do |a| - [a.name, parse(a.comment)] - end - - is_alias_for = [ - @is_alias_for.parent.full_name, - @is_alias_for.singleton, - @is_alias_for.name - ] if @is_alias_for - - [ MARSHAL_VERSION, - @name, - full_name, - @singleton, - @visibility, - parse(@comment), - @call_seq, - @block_params, - aliases, - @params, - @file.relative_name, - @calls_super, - @parent.name, - @parent.class, - @section.title, - is_alias_for, - ] - end - - ## - # Loads this AnyMethod from +array+. For a loaded AnyMethod the following - # methods will return cached values: - # - # * #full_name - # * #parent_name - - def marshal_load array - initialize_visibility - - @dont_rename_initialize = nil - @token_stream = nil - @aliases = [] - @parent = nil - @parent_name = nil - @parent_class = nil - @section = nil - @file = nil - - version = array[0] - @name = array[1] - @full_name = array[2] - @singleton = array[3] - @visibility = array[4] - @comment = array[5] - @call_seq = array[6] - @block_params = array[7] - # 8 handled below - @params = array[9] - # 10 handled below - @calls_super = array[11] - @parent_name = array[12] - @parent_title = array[13] - @section_title = array[14] - @is_alias_for = array[15] - - array[8].each do |new_name, comment| - add_alias RDoc::Alias.new(nil, @name, new_name, comment, @singleton) - end - - @parent_name ||= if @full_name =~ /#/ then - $` - else - name = @full_name.split('::') - name.pop - name.join '::' - end - - @file = RDoc::TopLevel.new array[10] if version > 0 - end - - ## - # Method name - # - # If the method has no assigned name, it extracts it from #call_seq. - - def name - return @name if @name - - @name = - @call_seq[/^.*?\.(\w+)/, 1] || - @call_seq[/^.*?(\w+)/, 1] || - @call_seq if @call_seq - end - - ## - # A list of this method's method and yield parameters. +call-seq+ params - # are preferred over parsed method and block params. - - def param_list - if @call_seq then - params = @call_seq.split("\n").last - params = params.sub(/.*?\((.*)\)/, '\1') - params = params.sub(/(\{|do)\s*\|([^|]*)\|.*/, ',\2') - elsif @params then - params = @params.sub(/\((.*)\)/, '\1') - - params << ",#{@block_params}" if @block_params - elsif @block_params then - params = @block_params - else - return [] - end - - if @block_params then - # If this method has explicit block parameters, remove any explicit - # &block - params = params.sub(/,?\s*&\w+/, '') - else - params = params.sub(/\&(\w+)/, '\1') - end - - params = params.gsub(/\s+/, '').split(',').reject(&:empty?) - - params.map { |param| param.sub(/=.*/, '') } - end - - ## - # Pretty parameter list for this method. If the method's parameters were - # given by +call-seq+ it is preferred over the parsed values. - - def param_seq - if @call_seq then - params = @call_seq.split("\n").last - params = params.sub(/[^( ]+/, '') - params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2') - elsif @params then - params = @params.gsub(/\s*\#.*/, '') - params = params.tr_s("\n ", " ") - params = "(#{params})" unless params[0] == ?( - else - params = '' - end - - if @block_params then - # If this method has explicit block parameters, remove any explicit - # &block - params = params.sub(/,?\s*&\w+/, '') - - block = @block_params.tr_s("\n ", " ") - if block[0] == ?( - block = block.sub(/^\(/, '').sub(/\)/, '') - end - params << " { |#{block}| ... }" - end - - params - end - - ## - # Whether to skip the method description, true for methods that have - # aliases with a call-seq that doesn't include the method name. - - def skip_description? - has_call_seq? && call_seq.nil? && !!(is_alias_for || !aliases.empty?) - end - - ## - # Sets the store for this method and its referenced code objects. - - def store= store - super - - @file = @store.add_file @file.full_name if @file - end - - ## - # For methods that +super+, find the superclass method that would be called. - - def superclass_method - return unless @calls_super - return @superclass_method if @superclass_method - - parent.each_ancestor do |ancestor| - if method = ancestor.method_list.find { |m| m.name == @name } then - @superclass_method = method - break - end - end - - @superclass_method - end - - protected - - ## - # call_seq without deduplication and alias lookup. - - def _call_seq - @call_seq if defined?(@call_seq) && @call_seq - end - - private - - ## - # call_seq with alias examples information removed, if this - # method is an alias method. - - def deduplicate_call_seq(call_seq) - return call_seq unless is_alias_for || !aliases.empty? - - method_name = self.name - method_name = method_name[0, 1] if method_name =~ /\A\[/ - - entries = call_seq.split "\n" - - ignore = aliases.map(&:name) - if is_alias_for - ignore << is_alias_for.name - ignore.concat is_alias_for.aliases.map(&:name) - end - ignore.map! { |n| n =~ /\A\[/ ? /\[.*\]/ : n} - ignore.delete(method_name) - ignore = Regexp.union(ignore) - - matching = entries.reject do |entry| - entry =~ /^\w*\.?#{ignore}[$\(\s]/ or - entry =~ /\s#{ignore}\s/ - end - - matching.empty? ? nil : matching.join("\n") - end -end diff --git a/lib/rdoc/code_object/attr.rb b/lib/rdoc/code_object/attr.rb deleted file mode 100644 index a403235933..0000000000 --- a/lib/rdoc/code_object/attr.rb +++ /dev/null @@ -1,175 +0,0 @@ -# frozen_string_literal: true -## -# An attribute created by \#attr, \#attr_reader, \#attr_writer or -# \#attr_accessor - -class RDoc::Attr < RDoc::MethodAttr - - ## - # 3:: - # RDoc 4 - # Added parent name and class - # Added section title - - MARSHAL_VERSION = 3 # :nodoc: - - ## - # Is the attribute readable ('R'), writable ('W') or both ('RW')? - - attr_accessor :rw - - ## - # Creates a new Attr with body +text+, +name+, read/write status +rw+ and - # +comment+. +singleton+ marks this as a class attribute. - - def initialize(text, name, rw, comment, singleton = false) - super text, name - - @rw = rw - @singleton = singleton - self.comment = comment - end - - ## - # Attributes are equal when their names, singleton and rw are identical - - def == other - self.class == other.class and - self.name == other.name and - self.rw == other.rw and - self.singleton == other.singleton - end - - ## - # Add +an_alias+ as an attribute in +context+. - - def add_alias(an_alias, context) - new_attr = self.class.new(self.text, an_alias.new_name, self.rw, - self.comment, self.singleton) - - new_attr.record_location an_alias.file - new_attr.visibility = self.visibility - new_attr.is_alias_for = self - @aliases << new_attr - context.add_attribute new_attr - new_attr - end - - ## - # The #aref prefix for attributes - - def aref_prefix - 'attribute' - end - - ## - # Attributes never call super. See RDoc::AnyMethod#calls_super - # - # An RDoc::Attr can show up in the method list in some situations (see - # Gem::ConfigFile) - - def calls_super # :nodoc: - false - end - - ## - # Returns attr_reader, attr_writer or attr_accessor as appropriate. - - def definition - case @rw - when 'RW' then 'attr_accessor' - when 'R' then 'attr_reader' - when 'W' then 'attr_writer' - end - end - - def inspect # :nodoc: - alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil - visibility = self.visibility - visibility = "forced #{visibility}" if force_documentation - "#<%s:0x%x %s %s (%s)%s>" % [ - self.class, object_id, - full_name, - rw, - visibility, - alias_for, - ] - end - - ## - # Dumps this Attr for use by ri. See also #marshal_load - - def marshal_dump - [ MARSHAL_VERSION, - @name, - full_name, - @rw, - @visibility, - parse(@comment), - singleton, - @file.relative_name, - @parent.full_name, - @parent.class, - @section.title - ] - end - - ## - # Loads this Attr from +array+. For a loaded Attr the following - # methods will return cached values: - # - # * #full_name - # * #parent_name - - def marshal_load array - initialize_visibility - - @aliases = [] - @parent = nil - @parent_name = nil - @parent_class = nil - @section = nil - @file = nil - - version = array[0] - @name = array[1] - @full_name = array[2] - @rw = array[3] - @visibility = array[4] - @comment = array[5] - @singleton = array[6] || false # MARSHAL_VERSION == 0 - # 7 handled below - @parent_name = array[8] - @parent_class = array[9] - @section_title = array[10] - - @file = RDoc::TopLevel.new array[7] if version > 1 - - @parent_name ||= @full_name.split('#', 2).first - end - - def pretty_print q # :nodoc: - q.group 2, "[#{self.class.name} #{full_name} #{rw} #{visibility}", "]" do - unless comment.empty? then - q.breakable - q.text "comment:" - q.breakable - q.pp @comment - end - end - end - - def to_s # :nodoc: - "#{definition} #{name} in: #{parent}" - end - - ## - # Attributes do not have token streams. - # - # An RDoc::Attr can show up in the method list in some situations (see - # Gem::ConfigFile) - - def token_stream # :nodoc: - end - -end diff --git a/lib/rdoc/code_object/class_module.rb b/lib/rdoc/code_object/class_module.rb deleted file mode 100644 index 33e71ab3f3..0000000000 --- a/lib/rdoc/code_object/class_module.rb +++ /dev/null @@ -1,868 +0,0 @@ -# frozen_string_literal: true -## -# ClassModule is the base class for objects representing either a class or a -# module. - -class RDoc::ClassModule < RDoc::Context - - ## - # 1:: - # RDoc 3.7 - # * Added visibility, singleton and file to attributes - # * Added file to constants - # * Added file to includes - # * Added file to methods - # 2:: - # RDoc 3.13 - # * Added extends - # 3:: - # RDoc 4.0 - # * Added sections - # * Added in_files - # * Added parent name - # * Complete Constant dump - - MARSHAL_VERSION = 3 # :nodoc: - - ## - # Constants that are aliases for this class or module - - attr_accessor :constant_aliases - - ## - # Comment and the location it came from. Use #add_comment to add comments - - attr_accessor :comment_location - - attr_accessor :diagram # :nodoc: - - ## - # Class or module this constant is an alias for - - attr_accessor :is_alias_for - - ## - # Return a RDoc::ClassModule of class +class_type+ that is a copy - # of module +module+. Used to promote modules to classes. - #-- - # TODO move to RDoc::NormalClass (I think) - - def self.from_module class_type, mod - klass = class_type.new mod.name - - mod.comment_location.each do |comment, location| - klass.add_comment comment, location - end - - klass.parent = mod.parent - klass.section = mod.section - klass.viewer = mod.viewer - - klass.attributes.concat mod.attributes - klass.method_list.concat mod.method_list - klass.aliases.concat mod.aliases - klass.external_aliases.concat mod.external_aliases - klass.constants.concat mod.constants - klass.includes.concat mod.includes - klass.extends.concat mod.extends - - klass.methods_hash.update mod.methods_hash - klass.constants_hash.update mod.constants_hash - - klass.current_section = mod.current_section - klass.in_files.concat mod.in_files - klass.sections.concat mod.sections - klass.unmatched_alias_lists = mod.unmatched_alias_lists - klass.current_section = mod.current_section - klass.visibility = mod.visibility - - klass.classes_hash.update mod.classes_hash - klass.modules_hash.update mod.modules_hash - klass.metadata.update mod.metadata - - klass.document_self = mod.received_nodoc ? nil : mod.document_self - klass.document_children = mod.document_children - klass.force_documentation = mod.force_documentation - klass.done_documenting = mod.done_documenting - - # update the parent of all children - - (klass.attributes + - klass.method_list + - klass.aliases + - klass.external_aliases + - klass.constants + - klass.includes + - klass.extends + - klass.classes + - klass.modules).each do |obj| - obj.parent = klass - obj.full_name = nil - end - - klass - end - - ## - # Creates a new ClassModule with +name+ with optional +superclass+ - # - # This is a constructor for subclasses, and must never be called directly. - - def initialize(name, superclass = nil) - @constant_aliases = [] - @diagram = nil - @is_alias_for = nil - @name = name - @superclass = superclass - @comment_location = [] # [[comment, location]] - - super() - end - - ## - # Adds +comment+ to this ClassModule's list of comments at +location+. This - # method is preferred over #comment= since it allows ri data to be updated - # across multiple runs. - - def add_comment comment, location - return unless document_self - - original = comment - - comment = case comment - when RDoc::Comment then - comment.normalize - else - normalize_comment comment - end - - if location.parser == RDoc::Parser::C - @comment_location.delete_if { |(_, l)| l == location } - end - - @comment_location << [comment, location] - - self.comment = original - end - - def add_things my_things, other_things # :nodoc: - other_things.each do |group, things| - my_things[group].each { |thing| yield false, thing } if - my_things.include? group - - things.each do |thing| - yield true, thing - end - end - end - - ## - # Ancestors list for this ClassModule: the list of included modules - # (classes will add their superclass if any). - # - # Returns the included classes or modules, not the includes - # themselves. The returned values are either String or - # RDoc::NormalModule instances (see RDoc::Include#module). - # - # The values are returned in reverse order of their inclusion, - # which is the order suitable for searching methods/attributes - # in the ancestors. The superclass, if any, comes last. - - def ancestors - includes.map { |i| i.module }.reverse - end - - def aref_prefix # :nodoc: - raise NotImplementedError, "missing aref_prefix for #{self.class}" - end - - ## - # HTML fragment reference for this module or class. See - # RDoc::NormalClass#aref and RDoc::NormalModule#aref - - def aref - "#{aref_prefix}-#{full_name}" - end - - ## - # Ancestors of this class or module only - - alias direct_ancestors ancestors - - ## - # Clears the comment. Used by the Ruby parser. - - def clear_comment - @comment = '' - end - - ## - # This method is deprecated, use #add_comment instead. - # - # Appends +comment+ to the current comment, but separated by a rule. Works - # more like +=. - - def comment= comment # :nodoc: - comment = case comment - when RDoc::Comment then - comment.normalize - else - normalize_comment comment - end - - comment = "#{@comment.to_s}\n---\n#{comment.to_s}" unless @comment.empty? - - super comment - end - - ## - # Prepares this ClassModule for use by a generator. - # - # See RDoc::Store#complete - - def complete min_visibility - update_aliases - remove_nodoc_children - embed_mixins - update_includes - remove_invisible min_visibility - end - - ## - # Does this ClassModule or any of its methods have document_self set? - - def document_self_or_methods - document_self || method_list.any?{ |m| m.document_self } - end - - ## - # Does this class or module have a comment with content or is - # #received_nodoc true? - - def documented? - return true if @received_nodoc - return false if @comment_location.empty? - @comment_location.any? { |comment, _| not comment.empty? } - end - - ## - # Iterates the ancestors of this class or module for which an - # RDoc::ClassModule exists. - - def each_ancestor # :yields: module - return enum_for __method__ unless block_given? - - ancestors.each do |mod| - next if String === mod - next if self == mod - yield mod - end - end - - ## - # Looks for a symbol in the #ancestors. See Context#find_local_symbol. - - def find_ancestor_local_symbol symbol - each_ancestor do |m| - res = m.find_local_symbol(symbol) - return res if res - end - - nil - end - - ## - # Finds a class or module with +name+ in this namespace or its descendants - - def find_class_named name - return self if full_name == name - return self if @name == name - - @classes.values.find do |klass| - next if klass == self - klass.find_class_named name - end - end - - ## - # Return the fully qualified name of this class or module - - def full_name - @full_name ||= if RDoc::ClassModule === parent then - "#{parent.full_name}::#{@name}" - else - @name - end - end - - ## - # TODO: filter included items by #display? - - def marshal_dump # :nodoc: - attrs = attributes.sort.map do |attr| - next unless attr.display? - [ attr.name, attr.rw, - attr.visibility, attr.singleton, attr.file_name, - ] - end.compact - - method_types = methods_by_type.map do |type, visibilities| - visibilities = visibilities.map do |visibility, methods| - method_names = methods.map do |method| - next unless method.display? - [method.name, method.file_name] - end.compact - - [visibility, method_names.uniq] - end - - [type, visibilities] - end - - [ MARSHAL_VERSION, - @name, - full_name, - @superclass, - parse(@comment_location), - attrs, - constants.select { |constant| constant.display? }, - includes.map do |incl| - next unless incl.display? - [incl.name, parse(incl.comment), incl.file_name] - end.compact, - method_types, - extends.map do |ext| - next unless ext.display? - [ext.name, parse(ext.comment), ext.file_name] - end.compact, - @sections.values, - @in_files.map do |tl| - tl.relative_name - end, - parent.full_name, - parent.class, - ] - end - - def marshal_load array # :nodoc: - initialize_visibility - initialize_methods_etc - @current_section = nil - @document_self = true - @done_documenting = false - @parent = nil - @temporary_section = nil - @visibility = nil - @classes = {} - @modules = {} - - @name = array[1] - @full_name = array[2] - @superclass = array[3] - @comment = array[4] - - @comment_location = if RDoc::Markup::Document === @comment.parts.first then - @comment - else - RDoc::Markup::Document.new @comment - end - - array[5].each do |name, rw, visibility, singleton, file| - singleton ||= false - visibility ||= :public - - attr = RDoc::Attr.new nil, name, rw, nil, singleton - - add_attribute attr - attr.visibility = visibility - attr.record_location RDoc::TopLevel.new file - end - - array[6].each do |constant, comment, file| - case constant - when RDoc::Constant then - add_constant constant - else - constant = add_constant RDoc::Constant.new(constant, nil, comment) - constant.record_location RDoc::TopLevel.new file - end - end - - array[7].each do |name, comment, file| - incl = add_include RDoc::Include.new(name, comment) - incl.record_location RDoc::TopLevel.new file - end - - array[8].each do |type, visibilities| - visibilities.each do |visibility, methods| - @visibility = visibility - - methods.each do |name, file| - method = RDoc::AnyMethod.new nil, name - method.singleton = true if type == 'class' - method.record_location RDoc::TopLevel.new file - add_method method - end - end - end - - array[9].each do |name, comment, file| - ext = add_extend RDoc::Extend.new(name, comment) - ext.record_location RDoc::TopLevel.new file - end if array[9] # Support Marshal version 1 - - sections = (array[10] || []).map do |section| - [section.title, section] - end - - @sections = Hash[*sections.flatten] - @current_section = add_section nil - - @in_files = [] - - (array[11] || []).each do |filename| - record_location RDoc::TopLevel.new filename - end - - @parent_name = array[12] - @parent_class = array[13] - end - - ## - # Merges +class_module+ into this ClassModule. - # - # The data in +class_module+ is preferred over the receiver. - - def merge class_module - @parent = class_module.parent - @parent_name = class_module.parent_name - - other_document = parse class_module.comment_location - - if other_document then - document = parse @comment_location - - document = document.merge other_document - - @comment = @comment_location = document - end - - cm = class_module - other_files = cm.in_files - - merge_collections attributes, cm.attributes, other_files do |add, attr| - if add then - add_attribute attr - else - @attributes.delete attr - @methods_hash.delete attr.pretty_name - end - end - - merge_collections constants, cm.constants, other_files do |add, const| - if add then - add_constant const - else - @constants.delete const - @constants_hash.delete const.name - end - end - - merge_collections includes, cm.includes, other_files do |add, incl| - if add then - add_include incl - else - @includes.delete incl - end - end - - @includes.uniq! # clean up - - merge_collections extends, cm.extends, other_files do |add, ext| - if add then - add_extend ext - else - @extends.delete ext - end - end - - @extends.uniq! # clean up - - merge_collections method_list, cm.method_list, other_files do |add, meth| - if add then - add_method meth - else - @method_list.delete meth - @methods_hash.delete meth.pretty_name - end - end - - merge_sections cm - - self - end - - ## - # Merges collection +mine+ with +other+ preferring other. +other_files+ is - # used to help determine which items should be deleted. - # - # Yields whether the item should be added or removed (true or false) and the - # item to be added or removed. - # - # merge_collections things, other.things, other.in_files do |add, thing| - # if add then - # # add the thing - # else - # # remove the thing - # end - # end - - def merge_collections mine, other, other_files, &block # :nodoc: - my_things = mine. group_by { |thing| thing.file } - other_things = other.group_by { |thing| thing.file } - - remove_things my_things, other_files, &block - add_things my_things, other_things, &block - end - - ## - # Merges the comments in this ClassModule with the comments in the other - # ClassModule +cm+. - - def merge_sections cm # :nodoc: - my_sections = sections.group_by { |section| section.title } - other_sections = cm.sections.group_by { |section| section.title } - - other_files = cm.in_files - - remove_things my_sections, other_files do |_, section| - @sections.delete section.title - end - - other_sections.each do |group, sections| - if my_sections.include? group - my_sections[group].each do |my_section| - other_section = cm.sections_hash[group] - - my_comments = my_section.comments - other_comments = other_section.comments - - other_files = other_section.in_files - - merge_collections my_comments, other_comments, other_files do |add, comment| - if add then - my_section.add_comment comment - else - my_section.remove_comment comment - end - end - end - else - sections.each do |section| - add_section group, section.comments - end - end - end - end - - ## - # Does this object represent a module? - - def module? - false - end - - ## - # Allows overriding the initial name. - # - # Used for modules and classes that are constant aliases. - - def name= new_name - @name = new_name - end - - ## - # Parses +comment_location+ into an RDoc::Markup::Document composed of - # multiple RDoc::Markup::Documents with their file set. - - def parse comment_location - case comment_location - when String then - super - when Array then - docs = comment_location.map do |comment, location| - doc = super comment - doc.file = location - doc - end - - RDoc::Markup::Document.new(*docs) - when RDoc::Comment then - doc = super comment_location.text, comment_location.format - doc.file = comment_location.location - doc - when RDoc::Markup::Document then - return comment_location - else - raise ArgumentError, "unknown comment class #{comment_location.class}" - end - end - - ## - # Path to this class or module for use with HTML generator output. - - def path - http_url @store.rdoc.generator.class_dir - end - - ## - # Name to use to generate the url: - # modules and classes that are aliases for another - # module or class return the name of the latter. - - def name_for_path - is_alias_for ? is_alias_for.full_name : full_name - end - - ## - # Returns the classes and modules that are not constants - # aliasing another class or module. For use by formatters - # only (caches its result). - - def non_aliases - @non_aliases ||= classes_and_modules.reject { |cm| cm.is_alias_for } - end - - ## - # Updates the child modules or classes of class/module +parent+ by - # deleting the ones that have been removed from the documentation. - # - # +parent_hash+ is either parent.modules_hash or - # parent.classes_hash and +all_hash+ is ::all_modules_hash or - # ::all_classes_hash. - - def remove_nodoc_children - prefix = self.full_name + '::' - - modules_hash.each_key do |name| - full_name = prefix + name - modules_hash.delete name unless @store.modules_hash[full_name] - end - - classes_hash.each_key do |name| - full_name = prefix + name - classes_hash.delete name unless @store.classes_hash[full_name] - end - end - - def remove_things my_things, other_files # :nodoc: - my_things.delete_if do |file, things| - next false unless other_files.include? file - - things.each do |thing| - yield false, thing - end - - true - end - end - - ## - # Search record used by RDoc::Generator::JsonIndex - - def search_record - [ - name, - full_name, - full_name, - '', - path, - '', - snippet(@comment_location), - ] - end - - ## - # Sets the store for this class or module and its contained code objects. - - def store= store - super - - @attributes .each do |attr| attr.store = store end - @constants .each do |const| const.store = store end - @includes .each do |incl| incl.store = store end - @extends .each do |ext| ext.store = store end - @method_list.each do |meth| meth.store = store end - end - - ## - # Get the superclass of this class. Attempts to retrieve the superclass - # object, returns the name if it is not known. - - def superclass - @store.find_class_named(@superclass) || @superclass - end - - ## - # Set the superclass of this class to +superclass+ - # - # where +superclass+ is one of: - # - # - +nil+ - # - a String containing the full name of the superclass - # - the RDoc::ClassModule representing the superclass - - def superclass=(superclass) - raise NoMethodError, "#{full_name} is a module" if module? - case superclass - when RDoc::ClassModule - @superclass = superclass.full_name - when nil, String - @superclass = superclass - else - raise TypeError, "superclass must be a String or RDoc::ClassModule, not #{superclass.class}" - end - end - - ## - # Get all super classes of this class in an array. The last element might be - # a string if the name is unknown. - - def super_classes - result = [] - parent = self - while parent = parent.superclass - result << parent - return result if parent.is_a?(String) - end - result - end - - def to_s # :nodoc: - if is_alias_for then - "#{self.class.name} #{self.full_name} -> #{is_alias_for}" - else - super - end - end - - ## - # 'module' or 'class' - - def type - module? ? 'module' : 'class' - end - - ## - # Updates the child modules & classes by replacing the ones that are - # aliases through a constant. - # - # The aliased module/class is replaced in the children and in - # RDoc::Store#modules_hash or RDoc::Store#classes_hash - # by a copy that has RDoc::ClassModule#is_alias_for set to - # the aliased module/class, and this copy is added to #aliases - # of the aliased module/class. - # - # Formatters can use the #non_aliases method to retrieve children that - # are not aliases, for instance to list the namespace content, since - # the aliased modules are included in the constants of the class/module, - # that are listed separately. - - def update_aliases - constants.each do |const| - next unless cm = const.is_alias_for - cm_alias = cm.dup - cm_alias.name = const.name - - # Don't move top-level aliases under Object, they look ugly there - unless RDoc::TopLevel === cm_alias.parent then - cm_alias.parent = self - cm_alias.full_name = nil # force update for new parent - end - - cm_alias.aliases.clear - cm_alias.is_alias_for = cm - - if cm.module? then - @store.modules_hash[cm_alias.full_name] = cm_alias - modules_hash[const.name] = cm_alias - else - @store.classes_hash[cm_alias.full_name] = cm_alias - classes_hash[const.name] = cm_alias - end - - cm.aliases << cm_alias - end - end - - ## - # Deletes from #includes those whose module has been removed from the - # documentation. - #-- - # FIXME: includes are not reliably removed, see _possible_bug test case - - def update_includes - includes.reject! do |include| - mod = include.module - !(String === mod) && @store.modules_hash[mod.full_name].nil? - end - - includes.uniq! - end - - ## - # Deletes from #extends those whose module has been removed from the - # documentation. - #-- - # FIXME: like update_includes, extends are not reliably removed - - def update_extends - extends.reject! do |ext| - mod = ext.module - - !(String === mod) && @store.modules_hash[mod.full_name].nil? - end - - extends.uniq! - end - - def embed_mixins - return unless options.embed_mixins - - includes.each do |include| - next if String === include.module - include.module.method_list.each do |code_object| - add_method(prepare_to_embed(code_object)) - end - include.module.constants.each do |code_object| - add_constant(prepare_to_embed(code_object)) - end - include.module.attributes.each do |code_object| - add_attribute(prepare_to_embed(code_object)) - end - end - - extends.each do |ext| - next if String === ext.module - ext.module.method_list.each do |code_object| - add_method(prepare_to_embed(code_object, true)) - end - ext.module.attributes.each do |code_object| - add_attribute(prepare_to_embed(code_object, true)) - end - end - end - - private - - def prepare_to_embed(code_object, singleton=false) - code_object = code_object.dup - code_object.mixin_from = code_object.parent - code_object.singleton = true if singleton - set_current_section(code_object.section.title, code_object.section.comment) - # add_method and add_attribute will reassign self's visibility back to the method/attribute - # so we need to sync self's visibility with the object's to properly retain that information - self.visibility = code_object.visibility - code_object - end -end diff --git a/lib/rdoc/code_object/constant.rb b/lib/rdoc/code_object/constant.rb deleted file mode 100644 index 12b8be775c..0000000000 --- a/lib/rdoc/code_object/constant.rb +++ /dev/null @@ -1,186 +0,0 @@ -# frozen_string_literal: true -## -# A constant - -class RDoc::Constant < RDoc::CodeObject - - MARSHAL_VERSION = 0 # :nodoc: - - ## - # Sets the module or class this is constant is an alias for. - - attr_writer :is_alias_for - - ## - # The constant's name - - attr_accessor :name - - ## - # The constant's value - - attr_accessor :value - - ## - # The constant's visibility - - attr_accessor :visibility - - ## - # Creates a new constant with +name+, +value+ and +comment+ - - def initialize(name, value, comment) - super() - - @name = name - @value = value - - @is_alias_for = nil - @visibility = :public - - self.comment = comment - end - - ## - # Constants are ordered by name - - def <=> other - return unless self.class === other - - [parent_name, name] <=> [other.parent_name, other.name] - end - - ## - # Constants are equal when their #parent and #name is the same - - def == other - self.class == other.class and - @parent == other.parent and - @name == other.name - end - - ## - # A constant is documented if it has a comment, or is an alias - # for a documented class or module. - - def documented? - return true if super - return false unless @is_alias_for - case @is_alias_for - when String then - found = @store.find_class_or_module @is_alias_for - return false unless found - @is_alias_for = found - end - @is_alias_for.documented? - end - - ## - # Full constant name including namespace - - def full_name - @full_name ||= "#{parent_name}::#{@name}" - end - - ## - # The module or class this constant is an alias for - - def is_alias_for - case @is_alias_for - when String then - found = @store.find_class_or_module @is_alias_for - @is_alias_for = found if found - @is_alias_for - else - @is_alias_for - end - end - - def inspect # :nodoc: - "#<%s:0x%x %s::%s>" % [ - self.class, object_id, - parent_name, @name, - ] - end - - ## - # Dumps this Constant for use by ri. See also #marshal_load - - def marshal_dump - alias_name = case found = is_alias_for - when RDoc::CodeObject then found.full_name - else found - end - - [ MARSHAL_VERSION, - @name, - full_name, - @visibility, - alias_name, - parse(@comment), - @file.relative_name, - parent.name, - parent.class, - section.title, - ] - end - - ## - # Loads this Constant from +array+. For a loaded Constant the following - # methods will return cached values: - # - # * #full_name - # * #parent_name - - def marshal_load array - initialize array[1], nil, array[5] - - @full_name = array[2] - @visibility = array[3] || :public - @is_alias_for = array[4] - # 5 handled above - # 6 handled below - @parent_name = array[7] - @parent_class = array[8] - @section_title = array[9] - - @file = RDoc::TopLevel.new array[6] - end - - ## - # Path to this constant for use with HTML generator output. - - def path - "#{@parent.path}##{@name}" - end - - def pretty_print q # :nodoc: - q.group 2, "[#{self.class.name} #{full_name}", "]" do - unless comment.empty? then - q.breakable - q.text "comment:" - q.breakable - q.pp @comment - end - end - end - - ## - # Sets the store for this class or module and its contained code objects. - - def store= store - super - - @file = @store.add_file @file.full_name if @file - end - - def to_s # :nodoc: - parent_name = parent ? parent.full_name : '(unknown)' - if is_alias_for - "constant #{parent_name}::#@name -> #{is_alias_for}" - else - "constant #{parent_name}::#@name" - end - end - -end diff --git a/lib/rdoc/code_object/context.rb b/lib/rdoc/code_object/context.rb deleted file mode 100644 index c688d562c3..0000000000 --- a/lib/rdoc/code_object/context.rb +++ /dev/null @@ -1,1264 +0,0 @@ -# frozen_string_literal: true -## -# A Context is something that can hold modules, classes, methods, attributes, -# aliases, requires, and includes. Classes, modules, and files are all -# Contexts. - -class RDoc::Context < RDoc::CodeObject - - include Comparable - - ## - # Types of methods - - TYPES = %w[class instance] - - ## - # If a context has these titles it will be sorted in this order. - - TOMDOC_TITLES = [nil, 'Public', 'Internal', 'Deprecated'] # :nodoc: - TOMDOC_TITLES_SORT = TOMDOC_TITLES.sort_by { |title| title.to_s } # :nodoc: - - ## - # Class/module aliases - - attr_reader :aliases - - ## - # All attr* methods - - attr_reader :attributes - - ## - # Block params to be used in the next MethodAttr parsed under this context - - attr_accessor :block_params - - ## - # Constants defined - - attr_reader :constants - - ## - # Sets the current documentation section of documentation - - attr_writer :current_section - - ## - # Files this context is found in - - attr_reader :in_files - - ## - # Modules this context includes - - attr_reader :includes - - ## - # Modules this context is extended with - - attr_reader :extends - - ## - # Methods defined in this context - - attr_reader :method_list - - ## - # Name of this class excluding namespace. See also full_name - - attr_reader :name - - ## - # Files this context requires - - attr_reader :requires - - ## - # Use this section for the next method, attribute or constant added. - - attr_accessor :temporary_section - - ## - # Hash old_name => [aliases], for aliases - # that haven't (yet) been resolved to a method/attribute. - # (Not to be confused with the aliases of the context.) - - attr_accessor :unmatched_alias_lists - - ## - # Aliases that could not be resolved. - - attr_reader :external_aliases - - ## - # Current visibility of this context - - attr_accessor :visibility - - ## - # Current visibility of this line - - attr_writer :current_line_visibility - - ## - # Hash of registered methods. Attributes are also registered here, - # twice if they are RW. - - attr_reader :methods_hash - - ## - # Params to be used in the next MethodAttr parsed under this context - - attr_accessor :params - - ## - # Hash of registered constants. - - attr_reader :constants_hash - - ## - # Creates an unnamed empty context with public current visibility - - def initialize - super - - @in_files = [] - - @name ||= "unknown" - @parent = nil - @visibility = :public - - @current_section = Section.new self, nil, nil - @sections = { nil => @current_section } - @temporary_section = nil - - @classes = {} - @modules = {} - - initialize_methods_etc - end - - ## - # Sets the defaults for methods and so-forth - - def initialize_methods_etc - @method_list = [] - @attributes = [] - @aliases = [] - @requires = [] - @includes = [] - @extends = [] - @constants = [] - @external_aliases = [] - @current_line_visibility = nil - - # This Hash maps a method name to a list of unmatched aliases (aliases of - # a method not yet encountered). - @unmatched_alias_lists = {} - - @methods_hash = {} - @constants_hash = {} - - @params = nil - - @store ||= nil - end - - ## - # Contexts are sorted by full_name - - def <=>(other) - return nil unless RDoc::CodeObject === other - - full_name <=> other.full_name - end - - ## - # Adds an item of type +klass+ with the given +name+ and +comment+ to the - # context. - # - # Currently only RDoc::Extend and RDoc::Include are supported. - - def add klass, name, comment - if RDoc::Extend == klass then - ext = RDoc::Extend.new name, comment - add_extend ext - elsif RDoc::Include == klass then - incl = RDoc::Include.new name, comment - add_include incl - else - raise NotImplementedError, "adding a #{klass} is not implemented" - end - end - - ## - # Adds +an_alias+ that is automatically resolved - - def add_alias an_alias - return an_alias unless @document_self - - method_attr = find_method(an_alias.old_name, an_alias.singleton) || - find_attribute(an_alias.old_name, an_alias.singleton) - - if method_attr then - method_attr.add_alias an_alias, self - else - add_to @external_aliases, an_alias - unmatched_alias_list = - @unmatched_alias_lists[an_alias.pretty_old_name] ||= [] - unmatched_alias_list.push an_alias - end - - an_alias - end - - ## - # Adds +attribute+ if not already there. If it is (as method(s) or attribute), - # updates the comment if it was empty. - # - # The attribute is registered only if it defines a new method. - # For instance, attr_reader :foo will not be registered - # if method +foo+ exists, but attr_accessor :foo will be registered - # if method +foo+ exists, but foo= does not. - - def add_attribute attribute - return attribute unless @document_self - - # mainly to check for redefinition of an attribute as a method - # TODO find a policy for 'attr_reader :foo' + 'def foo=()' - register = false - - key = nil - - if attribute.rw.index 'R' then - key = attribute.pretty_name - known = @methods_hash[key] - - if known then - known.comment = attribute.comment if known.comment.empty? - elsif registered = @methods_hash[attribute.pretty_name + '='] and - RDoc::Attr === registered then - registered.rw = 'RW' - else - @methods_hash[key] = attribute - register = true - end - end - - if attribute.rw.index 'W' then - key = attribute.pretty_name + '=' - known = @methods_hash[key] - - if known then - known.comment = attribute.comment if known.comment.empty? - elsif registered = @methods_hash[attribute.pretty_name] and - RDoc::Attr === registered then - registered.rw = 'RW' - else - @methods_hash[key] = attribute - register = true - end - end - - if register then - attribute.visibility = @visibility - add_to @attributes, attribute - resolve_aliases attribute - end - - attribute - end - - ## - # Adds a class named +given_name+ with +superclass+. - # - # Both +given_name+ and +superclass+ may contain '::', and are - # interpreted relative to the +self+ context. This allows handling correctly - # examples like these: - # class RDoc::Gauntlet < Gauntlet - # module Mod - # class Object # implies < ::Object - # class SubObject < Object # this is _not_ ::Object - # - # Given class Container::Item RDoc assumes +Container+ is a module - # unless it later sees class Container. +add_class+ automatically - # upgrades +given_name+ to a class in this case. - - def add_class class_type, given_name, superclass = '::Object' - # superclass +nil+ is passed by the C parser in the following cases: - # - registering Object in 1.8 (correct) - # - registering BasicObject in 1.9 (correct) - # - registering RubyVM in 1.9 in iseq.c (incorrect: < Object in vm.c) - # - # If we later find a superclass for a registered class with a nil - # superclass, we must honor it. - - # find the name & enclosing context - if given_name =~ /^:+(\w+)$/ then - full_name = $1 - enclosing = top_level - name = full_name.split(/:+/).last - else - full_name = child_name given_name - - if full_name =~ /^(.+)::(\w+)$/ then - name = $2 - ename = $1 - enclosing = @store.classes_hash[ename] || @store.modules_hash[ename] - # HACK: crashes in actionpack/lib/action_view/helpers/form_helper.rb (metaprogramming) - unless enclosing then - # try the given name at top level (will work for the above example) - enclosing = @store.classes_hash[given_name] || - @store.modules_hash[given_name] - return enclosing if enclosing - # not found: create the parent(s) - names = ename.split('::') - enclosing = self - names.each do |n| - enclosing = enclosing.classes_hash[n] || - enclosing.modules_hash[n] || - enclosing.add_module(RDoc::NormalModule, n) - end - end - else - name = full_name - enclosing = self - end - end - - # fix up superclass - if full_name == 'BasicObject' then - superclass = nil - elsif full_name == 'Object' then - superclass = '::BasicObject' - end - - # find the superclass full name - if superclass then - if superclass =~ /^:+/ then - superclass = $' #' - else - if superclass =~ /^(\w+):+(.+)$/ then - suffix = $2 - mod = find_module_named($1) - superclass = mod.full_name + '::' + suffix if mod - else - mod = find_module_named(superclass) - superclass = mod.full_name if mod - end - end - - # did we believe it was a module? - mod = @store.modules_hash.delete superclass - - upgrade_to_class mod, RDoc::NormalClass, mod.parent if mod - - # e.g., Object < Object - superclass = nil if superclass == full_name - end - - klass = @store.classes_hash[full_name] - - if klass then - # if TopLevel, it may not be registered in the classes: - enclosing.classes_hash[name] = klass - - # update the superclass if needed - if superclass then - existing = klass.superclass - existing = existing.full_name unless existing.is_a?(String) if existing - if existing.nil? || - (existing == 'Object' && superclass != 'Object') then - klass.superclass = superclass - end - end - else - # this is a new class - mod = @store.modules_hash.delete full_name - - if mod then - klass = upgrade_to_class mod, RDoc::NormalClass, enclosing - - klass.superclass = superclass unless superclass.nil? - else - klass = class_type.new name, superclass - - enclosing.add_class_or_module(klass, enclosing.classes_hash, - @store.classes_hash) - end - end - - klass.parent = self - - klass - end - - ## - # Adds the class or module +mod+ to the modules or - # classes Hash +self_hash+, and to +all_hash+ (either - # TopLevel::modules_hash or TopLevel::classes_hash), - # unless #done_documenting is +true+. Sets the #parent of +mod+ - # to +self+, and its #section to #current_section. Returns +mod+. - - def add_class_or_module mod, self_hash, all_hash - mod.section = current_section # TODO declaring context? something is - # wrong here... - mod.parent = self - mod.full_name = nil - mod.store = @store - - unless @done_documenting then - self_hash[mod.name] = mod - # this must be done AFTER adding mod to its parent, so that the full - # name is correct: - all_hash[mod.full_name] = mod - if @store.unmatched_constant_alias[mod.full_name] then - to, file = @store.unmatched_constant_alias[mod.full_name] - add_module_alias mod, mod.name, to, file - end - end - - mod - end - - ## - # Adds +constant+ if not already there. If it is, updates the comment, - # value and/or is_alias_for of the known constant if they were empty/nil. - - def add_constant constant - return constant unless @document_self - - # HACK: avoid duplicate 'PI' & 'E' in math.c (1.8.7 source code) - # (this is a #ifdef: should be handled by the C parser) - known = @constants_hash[constant.name] - - if known then - known.comment = constant.comment if known.comment.empty? - - known.value = constant.value if - known.value.nil? or known.value.strip.empty? - - known.is_alias_for ||= constant.is_alias_for - else - @constants_hash[constant.name] = constant - add_to @constants, constant - end - - constant - end - - ## - # Adds included module +include+ which should be an RDoc::Include - - def add_include include - add_to @includes, include - - include - end - - ## - # Adds extension module +ext+ which should be an RDoc::Extend - - def add_extend ext - add_to @extends, ext - - ext - end - - ## - # Adds +method+ if not already there. If it is (as method or attribute), - # updates the comment if it was empty. - - def add_method method - return method unless @document_self - - # HACK: avoid duplicate 'new' in io.c & struct.c (1.8.7 source code) - key = method.pretty_name - known = @methods_hash[key] - - if known then - if @store then # otherwise we are loading - known.comment = method.comment if known.comment.empty? - previously = ", previously in #{known.file}" unless - method.file == known.file - @store.rdoc.options.warn \ - "Duplicate method #{known.full_name} in #{method.file}#{previously}" - end - else - @methods_hash[key] = method - if @current_line_visibility - method.visibility, @current_line_visibility = @current_line_visibility, nil - else - method.visibility = @visibility - end - add_to @method_list, method - resolve_aliases method - end - - method - end - - ## - # Adds a module named +name+. If RDoc already knows +name+ is a class then - # that class is returned instead. See also #add_class. - - def add_module(class_type, name) - mod = @classes[name] || @modules[name] - return mod if mod - - full_name = child_name name - mod = @store.modules_hash[full_name] || class_type.new(name) - - add_class_or_module mod, @modules, @store.modules_hash - end - - ## - # Adds a module by +RDoc::NormalModule+ instance. See also #add_module. - - def add_module_by_normal_module(mod) - add_class_or_module mod, @modules, @store.modules_hash - end - - ## - # Adds an alias from +from+ (a class or module) to +name+ which was defined - # in +file+. - - def add_module_alias from, from_name, to, file - return from if @done_documenting - - to_full_name = child_name to.name - - # if we already know this name, don't register an alias: - # see the metaprogramming in lib/active_support/basic_object.rb, - # where we already know BasicObject is a class when we find - # BasicObject = BlankSlate - return from if @store.find_class_or_module to_full_name - - unless from - @store.unmatched_constant_alias[child_name(from_name)] = [to, file] - return to - end - - new_to = from.dup - new_to.name = to.name - new_to.full_name = nil - - if new_to.module? then - @store.modules_hash[to_full_name] = new_to - @modules[to.name] = new_to - else - @store.classes_hash[to_full_name] = new_to - @classes[to.name] = new_to - end - - # Registers a constant for this alias. The constant value and comment - # will be updated later, when the Ruby parser adds the constant - const = RDoc::Constant.new to.name, nil, new_to.comment - const.record_location file - const.is_alias_for = from - add_constant const - - new_to - end - - ## - # Adds +require+ to this context's top level - - def add_require(require) - return require unless @document_self - - if RDoc::TopLevel === self then - add_to @requires, require - else - parent.add_require require - end - end - - ## - # Returns a section with +title+, creating it if it doesn't already exist. - # +comment+ will be appended to the section's comment. - # - # A section with a +title+ of +nil+ will return the default section. - # - # See also RDoc::Context::Section - - def add_section title, comment = nil - if section = @sections[title] then - section.add_comment comment if comment - else - section = Section.new self, title, comment - @sections[title] = section - end - - section - end - - ## - # Adds +thing+ to the collection +array+ - - def add_to array, thing - array << thing if @document_self - - thing.parent = self - thing.store = @store if @store - thing.section = current_section - end - - ## - # Is there any content? - # - # This means any of: comment, aliases, methods, attributes, external - # aliases, require, constant. - # - # Includes and extends are also checked unless includes == false. - - def any_content(includes = true) - @any_content ||= !( - @comment.empty? && - @method_list.empty? && - @attributes.empty? && - @aliases.empty? && - @external_aliases.empty? && - @requires.empty? && - @constants.empty? - ) - @any_content || (includes && !(@includes + @extends).empty? ) - end - - ## - # Creates the full name for a child with +name+ - - def child_name name - if name =~ /^:+/ - $' #' - elsif RDoc::TopLevel === self then - name - else - "#{self.full_name}::#{name}" - end - end - - ## - # Class attributes - - def class_attributes - @class_attributes ||= attributes.select { |a| a.singleton } - end - - ## - # Class methods - - def class_method_list - @class_method_list ||= method_list.select { |a| a.singleton } - end - - ## - # Array of classes in this context - - def classes - @classes.values - end - - ## - # All classes and modules in this namespace - - def classes_and_modules - classes + modules - end - - ## - # Hash of classes keyed by class name - - def classes_hash - @classes - end - - ## - # The current documentation section that new items will be added to. If - # temporary_section is available it will be used. - - def current_section - if section = @temporary_section then - @temporary_section = nil - else - section = @current_section - end - - section - end - - ## - # Is part of this thing was defined in +file+? - - def defined_in?(file) - @in_files.include?(file) - end - - def display(method_attr) # :nodoc: - if method_attr.is_a? RDoc::Attr - "#{method_attr.definition} #{method_attr.pretty_name}" - else - "method #{method_attr.pretty_name}" - end - end - - ## - # Iterator for ancestors for duck-typing. Does nothing. See - # RDoc::ClassModule#each_ancestor. - # - # This method exists to make it easy to work with Context subclasses that - # aren't part of RDoc. - - def each_ancestor(&_) # :nodoc: - end - - ## - # Iterator for attributes - - def each_attribute # :yields: attribute - @attributes.each { |a| yield a } - end - - ## - # Iterator for classes and modules - - def each_classmodule(&block) # :yields: module - classes_and_modules.sort.each(&block) - end - - ## - # Iterator for constants - - def each_constant # :yields: constant - @constants.each {|c| yield c} - end - - ## - # Iterator for included modules - - def each_include # :yields: include - @includes.each do |i| yield i end - end - - ## - # Iterator for extension modules - - def each_extend # :yields: extend - @extends.each do |e| yield e end - end - - ## - # Iterator for methods - - def each_method # :yields: method - return enum_for __method__ unless block_given? - - @method_list.sort.each { |m| yield m } - end - - ## - # Iterator for each section's contents sorted by title. The +section+, the - # section's +constants+ and the sections +attributes+ are yielded. The - # +constants+ and +attributes+ collections are sorted. - # - # To retrieve methods in a section use #methods_by_type with the optional - # +section+ parameter. - # - # NOTE: Do not edit collections yielded by this method - - def each_section # :yields: section, constants, attributes - return enum_for __method__ unless block_given? - - constants = @constants.group_by do |constant| constant.section end - attributes = @attributes.group_by do |attribute| attribute.section end - - constants.default = [] - attributes.default = [] - - sort_sections.each do |section| - yield section, constants[section].select(&:display?).sort, attributes[section].select(&:display?).sort - end - end - - ## - # Finds an attribute +name+ with singleton value +singleton+. - - def find_attribute(name, singleton) - name = $1 if name =~ /^(.*)=$/ - @attributes.find { |a| a.name == name && a.singleton == singleton } - end - - ## - # Finds an attribute with +name+ in this context - - def find_attribute_named(name) - case name - when /\A#/ then - find_attribute name[1..-1], false - when /\A::/ then - find_attribute name[2..-1], true - else - @attributes.find { |a| a.name == name } - end - end - - ## - # Finds a class method with +name+ in this context - - def find_class_method_named(name) - @method_list.find { |meth| meth.singleton && meth.name == name } - end - - ## - # Finds a constant with +name+ in this context - - def find_constant_named(name) - @constants.find do |m| - m.name == name || m.full_name == name - end - end - - ## - # Find a module at a higher scope - - def find_enclosing_module_named(name) - parent && parent.find_module_named(name) - end - - ## - # Finds an external alias +name+ with singleton value +singleton+. - - def find_external_alias(name, singleton) - @external_aliases.find { |m| m.name == name && m.singleton == singleton } - end - - ## - # Finds an external alias with +name+ in this context - - def find_external_alias_named(name) - case name - when /\A#/ then - find_external_alias name[1..-1], false - when /\A::/ then - find_external_alias name[2..-1], true - else - @external_aliases.find { |a| a.name == name } - end - end - - ## - # Finds a file with +name+ in this context - - def find_file_named name - @store.find_file_named name - end - - ## - # Finds an instance method with +name+ in this context - - def find_instance_method_named(name) - @method_list.find { |meth| !meth.singleton && meth.name == name } - end - - ## - # Finds a method, constant, attribute, external alias, module or file - # named +symbol+ in this context. - - def find_local_symbol(symbol) - find_method_named(symbol) or - find_constant_named(symbol) or - find_attribute_named(symbol) or - find_external_alias_named(symbol) or - find_module_named(symbol) or - find_file_named(symbol) - end - - ## - # Finds a method named +name+ with singleton value +singleton+. - - def find_method(name, singleton) - @method_list.find { |m| - if m.singleton - m.name == name && m.singleton == singleton - else - m.name == name && !m.singleton && !singleton - end - } - end - - ## - # Finds a instance or module method with +name+ in this context - - def find_method_named(name) - case name - when /\A#/ then - find_method name[1..-1], false - when /\A::/ then - find_method name[2..-1], true - else - @method_list.find { |meth| meth.name == name } - end - end - - ## - # Find a module with +name+ using ruby's scoping rules - - def find_module_named(name) - res = @modules[name] || @classes[name] - return res if res - return self if self.name == name - find_enclosing_module_named name - end - - ## - # Look up +symbol+, first as a module, then as a local symbol. - - def find_symbol(symbol) - find_symbol_module(symbol) || find_local_symbol(symbol) - end - - ## - # Look up a module named +symbol+. - - def find_symbol_module(symbol) - result = nil - - # look for a class or module 'symbol' - case symbol - when /^::/ then - result = @store.find_class_or_module symbol - when /^(\w+):+(.+)$/ - suffix = $2 - top = $1 - searched = self - while searched do - mod = searched.find_module_named(top) - break unless mod - result = @store.find_class_or_module "#{mod.full_name}::#{suffix}" - break if result || searched.is_a?(RDoc::TopLevel) - searched = searched.parent - end - else - searched = self - while searched do - result = searched.find_module_named(symbol) - break if result || searched.is_a?(RDoc::TopLevel) - searched = searched.parent - end - end - - result - end - - ## - # The full name for this context. This method is overridden by subclasses. - - def full_name - '(unknown)' - end - - ## - # Does this context and its methods and constants all have documentation? - # - # (Yes, fully documented doesn't mean everything.) - - def fully_documented? - documented? and - attributes.all? { |a| a.documented? } and - method_list.all? { |m| m.documented? } and - constants.all? { |c| c.documented? } - end - - ## - # URL for this with a +prefix+ - - def http_url(prefix) - path = name_for_path - path = path.gsub(/<<\s*(\w*)/, 'from-\1') if path =~ /<'class' or - # 'instance') and visibility (+:public+, +:protected+, +:private+). - # - # If +section+ is provided only methods in that RDoc::Context::Section will - # be returned. - - def methods_by_type section = nil - methods = {} - - TYPES.each do |type| - visibilities = {} - RDoc::VISIBILITIES.each do |vis| - visibilities[vis] = [] - end - - methods[type] = visibilities - end - - each_method do |method| - next if section and not method.section == section - methods[method.type][method.visibility] << method - end - - methods - end - - ## - # Yields AnyMethod and Attr entries matching the list of names in +methods+. - - def methods_matching(methods, singleton = false, &block) - (@method_list + @attributes).each do |m| - yield m if methods.include?(m.name) and m.singleton == singleton - end - - each_ancestor do |parent| - parent.methods_matching(methods, singleton, &block) - end - end - - ## - # Array of modules in this context - - def modules - @modules.values - end - - ## - # Hash of modules keyed by module name - - def modules_hash - @modules - end - - ## - # Name to use to generate the url. - # #full_name by default. - - def name_for_path - full_name - end - - ## - # Changes the visibility for new methods to +visibility+ - - def ongoing_visibility=(visibility) - @visibility = visibility - end - - ## - # Record +top_level+ as a file +self+ is in. - - def record_location(top_level) - @in_files << top_level unless @in_files.include?(top_level) - end - - ## - # Should we remove this context from the documentation? - # - # The answer is yes if: - # * #received_nodoc is +true+ - # * #any_content is +false+ (not counting includes) - # * All #includes are modules (not a string), and their module has - # #remove_from_documentation? == true - # * All classes and modules have #remove_from_documentation? == true - - def remove_from_documentation? - @remove_from_documentation ||= - @received_nodoc && - !any_content(false) && - @includes.all? { |i| !i.module.is_a?(String) && i.module.remove_from_documentation? } && - classes_and_modules.all? { |cm| cm.remove_from_documentation? } - end - - ## - # Removes methods and attributes with a visibility less than +min_visibility+. - #-- - # TODO mark the visibility of attributes in the template (if not public?) - - def remove_invisible min_visibility - return if [:private, :nodoc].include? min_visibility - remove_invisible_in @method_list, min_visibility - remove_invisible_in @attributes, min_visibility - remove_invisible_in @constants, min_visibility - end - - ## - # Only called when min_visibility == :public or :private - - def remove_invisible_in array, min_visibility # :nodoc: - if min_visibility == :public then - array.reject! { |e| - e.visibility != :public and not e.force_documentation - } - else - array.reject! { |e| - e.visibility == :private and not e.force_documentation - } - end - end - - ## - # Tries to resolve unmatched aliases when a method or attribute has just - # been added. - - def resolve_aliases added - # resolve any pending unmatched aliases - key = added.pretty_name - unmatched_alias_list = @unmatched_alias_lists[key] - return unless unmatched_alias_list - unmatched_alias_list.each do |unmatched_alias| - added.add_alias unmatched_alias, self - @external_aliases.delete unmatched_alias - end - @unmatched_alias_lists.delete key - end - - ## - # Returns RDoc::Context::Section objects referenced in this context for use - # in a table of contents. - - def section_contents - used_sections = {} - - each_method do |method| - next unless method.display? - - used_sections[method.section] = true - end - - # order found sections - sections = sort_sections.select do |section| - used_sections[section] - end - - # only the default section is used - return [] if - sections.length == 1 and not sections.first.title - - sections - end - - ## - # Sections in this context - - def sections - @sections.values - end - - def sections_hash # :nodoc: - @sections - end - - ## - # Sets the current section to a section with +title+. See also #add_section - - def set_current_section title, comment - @current_section = add_section title, comment - end - - ## - # Given an array +methods+ of method names, set the visibility of each to - # +visibility+ - - def set_visibility_for(methods, visibility, singleton = false) - methods_matching methods, singleton do |m| - m.visibility = visibility - end - end - - ## - # Given an array +names+ of constants, set the visibility of each constant to - # +visibility+ - - def set_constant_visibility_for(names, visibility) - names.each do |name| - constant = @constants_hash[name] or next - constant.visibility = visibility - end - end - - ## - # Sorts sections alphabetically (default) or in TomDoc fashion (none, - # Public, Internal, Deprecated) - - def sort_sections - titles = @sections.map { |title, _| title } - - if titles.length > 1 and - TOMDOC_TITLES_SORT == - (titles | TOMDOC_TITLES).sort_by { |title| title.to_s } then - @sections.values_at(*TOMDOC_TITLES).compact - else - @sections.sort_by { |title, _| - title.to_s - }.map { |_, section| - section - } - end - end - - def to_s # :nodoc: - "#{self.class.name} #{self.full_name}" - end - - ## - # Return the TopLevel that owns us - #-- - # FIXME we can be 'owned' by several TopLevel (see #record_location & - # #in_files) - - def top_level - return @top_level if defined? @top_level - @top_level = self - @top_level = @top_level.parent until RDoc::TopLevel === @top_level - @top_level - end - - ## - # Upgrades NormalModule +mod+ in +enclosing+ to a +class_type+ - - def upgrade_to_class mod, class_type, enclosing - enclosing.modules_hash.delete mod.name - - klass = RDoc::ClassModule.from_module class_type, mod - klass.store = @store - - # if it was there, then we keep it even if done_documenting - @store.classes_hash[mod.full_name] = klass - enclosing.classes_hash[mod.name] = klass - - klass - end - - autoload :Section, "#{__dir__}/context/section" - -end diff --git a/lib/rdoc/code_object/context/section.rb b/lib/rdoc/code_object/context/section.rb deleted file mode 100644 index aecd4e0213..0000000000 --- a/lib/rdoc/code_object/context/section.rb +++ /dev/null @@ -1,233 +0,0 @@ -# frozen_string_literal: true -require 'cgi/util' - -## -# A section of documentation like: -# -# # :section: The title -# # The body -# -# Sections can be referenced multiple times and will be collapsed into a -# single section. - -class RDoc::Context::Section - - include RDoc::Text - - MARSHAL_VERSION = 0 # :nodoc: - - ## - # Section comment - - attr_reader :comment - - ## - # Section comments - - attr_reader :comments - - ## - # Context this Section lives in - - attr_reader :parent - - ## - # Section title - - attr_reader :title - - ## - # Creates a new section with +title+ and +comment+ - - def initialize parent, title, comment - @parent = parent - @title = title ? title.strip : title - - @comments = [] - - add_comment comment - end - - ## - # Sections are equal when they have the same #title - - def == other - self.class === other and @title == other.title - end - - alias eql? == - - ## - # Adds +comment+ to this section - - def add_comment comment - comment = extract_comment comment - - return if comment.empty? - - case comment - when RDoc::Comment then - @comments << comment - when RDoc::Markup::Document then - @comments.concat comment.parts - when Array then - @comments.concat comment - else - raise TypeError, "unknown comment type: #{comment.inspect}" - end - end - - ## - # Anchor reference for linking to this section - - def aref - title = @title || '[untitled]' - - CGI.escape(title).gsub('%', '-').sub(/^-/, '') - end - - ## - # Extracts the comment for this section from the original comment block. - # If the first line contains :section:, strip it and use the rest. - # Otherwise remove lines up to the line containing :section:, and look - # for those lines again at the end and remove them. This lets us write - # - # # :section: The title - # # The body - - def extract_comment comment - case comment - when Array then - comment.map do |c| - extract_comment c - end - when nil - RDoc::Comment.new '' - when RDoc::Comment then - if comment.text =~ /^#[ \t]*:section:.*\n/ then - start = $` - rest = $' - - comment.text = if start.empty? then - rest - else - rest.sub(/#{start.chomp}\Z/, '') - end - end - - comment - when RDoc::Markup::Document then - comment - else - raise TypeError, "unknown comment #{comment.inspect}" - end - end - - def inspect # :nodoc: - "#<%s:0x%x %p>" % [self.class, object_id, title] - end - - def hash # :nodoc: - @title.hash - end - - ## - # The files comments in this section come from - - def in_files - return [] if @comments.empty? - - case @comments - when Array then - @comments.map do |comment| - comment.file - end - when RDoc::Markup::Document then - @comment.parts.map do |document| - document.file - end - else - raise RDoc::Error, "BUG: unknown comment class #{@comments.class}" - end - end - - ## - # Serializes this Section. The title and parsed comment are saved, but not - # the section parent which must be restored manually. - - def marshal_dump - [ - MARSHAL_VERSION, - @title, - parse, - ] - end - - ## - # De-serializes this Section. The section parent must be restored manually. - - def marshal_load array - @parent = nil - - @title = array[1] - @comments = array[2] - end - - ## - # Parses +comment_location+ into an RDoc::Markup::Document composed of - # multiple RDoc::Markup::Documents with their file set. - - def parse - case @comments - when String then - super - when Array then - docs = @comments.map do |comment, location| - doc = super comment - doc.file = location if location - doc - end - - RDoc::Markup::Document.new(*docs) - when RDoc::Comment then - doc = super @comments.text, comments.format - doc.file = @comments.location - doc - when RDoc::Markup::Document then - return @comments - else - raise ArgumentError, "unknown comment class #{comments.class}" - end - end - - ## - # The section's title, or 'Top Section' if the title is nil. - # - # This is used by the table of contents template so the name is silly. - - def plain_html - @title || 'Top Section' - end - - ## - # Removes a comment from this section if it is from the same file as - # +comment+ - - def remove_comment comment - return if @comments.empty? - - case @comments - when Array then - @comments.delete_if do |my_comment| - my_comment.file == comment.file - end - when RDoc::Markup::Document then - @comments.parts.delete_if do |document| - document.file == comment.file.name - end - else - raise RDoc::Error, "BUG: unknown comment class #{@comments.class}" - end - end - -end diff --git a/lib/rdoc/code_object/extend.rb b/lib/rdoc/code_object/extend.rb deleted file mode 100644 index 7d57433de6..0000000000 --- a/lib/rdoc/code_object/extend.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true -## -# A Module extension to a class with \#extend -# -# RDoc::Extend.new 'Enumerable', 'comment ...' - -class RDoc::Extend < RDoc::Mixin - -end diff --git a/lib/rdoc/code_object/ghost_method.rb b/lib/rdoc/code_object/ghost_method.rb deleted file mode 100644 index 25f951e35e..0000000000 --- a/lib/rdoc/code_object/ghost_method.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true -## -# GhostMethod represents a method referenced only by a comment - -class RDoc::GhostMethod < RDoc::AnyMethod -end diff --git a/lib/rdoc/code_object/include.rb b/lib/rdoc/code_object/include.rb deleted file mode 100644 index c3e0d45e47..0000000000 --- a/lib/rdoc/code_object/include.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true -## -# A Module included in a class with \#include -# -# RDoc::Include.new 'Enumerable', 'comment ...' - -class RDoc::Include < RDoc::Mixin - -end diff --git a/lib/rdoc/code_object/meta_method.rb b/lib/rdoc/code_object/meta_method.rb deleted file mode 100644 index 8c95a0f78c..0000000000 --- a/lib/rdoc/code_object/meta_method.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true -## -# MetaMethod represents a meta-programmed method - -class RDoc::MetaMethod < RDoc::AnyMethod -end diff --git a/lib/rdoc/code_object/method_attr.rb b/lib/rdoc/code_object/method_attr.rb deleted file mode 100644 index 263780f7c7..0000000000 --- a/lib/rdoc/code_object/method_attr.rb +++ /dev/null @@ -1,430 +0,0 @@ -# frozen_string_literal: true -## -# Abstract class representing either a method or an attribute. - -class RDoc::MethodAttr < RDoc::CodeObject - - include Comparable - - ## - # Name of this method/attribute. - - attr_accessor :name - - ## - # public, protected, private - - attr_accessor :visibility - - ## - # Is this a singleton method/attribute? - - attr_accessor :singleton - - ## - # Source file token stream - - attr_reader :text - - ## - # Array of other names for this method/attribute - - attr_reader :aliases - - ## - # The method/attribute we're aliasing - - attr_accessor :is_alias_for - - #-- - # The attributes below are for AnyMethod only. - # They are left here for the time being to - # allow ri to operate. - # TODO modify ri to avoid calling these on attributes. - #++ - - ## - # Parameters yielded by the called block - - attr_reader :block_params - - ## - # Parameters for this method - - attr_accessor :params - - ## - # Different ways to call this method - - attr_accessor :call_seq - - ## - # The call_seq or the param_seq with method name, if there is no call_seq. - - attr_reader :arglists - - ## - # Pretty parameter list for this method - - attr_reader :param_seq - - - ## - # Creates a new MethodAttr from token stream +text+ and method or attribute - # name +name+. - # - # Usually this is called by super from a subclass. - - def initialize text, name - super() - - @text = text - @name = name - - @aliases = [] - @is_alias_for = nil - @parent_name = nil - @singleton = nil - @visibility = :public - @see = false - - @arglists = nil - @block_params = nil - @call_seq = nil - @param_seq = nil - @params = nil - end - - ## - # Resets cached data for the object so it can be rebuilt by accessor methods - - def initialize_copy other # :nodoc: - @full_name = nil - end - - def initialize_visibility # :nodoc: - super - @see = nil - end - - ## - # Order by #singleton then #name - - def <=>(other) - return unless other.respond_to?(:singleton) && - other.respond_to?(:name) - - [@singleton ? 0 : 1, name_ord_range, name] <=> - [other.singleton ? 0 : 1, other.name_ord_range, other.name] - end - - def == other # :nodoc: - equal?(other) or self.class == other.class and full_name == other.full_name - end - - ## - # A method/attribute is documented if any of the following is true: - # - it was marked with :nodoc:; - # - it has a comment; - # - it is an alias for a documented method; - # - it has a +#see+ method that is documented. - - def documented? - super or - (is_alias_for and is_alias_for.documented?) or - (see and see.documented?) - end - - ## - # A method/attribute to look at, - # in particular if this method/attribute has no documentation. - # - # It can be a method/attribute of the superclass or of an included module, - # including the Kernel module, which is always appended to the included - # modules. - # - # Returns +nil+ if there is no such method/attribute. - # The +#is_alias_for+ method/attribute, if any, is not included. - # - # Templates may generate a "see also ..." if this method/attribute - # has documentation, and "see ..." if it does not. - - def see - @see = find_see if @see == false - @see - end - - ## - # Sets the store for this class or module and its contained code objects. - - def store= store - super - - @file = @store.add_file @file.full_name if @file - end - - def find_see # :nodoc: - return nil if singleton || is_alias_for - - # look for the method - other = find_method_or_attribute name - return other if other - - # if it is a setter, look for a getter - return nil unless name =~ /[a-z_]=$/i # avoid == or === - return find_method_or_attribute name[0..-2] - end - - def find_method_or_attribute name # :nodoc: - return nil unless parent.respond_to? :ancestors - - searched = parent.ancestors - kernel = @store.modules_hash['Kernel'] - - searched << kernel if kernel && - parent != kernel && !searched.include?(kernel) - - searched.each do |ancestor| - next if String === ancestor - next if parent == ancestor - - other = ancestor.find_method_named('#' + name) || - ancestor.find_attribute_named(name) - - return other if other - end - - nil - end - - ## - # Abstract method. Contexts in their building phase call this - # to register a new alias for this known method/attribute. - # - # - creates a new AnyMethod/Attribute named an_alias.new_name; - # - adds +self+ as an alias for the new method or attribute - # - adds the method or attribute to #aliases - # - adds the method or attribute to +context+. - - def add_alias(an_alias, context) - raise NotImplementedError - end - - ## - # HTML fragment reference for this method - - def aref - type = singleton ? 'c' : 'i' - # % characters are not allowed in html names => dash instead - "#{aref_prefix}-#{type}-#{html_name}" - end - - ## - # Prefix for +aref+, defined by subclasses. - - def aref_prefix - raise NotImplementedError - end - - ## - # Attempts to sanitize the content passed by the Ruby parser: - # remove outer parentheses, etc. - - def block_params=(value) - # 'yield.to_s' or 'assert yield, msg' - return @block_params = '' if value =~ /^[\.,]/ - - # remove trailing 'if/unless ...' - return @block_params = '' if value =~ /^(if|unless)\s/ - - value = $1.strip if value =~ /^(.+)\s(if|unless)\s/ - - # outer parentheses - value = $1 if value =~ /^\s*\((.*)\)\s*$/ - value = value.strip - - # proc/lambda - return @block_params = $1 if value =~ /^(proc|lambda)(\s*\{|\sdo)/ - - # surrounding +...+ or [...] - value = $1.strip if value =~ /^\+(.*)\+$/ - value = $1.strip if value =~ /^\[(.*)\]$/ - - return @block_params = '' if value.empty? - - # global variable - return @block_params = 'str' if value =~ /^\$[&0-9]$/ - - # wipe out array/hash indices - value.gsub!(/(\w)\[[^\[]+\]/, '\1') - - # remove @ from class/instance variables - value.gsub!(/@@?([a-z0-9_]+)/, '\1') - - # method calls => method name - value.gsub!(/([A-Z:a-z0-9_]+)\.([a-z0-9_]+)(\s*\(\s*[a-z0-9_.,\s]*\s*\)\s*)?/) do - case $2 - when 'to_s' then $1 - when 'const_get' then 'const' - when 'new' then - $1.split('::').last. # ClassName => class_name - gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). - gsub(/([a-z\d])([A-Z])/, '\1_\2'). - downcase - else - $2 - end - end - - # class prefixes - value.gsub!(/[A-Za-z0-9_:]+::/, '') - - # simple expressions - value = $1 if value =~ /^([a-z0-9_]+)\s*[-*+\/]/ - - @block_params = value.strip - end - - ## - # HTML id-friendly method/attribute name - - def html_name - require 'cgi/util' - - CGI.escape(@name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '') - end - - ## - # Full method/attribute name including namespace - - def full_name - @full_name ||= "#{parent_name}#{pretty_name}" - end - - def inspect # :nodoc: - alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil - visibility = self.visibility - visibility = "forced #{visibility}" if force_documentation - "#<%s:0x%x %s (%s)%s>" % [ - self.class, object_id, - full_name, - visibility, - alias_for, - ] - end - - ## - # '::' for a class method/attribute, '#' for an instance method. - - def name_prefix - @singleton ? '::' : '#' - end - - ## - # Name for output to HTML. For class methods the full name with a "." is - # used like +SomeClass.method_name+. For instance methods the class name is - # used if +context+ does not match the parent. - # - # This is to help prevent people from using :: to call class methods. - - def output_name context - return "#{name_prefix}#{@name}" if context == parent - - "#{parent_name}#{@singleton ? '.' : '#'}#{@name}" - end - - ## - # Method/attribute name with class/instance indicator - - def pretty_name - "#{name_prefix}#{@name}" - end - - ## - # Type of method/attribute (class or instance) - - def type - singleton ? 'class' : 'instance' - end - - ## - # Path to this method for use with HTML generator output. - - def path - "#{@parent.path}##{aref}" - end - - ## - # Name of our parent with special handling for un-marshaled methods - - def parent_name - @parent_name || super - end - - def pretty_print q # :nodoc: - alias_for = - if @is_alias_for.respond_to? :name then - "alias for #{@is_alias_for.name}" - elsif Array === @is_alias_for then - "alias for #{@is_alias_for.last}" - end - - q.group 2, "[#{self.class.name} #{full_name} #{visibility}", "]" do - if alias_for then - q.breakable - q.text alias_for - end - - if text then - q.breakable - q.text "text:" - q.breakable - q.pp @text - end - - unless comment.empty? then - q.breakable - q.text "comment:" - q.breakable - q.pp @comment - end - end - end - - ## - # Used by RDoc::Generator::JsonIndex to create a record for the search - # engine. - - def search_record - [ - @name, - full_name, - @name, - @parent.full_name, - path, - params, - snippet(@comment), - ] - end - - def to_s # :nodoc: - if @is_alias_for - "#{self.class.name}: #{full_name} -> #{is_alias_for}" - else - "#{self.class.name}: #{full_name}" - end - end - - def name_ord_range # :nodoc: - case name.ord - when 0..64 # anything below "A" - 1 - when 91..96 # the symbols between "Z" and "a" - 2 - when 123..126 # 7-bit symbols above "z": "{", "|", "}", "~" - 3 - else # everythig else can be sorted as normal - 4 - end - end -end diff --git a/lib/rdoc/code_object/mixin.rb b/lib/rdoc/code_object/mixin.rb deleted file mode 100644 index fa8faefc15..0000000000 --- a/lib/rdoc/code_object/mixin.rb +++ /dev/null @@ -1,120 +0,0 @@ -# frozen_string_literal: true -## -# A Mixin adds features from a module into another context. RDoc::Include and -# RDoc::Extend are both mixins. - -class RDoc::Mixin < RDoc::CodeObject - - ## - # Name of included module - - attr_accessor :name - - ## - # Creates a new Mixin for +name+ with +comment+ - - def initialize(name, comment) - super() - @name = name - self.comment = comment - @module = nil # cache for module if found - end - - ## - # Mixins are sorted by name - - def <=> other - return unless self.class === other - - name <=> other.name - end - - def == other # :nodoc: - self.class === other and @name == other.name - end - - alias eql? == # :nodoc: - - ## - # Full name based on #module - - def full_name - m = self.module - RDoc::ClassModule === m ? m.full_name : @name - end - - def hash # :nodoc: - [@name, self.module].hash - end - - def inspect # :nodoc: - "#<%s:0x%x %s.%s %s>" % [ - self.class, - object_id, - parent_name, self.class.name.downcase, @name, - ] - end - - ## - # Attempts to locate the included module object. Returns the name if not - # known. - # - # The scoping rules of Ruby to resolve the name of an included module are: - # - first look into the children of the current context; - # - if not found, look into the children of included modules, - # in reverse inclusion order; - # - if still not found, go up the hierarchy of names. - # - # This method has O(n!) behavior when the module calling - # include is referencing nonexistent modules. Avoid calling #module until - # after all the files are parsed. This behavior is due to ruby's constant - # lookup behavior. - # - # As of the beginning of October, 2011, no gem includes nonexistent modules. - - def module - return @module if @module - - # search the current context - return @name unless parent - full_name = parent.child_name(@name) - @module = @store.modules_hash[full_name] - return @module if @module - return @name if @name =~ /^::/ - - # search the includes before this one, in reverse order - searched = parent.includes.take_while { |i| i != self }.reverse - searched.each do |i| - inc = i.module - next if String === inc - full_name = inc.child_name(@name) - @module = @store.modules_hash[full_name] - return @module if @module - end - - # go up the hierarchy of names - up = parent.parent - while up - full_name = up.child_name(@name) - @module = @store.modules_hash[full_name] - return @module if @module - up = up.parent - end - - @name - end - - ## - # Sets the store for this class or module and its contained code objects. - - def store= store - super - - @file = @store.add_file @file.full_name if @file - end - - def to_s # :nodoc: - "#{self.class.name.downcase} #@name in: #{parent}" - end - -end diff --git a/lib/rdoc/code_object/normal_class.rb b/lib/rdoc/code_object/normal_class.rb deleted file mode 100644 index aa340b5d15..0000000000 --- a/lib/rdoc/code_object/normal_class.rb +++ /dev/null @@ -1,92 +0,0 @@ -# frozen_string_literal: true -## -# A normal class, neither singleton nor anonymous - -class RDoc::NormalClass < RDoc::ClassModule - - ## - # The ancestors of this class including modules. Unlike Module#ancestors, - # this class is not included in the result. The result will contain both - # RDoc::ClassModules and Strings. - - def ancestors - if String === superclass then - super << superclass - elsif superclass then - ancestors = super - ancestors << superclass - ancestors.concat superclass.ancestors - else - super - end - end - - def aref_prefix # :nodoc: - 'class' - end - - ## - # The definition of this class, class MyClassName - - def definition - "class #{full_name}" - end - - def direct_ancestors - superclass ? super + [superclass] : super - end - - def inspect # :nodoc: - superclass = @superclass ? " < #{@superclass}" : nil - "<%s:0x%x class %s%s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [ - self.class, object_id, - full_name, superclass, @includes, @extends, @attributes, @method_list, @aliases - ] - end - - def to_s # :nodoc: - display = "#{self.class.name} #{self.full_name}" - if superclass - display += ' < ' + (superclass.is_a?(String) ? superclass : superclass.full_name) - end - display += ' -> ' + is_alias_for.to_s if is_alias_for - display - end - - def pretty_print q # :nodoc: - superclass = @superclass ? " < #{@superclass}" : nil - - q.group 2, "[class #{full_name}#{superclass}", "]" do - q.breakable - q.text "includes:" - q.breakable - q.seplist @includes do |inc| q.pp inc end - - q.breakable - q.text "constants:" - q.breakable - q.seplist @constants do |const| q.pp const end - - q.breakable - q.text "attributes:" - q.breakable - q.seplist @attributes do |attr| q.pp attr end - - q.breakable - q.text "methods:" - q.breakable - q.seplist @method_list do |meth| q.pp meth end - - q.breakable - q.text "aliases:" - q.breakable - q.seplist @aliases do |aliaz| q.pp aliaz end - - q.breakable - q.text "comment:" - q.breakable - q.pp comment - end - end - -end diff --git a/lib/rdoc/code_object/normal_module.rb b/lib/rdoc/code_object/normal_module.rb deleted file mode 100644 index 498ec4dde2..0000000000 --- a/lib/rdoc/code_object/normal_module.rb +++ /dev/null @@ -1,73 +0,0 @@ -# frozen_string_literal: true -## -# A normal module, like NormalClass - -class RDoc::NormalModule < RDoc::ClassModule - - def aref_prefix # :nodoc: - 'module' - end - - def inspect # :nodoc: - "#<%s:0x%x module %s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [ - self.class, object_id, - full_name, @includes, @extends, @attributes, @method_list, @aliases - ] - end - - ## - # The definition of this module, module MyModuleName - - def definition - "module #{full_name}" - end - - ## - # This is a module, returns true - - def module? - true - end - - def pretty_print q # :nodoc: - q.group 2, "[module #{full_name}:", "]" do - q.breakable - q.text "includes:" - q.breakable - q.seplist @includes do |inc| q.pp inc end - q.breakable - - q.breakable - q.text "constants:" - q.breakable - q.seplist @constants do |const| q.pp const end - - q.text "attributes:" - q.breakable - q.seplist @attributes do |attr| q.pp attr end - q.breakable - - q.text "methods:" - q.breakable - q.seplist @method_list do |meth| q.pp meth end - q.breakable - - q.text "aliases:" - q.breakable - q.seplist @aliases do |aliaz| q.pp aliaz end - q.breakable - - q.text "comment:" - q.breakable - q.pp comment - end - end - - ## - # Modules don't have one, raises NoMethodError - - def superclass - raise NoMethodError, "#{full_name} is a module" - end - -end diff --git a/lib/rdoc/code_object/require.rb b/lib/rdoc/code_object/require.rb deleted file mode 100644 index 05e26b84b0..0000000000 --- a/lib/rdoc/code_object/require.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true -## -# A file loaded by \#require - -class RDoc::Require < RDoc::CodeObject - - ## - # Name of the required file - - attr_accessor :name - - ## - # Creates a new Require that loads +name+ with +comment+ - - def initialize(name, comment) - super() - @name = name.gsub(/'|"/, "") #' - @top_level = nil - self.comment = comment - end - - def inspect # :nodoc: - "#<%s:0x%x require '%s' in %s>" % [ - self.class, - object_id, - @name, - parent_file_name, - ] - end - - def to_s # :nodoc: - "require #{name} in: #{parent}" - end - - ## - # The RDoc::TopLevel corresponding to this require, or +nil+ if not found. - - def top_level - @top_level ||= begin - tl = RDoc::TopLevel.all_files_hash[name + '.rb'] - - if tl.nil? and RDoc::TopLevel.all_files.first.full_name =~ %r(^lib/) then - # second chance - tl = RDoc::TopLevel.all_files_hash['lib/' + name + '.rb'] - end - - tl - end - end - -end diff --git a/lib/rdoc/code_object/single_class.rb b/lib/rdoc/code_object/single_class.rb deleted file mode 100644 index dd16529648..0000000000 --- a/lib/rdoc/code_object/single_class.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true -## -# A singleton class - -class RDoc::SingleClass < RDoc::ClassModule - - ## - # Adds the superclass to the included modules. - - def ancestors - superclass ? super + [superclass] : super - end - - def aref_prefix # :nodoc: - 'sclass' - end - - ## - # The definition of this singleton class, class << MyClassName - - def definition - "class << #{full_name}" - end - - def pretty_print q # :nodoc: - q.group 2, "[class << #{full_name}", "]" do - next - end - end -end diff --git a/lib/rdoc/code_object/top_level.rb b/lib/rdoc/code_object/top_level.rb deleted file mode 100644 index b93e3802fc..0000000000 --- a/lib/rdoc/code_object/top_level.rb +++ /dev/null @@ -1,291 +0,0 @@ -# frozen_string_literal: true -## -# A TopLevel context is a representation of the contents of a single file - -class RDoc::TopLevel < RDoc::Context - - MARSHAL_VERSION = 0 # :nodoc: - - ## - # This TopLevel's File::Stat struct - - attr_accessor :file_stat - - ## - # Relative name of this file - - attr_accessor :relative_name - - ## - # Absolute name of this file - - attr_accessor :absolute_name - - ## - # 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. - - attr_reader :classes_or_modules - - attr_accessor :diagram # :nodoc: - - ## - # The parser class that processed this file - - attr_reader :parser - - ## - # 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 # HACK for testing - @diagram = nil - @parser = nil - - @classes_or_modules = [] - end - - ## - # Sets the parser for this toplevel context, also the store. - - def parser=(val) - @parser = val - @store.update_parser_of_file(absolute_name, val) if @store - @parser - end - - ## - # An RDoc::TopLevel is equal to another with the same relative_name - - def == other - self.class === other and @relative_name == other.relative_name - end - - alias eql? == - - ## - # 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 - - ## - # 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 - - ## - # 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 - - ## - # 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 - - ## - # 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 of this file - - def base_name - File.basename @relative_name - end - - alias name base_name - - ## - # Only a TopLevel that contains text file) will be displayed. See also - # RDoc::CodeObject#display? - - def display? - text? and super - end - - ## - # See RDoc::TopLevel::find_class_or_module - #-- - # TODO Why do we search through all classes/modules found, not just the - # ones of this instance? - - def find_class_or_module name - @store.find_class_or_module name - end - - ## - # Finds a class or module named +symbol+ - - def find_local_symbol(symbol) - find_class_or_module(symbol) || super - end - - ## - # Finds a module or class with +name+ - - def find_module_named(name) - find_class_or_module(name) - end - - ## - # Returns the relative name of this file - - def full_name - @relative_name - end - - ## - # An RDoc::TopLevel has the same hash as another with the same - # relative_name - - def hash - @relative_name.hash - end - - ## - # URL for this with a +prefix+ - - def http_url(prefix) - path = [prefix, @relative_name.tr('.', '_')] - - File.join(*path.compact) + '.html' - end - - 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 - - ## - # Time this file was last modified, if known - - def last_modified - @file_stat ? file_stat.mtime : nil - end - - ## - # Dumps this TopLevel for use by ri. See also #marshal_load - - def marshal_dump - [ - MARSHAL_VERSION, - @relative_name, - @parser, - parse(@comment), - ] - end - - ## - # Loads this TopLevel from +array+. - - def marshal_load array # :nodoc: - initialize array[1] - - @parser = array[2] - @comment = array[3] - - @file_stat = nil - end - - ## - # 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 - - ## - # Base name of this file without the extension - - 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. - - def path - http_url @store.rdoc.generator.file_dir - end - - def pretty_print q # :nodoc: - 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 - - ## - # Search record used by RDoc::Generator::JsonIndex - - 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? - - def text? - @parser and @parser.include? RDoc::Parser::Text - end - - def to_s # :nodoc: - "file #{full_name}" - end - -end diff --git a/lib/rdoc/code_objects.rb b/lib/rdoc/code_objects.rb deleted file mode 100644 index d5f2f920ad..0000000000 --- a/lib/rdoc/code_objects.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true -# This file was used to load all the RDoc::CodeObject subclasses at once. Now -# autoload handles this. - -require_relative '../rdoc' diff --git a/lib/rdoc/comment.rb b/lib/rdoc/comment.rb deleted file mode 100644 index 04ec226436..0000000000 --- a/lib/rdoc/comment.rb +++ /dev/null @@ -1,229 +0,0 @@ -# frozen_string_literal: true -## -# A comment holds the text comment for a RDoc::CodeObject and provides a -# unified way of cleaning it up and parsing it into an RDoc::Markup::Document. -# -# Each comment may have a different markup format set by #format=. By default -# 'rdoc' is used. The :markup: directive tells RDoc which format to use. -# -# See RDoc::MarkupReference@Directive+for+Specifying+RDoc+Source+Format. - - -class RDoc::Comment - - include RDoc::Text - - ## - # The format of this comment. Defaults to RDoc::Markup - - attr_reader :format - - ## - # The RDoc::TopLevel this comment was found in - - attr_accessor :location - - ## - # Line where this Comment was written - - attr_accessor :line - - ## - # For duck-typing when merging classes at load time - - alias file location # :nodoc: - - ## - # The text for this comment - - attr_reader :text - - ## - # Alias for text - - alias to_s text - - ## - # Overrides the content returned by #parse. Use when there is no #text - # source for this comment - - attr_writer :document - - ## - # Creates a new comment with +text+ that is found in the RDoc::TopLevel - # +location+. - - def initialize text = nil, location = nil, language = nil - @location = location - @text = text.nil? ? nil : text.dup - @language = language - - @document = nil - @format = 'rdoc' - @normalized = false - end - - ## - #-- - # TODO deep copy @document - - def initialize_copy copy # :nodoc: - @text = copy.text.dup - end - - def == other # :nodoc: - self.class === other and - other.text == @text and other.location == @location - end - - ## - # Look for a 'call-seq' in the comment to override the normal parameter - # handling. The :call-seq: is indented from the baseline. All lines of the - # same indentation level and prefix are consumed. - # - # For example, all of the following will be used as the :call-seq: - # - # # :call-seq: - # # ARGF.readlines(sep=$/) -> array - # # ARGF.readlines(limit) -> array - # # ARGF.readlines(sep, limit) -> array - # # - # # ARGF.to_a(sep=$/) -> array - # # ARGF.to_a(limit) -> array - # # ARGF.to_a(sep, limit) -> array - - def extract_call_seq method - # we must handle situations like the above followed by an unindented first - # comment. The difficulty is to make sure not to match lines starting - # with ARGF at the same indent, but that are after the first description - # paragraph. - if /^(? ((?!\n)\s)*+ (?# whitespaces except newline)) - :?call-seq: - (? \g(?\n|\z) (?# trailing spaces))? - (? - (\g(?!\w)\S.*\g)* - (?> - (? \g\w+ (?# ' # ARGF' in the example above)) - .*\g)? - (\g\S.*\g (?# other non-blank line))*+ - (\g+(\k.*\g (?# ARGF.to_a lines))++)*+ - ) - (?m:^\s*$|\z) - /x =~ @text - seq = $~[:seq] - - all_start, all_stop = $~.offset(0) - @text.slice! all_start...all_stop - - seq.gsub!(/^\s*/, '') - method.call_seq = seq - end - - method - end - - ## - # A comment is empty if its text String is empty. - - def empty? - @text.empty? - end - - ## - # HACK dubious - - def encode! encoding - @text = String.new @text, encoding: encoding - self - end - - ## - # Sets the format of this comment and resets any parsed document - - def format= format - @format = format - @document = nil - end - - def inspect # :nodoc: - location = @location ? @location.relative_name : '(unknown)' - - "#<%s:%x %s %p>" % [self.class, object_id, location, @text] - end - - ## - # Normalizes the text. See RDoc::Text#normalize_comment for details - - def normalize - return self unless @text - return self if @normalized # TODO eliminate duplicate normalization - - @text = normalize_comment @text - - @normalized = true - - self - end - - ## - # Was this text normalized? - - def normalized? # :nodoc: - @normalized - end - - ## - # Parses the comment into an RDoc::Markup::Document. The parsed document is - # cached until the text is changed. - - def parse - return @document if @document - - @document = super @text, @format - @document.file = @location - @document - end - - ## - # Removes private sections from this comment. Private sections are flush to - # the comment marker and start with -- and end with ++. - # For C-style comments, a private marker may not start at the opening of the - # comment. - # - # /* - # *-- - # * private - # *++ - # * public - # */ - - def remove_private - # Workaround for gsub encoding for Ruby 1.9.2 and earlier - empty = '' - empty = RDoc::Encoding.change_encoding empty, @text.encoding - - @text = @text.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty) - @text = @text.sub(%r%^\s*[#*]?--.*%m, '') - end - - ## - # Replaces this comment's text with +text+ and resets the parsed document. - # - # An error is raised if the comment contains a document but no text. - - def text= text - raise RDoc::Error, 'replacing document-only comment is not allowed' if - @text.nil? and @document - - @document = nil - @text = text.nil? ? nil : text.dup - end - - ## - # Returns true if this comment is in TomDoc format. - - def tomdoc? - @format == 'tomdoc' - end - -end diff --git a/lib/rdoc/cross_reference.rb b/lib/rdoc/cross_reference.rb deleted file mode 100644 index 4e011219e8..0000000000 --- a/lib/rdoc/cross_reference.rb +++ /dev/null @@ -1,228 +0,0 @@ -# frozen_string_literal: true - -require_relative 'markup/attribute_manager' # for PROTECT_ATTR - -## -# RDoc::CrossReference is a reusable way to create cross references for names. - -class RDoc::CrossReference - - ## - # Regular expression to match class references - # - # 1. There can be a '\\' in front of text to suppress the cross-reference - # 2. There can be a '::' in front of class names to reference from the - # top-level namespace. - # 3. The method can be followed by parenthesis (not recommended) - - CLASS_REGEXP_STR = '\\\\?((?:\:{2})?[A-Z]\w*(?:\:\:\w+)*)' - - ## - # Regular expression to match a single method argument. - - METHOD_ARG_REGEXP_STR = '[\w.+*/=<>-]+' - - ## - # Regular expression to match method arguments. - - METHOD_ARGS_REGEXP_STR = /(?:\((?:#{METHOD_ARG_REGEXP_STR}(?:,\s*#{METHOD_ARG_REGEXP_STR})*)?\))?/.source - - ## - # Regular expression to match method references. - # - # See CLASS_REGEXP_STR - - METHOD_REGEXP_STR = /( - (?!\d)[\w#{RDoc::Markup::AttributeManager::PROTECT_ATTR}]+[!?=]?| - %|=(?:==?|~)|![=~]|\[\]=?|<(?:<|=>?)?|>[>=]?|[-+!]@?|\*\*?|[\/%\`|&^~] - )#{METHOD_ARGS_REGEXP_STR}/.source.delete("\n ").freeze - - ## - # Regular expressions matching text that should potentially have - # cross-reference links generated are passed to add_regexp_handling. Note - # that these expressions are meant to pick up text for which cross-references - # have been suppressed, since the suppression characters are removed by the - # code that is triggered. - - CROSSREF_REGEXP = /(?:^|[\s()]) - ( - (?: - # A::B::C.meth - #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR} - - # A::B::C - # The stuff after CLASS_REGEXP_STR is a - # nasty hack. CLASS_REGEXP_STR unfortunately matches - # words like dog and cat (these are legal "class" - # names in Fortran 95). When a word is flagged as a - # potential cross-reference, limitations in the markup - # engine suppress other processing, such as typesetting. - # This is particularly noticeable for contractions. - # In order that words like "can't" not - # be flagged as potential cross-references, only - # flag potential class cross-references if the character - # after the cross-reference is a space, sentence - # punctuation, tag start character, or attribute - # marker. - | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z) - - # Stand-alone method (preceded by a #) - | \\?\##{METHOD_REGEXP_STR} - - # Stand-alone method (preceded by ::) - | ::#{METHOD_REGEXP_STR} - - # Things that look like filenames - # The key thing is that there must be at least - # one special character (period, slash, or - # underscore). - | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+ - - # Things that have markup suppressed - # Don't process things like '\<' in \, though. - # TODO: including < is a hack, not very satisfying. - | \\[^\s<] - ) - - # labels for headings - (?:@[\w+%-]+(?:\.[\w|%-]+)?)? - )/x - - ## - # Version of CROSSREF_REGEXP used when --hyperlink-all is specified. - - ALL_CROSSREF_REGEXP = / - (?:^|[\s()]) - ( - (?: - # A::B::C.meth - #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR} - - # A::B::C - | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z) - - # Stand-alone method - | \\?#{METHOD_REGEXP_STR} - - # Things that look like filenames - | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+ - - # Things that have markup suppressed - | \\[^\s<] - ) - - # labels for headings - (?:@[\w+%-]+)? - )/x - - ## - # Hash of references that have been looked-up to their replacements - - attr_accessor :seen - - ## - # Allows cross-references to be created based on the given +context+ - # (RDoc::Context). - - def initialize context - @context = context - @store = context.store - - @seen = {} - end - - ## - # Returns a method reference to +name+. - - def resolve_method name - ref = nil - - if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then - type = $2 - if '.' == type # will find either #method or ::method - method = $3 - else - method = "#{type}#{$3}" - end - container = @context.find_symbol_module($1) - elsif /^([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then - type = $1 - if '.' == type - method = $2 - else - method = "#{type}#{$2}" - end - container = @context - else - type = nil - container = nil - end - - if container then - unless RDoc::TopLevel === container then - if '.' == type then - if 'new' == method then # AnyClassName.new will be class method - ref = container.find_local_symbol method - ref = container.find_ancestor_local_symbol method unless ref - else - ref = container.find_local_symbol "::#{method}" - ref = container.find_ancestor_local_symbol "::#{method}" unless ref - ref = container.find_local_symbol "##{method}" unless ref - ref = container.find_ancestor_local_symbol "##{method}" unless ref - end - else - ref = container.find_local_symbol method - ref = container.find_ancestor_local_symbol method unless ref - end - end - end - - ref - end - - ## - # Returns a reference to +name+. - # - # If the reference is found and +name+ is not documented +text+ will be - # returned. If +name+ is escaped +name+ is returned. If +name+ is not - # found +text+ is returned. - - def resolve name, text - return @seen[name] if @seen.include? name - - ref = case name - when /^\\(#{CLASS_REGEXP_STR})$/o then - @context.find_symbol $1 - else - @context.find_symbol name - end - - ref = resolve_method name unless ref - - # Try a page name - ref = @store.page name if not ref and name =~ /^[\w.]+$/ - - ref = nil if RDoc::Alias === ref # external alias, can't link to it - - out = if name == '\\' then - name - elsif name =~ /^\\/ then - # we remove the \ only in front of what we know: - # other backslashes are treated later, only outside of - ref ? $' : name - elsif ref then - if ref.display? then - ref - else - text - end - else - text - end - - @seen[name] = out - - out - end - -end diff --git a/lib/rdoc/encoding.rb b/lib/rdoc/encoding.rb deleted file mode 100644 index 67e190f782..0000000000 --- a/lib/rdoc/encoding.rb +++ /dev/null @@ -1,120 +0,0 @@ -# coding: US-ASCII -# frozen_string_literal: true - -## -# This class is a wrapper around File IO and Encoding that helps RDoc load -# files and convert them to the correct encoding. - -module RDoc::Encoding - - HEADER_REGEXP = /^ - (?: - \A\#!.*\n - | - ^\#\s+frozen[-_]string[-_]literal[=:].+\n - | - ^\#[^\n]+\b(?:en)?coding[=:]\s*(?[^\s;]+).*\n - | - <\?xml[^?]*encoding=(?["'])(?.*?)\k.*\n - )+ - /xi # :nodoc: - - ## - # Reads the contents of +filename+ and handles any encoding directives in - # the file. - # - # The content will be converted to the +encoding+. If the file cannot be - # converted a warning will be printed and nil will be returned. - # - # If +force_transcode+ is true the document will be transcoded and any - # unknown character in the target encoding will be replaced with '?' - - def self.read_file filename, encoding, force_transcode = false - content = File.open filename, "rb" do |f| f.read end - content.gsub!("\r\n", "\n") if RUBY_PLATFORM =~ /mswin|mingw/ - - utf8 = content.sub!(/\A\xef\xbb\xbf/, '') - - enc = RDoc::Encoding.detect_encoding content - content = RDoc::Encoding.change_encoding content, enc if enc - - begin - encoding ||= Encoding.default_external - orig_encoding = content.encoding - - if not orig_encoding.ascii_compatible? then - content = content.encode encoding - elsif utf8 then - content = RDoc::Encoding.change_encoding content, Encoding::UTF_8 - content = content.encode encoding - else - # assume the content is in our output encoding - content = RDoc::Encoding.change_encoding content, encoding - end - - unless content.valid_encoding? then - # revert and try to transcode - content = RDoc::Encoding.change_encoding content, orig_encoding - content = content.encode encoding - end - - unless content.valid_encoding? then - warn "unable to convert #{filename} to #{encoding}, skipping" - content = nil - end - rescue Encoding::InvalidByteSequenceError, - Encoding::UndefinedConversionError => e - if force_transcode then - content = RDoc::Encoding.change_encoding content, orig_encoding - content = content.encode(encoding, - :invalid => :replace, - :undef => :replace, - :replace => '?') - return content - else - warn "unable to convert #{e.message} for #{filename}, skipping" - return nil - end - end - - content - rescue ArgumentError => e - raise unless e.message =~ /unknown encoding name - (.*)/ - warn "unknown encoding name \"#{$1}\" for #{filename}, skipping" - nil - rescue Errno::EISDIR, Errno::ENOENT - nil - end - - ## - # Detects the encoding of +string+ based on the magic comment - - def self.detect_encoding string - result = HEADER_REGEXP.match string - name = result && result[:name] - - name ? Encoding.find(name) : nil - end - - ## - # Removes magic comments and shebang - - def self.remove_magic_comment string - string.sub HEADER_REGEXP do |s| - s.gsub(/[^\n]/, '') - end - end - - ## - # Changes encoding based on +encoding+ without converting and returns new - # string - - def self.change_encoding text, encoding - if text.kind_of? RDoc::Comment - text.encode! encoding - else - String.new text, encoding: encoding - end - end - -end diff --git a/lib/rdoc/erb_partial.rb b/lib/rdoc/erb_partial.rb deleted file mode 100644 index 043d763db1..0000000000 --- a/lib/rdoc/erb_partial.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true -## -# Allows an ERB template to be rendered in the context (binding) of an -# existing ERB template evaluation. - -class RDoc::ERBPartial < ERB - - ## - # Overrides +compiler+ startup to set the +eoutvar+ to an empty string only - # if it isn't already set. - - def set_eoutvar compiler, eoutvar = '_erbout' - super - - compiler.pre_cmd = ["#{eoutvar} ||= +''"] - end - -end diff --git a/lib/rdoc/erbio.rb b/lib/rdoc/erbio.rb deleted file mode 100644 index 0f98eaedee..0000000000 --- a/lib/rdoc/erbio.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true -require 'erb' - -## -# A subclass of ERB that writes directly to an IO. Credit to Aaron Patterson -# and Masatoshi SEKI. -# -# To use: -# -# erbio = RDoc::ERBIO.new '<%= "hello world" %>', nil, nil -# -# File.open 'hello.txt', 'w' do |io| -# erbio.result binding -# end -# -# Note that binding must enclose the io you wish to output on. - -class RDoc::ERBIO < ERB - - ## - # Defaults +eoutvar+ to 'io', otherwise is identical to ERB's initialize - - def initialize str, trim_mode: nil, eoutvar: 'io' - super(str, trim_mode: trim_mode, eoutvar: eoutvar) - end - - ## - # Instructs +compiler+ how to write to +io_variable+ - - def set_eoutvar compiler, io_variable - compiler.put_cmd = "#{io_variable}.write" - compiler.insert_cmd = "#{io_variable}.write" - compiler.pre_cmd = [] - compiler.post_cmd = [] - end - -end diff --git a/lib/rdoc/generator.rb b/lib/rdoc/generator.rb deleted file mode 100644 index a769cf8ac0..0000000000 --- a/lib/rdoc/generator.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true -## -# RDoc uses generators to turn parsed source code in the form of an -# RDoc::CodeObject tree into some form of output. RDoc comes with the HTML -# generator RDoc::Generator::Darkfish and an ri data generator -# RDoc::Generator::RI. -# -# == Registering a Generator -# -# Generators are registered by calling RDoc::RDoc.add_generator with the class -# of the generator: -# -# class My::Awesome::Generator -# RDoc::RDoc.add_generator self -# end -# -# == Adding Options to +rdoc+ -# -# Before option processing in +rdoc+, RDoc::Options will call ::setup_options -# on the generator class with an RDoc::Options instance. The generator can -# use RDoc::Options#option_parser to add command-line options to the +rdoc+ -# tool. See RDoc::Options@Custom+Options for an example and see OptionParser -# for details on how to add options. -# -# You can extend the RDoc::Options instance with additional accessors for your -# generator. -# -# == Generator Instantiation -# -# After parsing, RDoc::RDoc will instantiate a generator by calling -# #initialize with an RDoc::Store instance and an RDoc::Options instance. -# -# The RDoc::Store instance holds documentation for parsed source code. In -# RDoc 3 and earlier the RDoc::TopLevel class held this data. When upgrading -# a generator from RDoc 3 and earlier you should only need to replace -# RDoc::TopLevel with the store instance. -# -# RDoc will then call #generate on the generator instance. You can use the -# various methods on RDoc::Store and in the RDoc::CodeObject tree to create -# your desired output format. - -module RDoc::Generator - - autoload :Markup, "#{__dir__}/generator/markup" - - autoload :Darkfish, "#{__dir__}/generator/darkfish" - autoload :JsonIndex, "#{__dir__}/generator/json_index" - autoload :RI, "#{__dir__}/generator/ri" - autoload :POT, "#{__dir__}/generator/pot" - -end diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb deleted file mode 100644 index 08f2b85e3b..0000000000 --- a/lib/rdoc/generator/darkfish.rb +++ /dev/null @@ -1,828 +0,0 @@ -# frozen_string_literal: true -# -*- mode: ruby; ruby-indent-level: 2; tab-width: 2 -*- - -require 'erb' -require 'fileutils' -require 'pathname' -require_relative 'markup' - -## -# Darkfish RDoc HTML Generator -# -# $Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $ -# -# == Author/s -# * Michael Granger (ged@FaerieMUD.org) -# -# == Contributors -# * Mahlon E. Smith (mahlon@martini.nu) -# * Eric Hodel (drbrain@segment7.net) -# -# == License -# -# Copyright (c) 2007, 2008, Michael Granger. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# * Neither the name of the author/s, nor the names of the project's -# contributors may be used to endorse or promote products derived from this -# software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# == Attributions -# -# Darkfish uses the {Silk Icons}[http://www.famfamfam.com/lab/icons/silk/] set -# by Mark James. - -class RDoc::Generator::Darkfish - - RDoc::RDoc.add_generator self - - include ERB::Util - - ## - # Stylesheets, fonts, etc. that are included in RDoc. - - BUILTIN_STYLE_ITEMS = # :nodoc: - %w[ - css/fonts.css - fonts/Lato-Light.ttf - fonts/Lato-LightItalic.ttf - fonts/Lato-Regular.ttf - fonts/Lato-RegularItalic.ttf - fonts/SourceCodePro-Bold.ttf - fonts/SourceCodePro-Regular.ttf - css/rdoc.css - ] - - ## - # Path to this file's parent directory. Used to find templates and other - # resources. - - GENERATOR_DIR = File.join 'rdoc', 'generator' - - ## - # Release Version - - VERSION = '3' - - ## - # Description of this generator - - DESCRIPTION = 'HTML generator, written by Michael Granger' - - ## - # The relative path to style sheets and javascript. By default this is set - # the same as the rel_prefix. - - attr_accessor :asset_rel_path - - ## - # The path to generate files into, combined with --op from the - # options for a full path. - - attr_reader :base_dir - - ## - # Classes and modules to be used by this generator, not necessarily - # displayed. See also #modsort - - attr_reader :classes - - ## - # No files will be written when dry_run is true. - - attr_accessor :dry_run - - ## - # When false the generate methods return a String instead of writing to a - # file. The default is true. - - attr_accessor :file_output - - ## - # Files to be displayed by this generator - - attr_reader :files - - ## - # The JSON index generator for this Darkfish generator - - attr_reader :json_index - - ## - # Methods to be displayed by this generator - - attr_reader :methods - - ## - # Sorted list of classes and modules to be displayed by this generator - - attr_reader :modsort - - ## - # The RDoc::Store that is the source of the generated content - - attr_reader :store - - ## - # The directory where the template files live - - attr_reader :template_dir # :nodoc: - - ## - # The output directory - - attr_reader :outputdir - - ## - # Initialize a few instance variables before we start - - def initialize store, options - @store = store - @options = options - - @asset_rel_path = '' - @base_dir = Pathname.pwd.expand_path - @dry_run = @options.dry_run - @file_output = true - @template_dir = Pathname.new options.template_dir - @template_cache = {} - - @classes = nil - @context = nil - @files = nil - @methods = nil - @modsort = nil - - @json_index = RDoc::Generator::JsonIndex.new self, options - end - - ## - # Output progress information if debugging is enabled - - def debug_msg *msg - return unless $DEBUG_RDOC - $stderr.puts(*msg) - end - - ## - # Directory where generated class HTML files live relative to the output - # dir. - - def class_dir - nil - end - - ## - # Directory where generated class HTML files live relative to the output - # dir. - - def file_dir - nil - end - - ## - # Create the directories the generated docs will live in if they don't - # already exist. - - def gen_sub_directories - @outputdir.mkpath - end - - ## - # Copy over the stylesheet into the appropriate place in the output - # directory. - - def write_style_sheet - debug_msg "Copying static files" - options = { :verbose => $DEBUG_RDOC, :noop => @dry_run } - - BUILTIN_STYLE_ITEMS.each do |item| - install_rdoc_static_file @template_dir + item, "./#{item}", options - end - - unless @options.template_stylesheets.empty? - FileUtils.cp @options.template_stylesheets, '.', **options - end - - Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path| - next if File.directory? path - next if File.basename(path) =~ /^\./ - - dst = Pathname.new(path).relative_path_from @template_dir - - install_rdoc_static_file @template_dir + path, dst, options - end - end - - ## - # Build the initial indices and output objects based on an array of TopLevel - # objects containing the extracted information. - - def generate - setup - - write_style_sheet - generate_index - generate_class_files - generate_file_files - generate_table_of_contents - @json_index.generate - @json_index.generate_gzipped - - copy_static - - rescue => e - debug_msg "%s: %s\n %s" % [ - e.class.name, e.message, e.backtrace.join("\n ") - ] - - raise - end - - ## - # Copies static files from the static_path into the output directory - - def copy_static - return if @options.static_path.empty? - - fu_options = { :verbose => $DEBUG_RDOC, :noop => @dry_run } - - @options.static_path.each do |path| - unless File.directory? path then - FileUtils.install path, @outputdir, **fu_options.merge(:mode => 0644) - next - end - - Dir.chdir path do - Dir[File.join('**', '*')].each do |entry| - dest_file = @outputdir + entry - - if File.directory? entry then - FileUtils.mkdir_p entry, **fu_options - else - FileUtils.install entry, dest_file, **fu_options.merge(:mode => 0644) - end - end - end - end - end - - ## - # Return a list of the documented modules sorted by salience first, then - # by name. - - def get_sorted_module_list classes - classes.select do |klass| - klass.display? - end.sort - end - - ## - # Generate an index page which lists all the classes which are documented. - - def generate_index - setup - - template_file = @template_dir + 'index.rhtml' - return unless template_file.exist? - - debug_msg "Rendering the index page..." - - out_file = @base_dir + @options.op_dir + 'index.html' - rel_prefix = @outputdir.relative_path_from out_file.dirname - search_index_rel_prefix = rel_prefix - search_index_rel_prefix += @asset_rel_path if @file_output - - asset_rel_prefix = rel_prefix + @asset_rel_path - - @title = @options.title - - render_template template_file, out_file do |io| - here = binding - # suppress 1.9.3 warning - here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) - here - end - rescue => e - error = RDoc::Error.new \ - "error generating index.html: #{e.message} (#{e.class})" - error.set_backtrace e.backtrace - - raise error - end - - ## - # Generates a class file for +klass+ - - def generate_class klass, template_file = nil - setup - - current = klass - - template_file ||= @template_dir + 'class.rhtml' - - debug_msg " working on %s (%s)" % [klass.full_name, klass.path] - out_file = @outputdir + klass.path - rel_prefix = @outputdir.relative_path_from out_file.dirname - search_index_rel_prefix = rel_prefix - search_index_rel_prefix += @asset_rel_path if @file_output - - asset_rel_prefix = rel_prefix + @asset_rel_path - svninfo = get_svninfo(current) - - @title = "#{klass.type} #{klass.full_name} - #{@options.title}" - - debug_msg " rendering #{out_file}" - render_template template_file, out_file do |io| - here = binding - # suppress 1.9.3 warning - here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) - here.local_variable_set(:svninfo, svninfo) - here - end - end - - ## - # Generate a documentation file for each class and module - - def generate_class_files - setup - - template_file = @template_dir + 'class.rhtml' - template_file = @template_dir + 'classpage.rhtml' unless - template_file.exist? - return unless template_file.exist? - debug_msg "Generating class documentation in #{@outputdir}" - - current = nil - - @classes.each do |klass| - current = klass - - generate_class klass, template_file - end - rescue => e - error = RDoc::Error.new \ - "error generating #{current.path}: #{e.message} (#{e.class})" - error.set_backtrace e.backtrace - - raise error - end - - ## - # Generate a documentation file for each file - - def generate_file_files - setup - - page_file = @template_dir + 'page.rhtml' - fileinfo_file = @template_dir + 'fileinfo.rhtml' - - # for legacy templates - filepage_file = @template_dir + 'filepage.rhtml' unless - page_file.exist? or fileinfo_file.exist? - - return unless - page_file.exist? or fileinfo_file.exist? or filepage_file.exist? - - debug_msg "Generating file documentation in #{@outputdir}" - - out_file = nil - current = nil - - @files.each do |file| - current = file - - if file.text? and page_file.exist? then - generate_page file - next - end - - template_file = nil - out_file = @outputdir + file.path - debug_msg " working on %s (%s)" % [file.full_name, out_file] - rel_prefix = @outputdir.relative_path_from out_file.dirname - search_index_rel_prefix = rel_prefix - search_index_rel_prefix += @asset_rel_path if @file_output - - asset_rel_prefix = rel_prefix + @asset_rel_path - - unless filepage_file then - if file.text? then - next unless page_file.exist? - template_file = page_file - @title = file.page_name - else - next unless fileinfo_file.exist? - template_file = fileinfo_file - @title = "File: #{file.base_name}" - end - end - - @title += " - #{@options.title}" - template_file ||= filepage_file - - render_template template_file, out_file do |io| - here = binding - # suppress 1.9.3 warning - here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) - here.local_variable_set(:current, current) - here - end - end - rescue => e - error = - RDoc::Error.new "error generating #{out_file}: #{e.message} (#{e.class})" - error.set_backtrace e.backtrace - - raise error - end - - ## - # Generate a page file for +file+ - - def generate_page file - setup - - template_file = @template_dir + 'page.rhtml' - - out_file = @outputdir + file.path - debug_msg " working on %s (%s)" % [file.full_name, out_file] - rel_prefix = @outputdir.relative_path_from out_file.dirname - search_index_rel_prefix = rel_prefix - search_index_rel_prefix += @asset_rel_path if @file_output - - current = file - asset_rel_prefix = rel_prefix + @asset_rel_path - - @title = "#{file.page_name} - #{@options.title}" - - debug_msg " rendering #{out_file}" - render_template template_file, out_file do |io| - here = binding - # suppress 1.9.3 warning - here.local_variable_set(:current, current) - here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) - here - end - end - - ## - # Generates the 404 page for the RDoc servlet - - def generate_servlet_not_found message - setup - - template_file = @template_dir + 'servlet_not_found.rhtml' - return unless template_file.exist? - - debug_msg "Rendering the servlet 404 Not Found page..." - - rel_prefix = rel_prefix = '' - search_index_rel_prefix = rel_prefix - search_index_rel_prefix += @asset_rel_path if @file_output - - asset_rel_prefix = '' - - @title = 'Not Found' - - render_template template_file do |io| - here = binding - # suppress 1.9.3 warning - here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) - here - end - rescue => e - error = RDoc::Error.new \ - "error generating servlet_not_found: #{e.message} (#{e.class})" - error.set_backtrace e.backtrace - - raise error - end - - ## - # Generates the servlet root page for the RDoc servlet - - def generate_servlet_root installed - setup - - template_file = @template_dir + 'servlet_root.rhtml' - return unless template_file.exist? - - debug_msg 'Rendering the servlet root page...' - - rel_prefix = '.' - asset_rel_prefix = rel_prefix - search_index_rel_prefix = asset_rel_prefix - search_index_rel_prefix += @asset_rel_path if @file_output - - @title = 'Local RDoc Documentation' - - render_template template_file do |io| binding end - rescue => e - error = RDoc::Error.new \ - "error generating servlet_root: #{e.message} (#{e.class})" - error.set_backtrace e.backtrace - - raise error - end - - ## - # Generate an index page which lists all the classes which are documented. - - def generate_table_of_contents - setup - - template_file = @template_dir + 'table_of_contents.rhtml' - return unless template_file.exist? - - debug_msg "Rendering the Table of Contents..." - - out_file = @outputdir + 'table_of_contents.html' - rel_prefix = @outputdir.relative_path_from out_file.dirname - search_index_rel_prefix = rel_prefix - search_index_rel_prefix += @asset_rel_path if @file_output - - asset_rel_prefix = rel_prefix + @asset_rel_path - - @title = "Table of Contents - #{@options.title}" - - render_template template_file, out_file do |io| - here = binding - # suppress 1.9.3 warning - here.local_variable_set(:asset_rel_prefix, asset_rel_prefix) - here - end - rescue => e - error = RDoc::Error.new \ - "error generating table_of_contents.html: #{e.message} (#{e.class})" - error.set_backtrace e.backtrace - - raise error - end - - def install_rdoc_static_file source, destination, options # :nodoc: - return unless source.exist? - - begin - FileUtils.mkdir_p File.dirname(destination), **options - - begin - FileUtils.ln source, destination, **options - rescue Errno::EEXIST - FileUtils.rm destination - retry - end - rescue - FileUtils.cp source, destination, **options - end - end - - ## - # Prepares for generation of output from the current directory - - def setup - return if instance_variable_defined? :@outputdir - - @outputdir = Pathname.new(@options.op_dir).expand_path @base_dir - - return unless @store - - @classes = @store.all_classes_and_modules.sort - @files = @store.all_files.sort - @methods = @classes.flat_map { |m| m.method_list }.sort - @modsort = get_sorted_module_list @classes - end - - ## - # Return a string describing the amount of time in the given number of - # seconds in terms a human can understand easily. - - def time_delta_string seconds - return 'less than a minute' if seconds < 60 - return "#{seconds / 60} minute#{seconds / 60 == 1 ? '' : 's'}" if - seconds < 3000 # 50 minutes - return 'about one hour' if seconds < 5400 # 90 minutes - return "#{seconds / 3600} hours" if seconds < 64800 # 18 hours - return 'one day' if seconds < 86400 # 1 day - return 'about one day' if seconds < 172800 # 2 days - return "#{seconds / 86400} days" if seconds < 604800 # 1 week - return 'about one week' if seconds < 1209600 # 2 week - return "#{seconds / 604800} weeks" if seconds < 7257600 # 3 months - return "#{seconds / 2419200} months" if seconds < 31536000 # 1 year - return "#{seconds / 31536000} years" - end - - # %q$Id: darkfish.rb 52 2009-01-07 02:08:11Z deveiant $" - SVNID_PATTERN = / - \$Id:\s - (\S+)\s # filename - (\d+)\s # rev - (\d{4}-\d{2}-\d{2})\s # Date (YYYY-MM-DD) - (\d{2}:\d{2}:\d{2}Z)\s # Time (HH:MM:SSZ) - (\w+)\s # committer - \$$ - /x - - ## - # Try to extract Subversion information out of the first constant whose - # value looks like a subversion Id tag. If no matching constant is found, - # and empty hash is returned. - - def get_svninfo klass - constants = klass.constants or return {} - - constants.find { |c| c.value =~ SVNID_PATTERN } or return {} - - filename, rev, date, time, committer = $~.captures - commitdate = Time.parse "#{date} #{time}" - - return { - :filename => filename, - :rev => Integer(rev), - :commitdate => commitdate, - :commitdelta => time_delta_string(Time.now - commitdate), - :committer => committer, - } - end - - ## - # Creates a template from its components and the +body_file+. - # - # For backwards compatibility, if +body_file+ contains " - - - -#{head_file.read} - -#{body} - TEMPLATE - end - - ## - # Renders the ERb contained in +file_name+ relative to the template - # directory and returns the result based on the current context. - - def render file_name - template_file = @template_dir + file_name - - template = template_for template_file, false, RDoc::ERBPartial - - template.filename = template_file.to_s - - template.result @context - end - - ## - # Load and render the erb template in the given +template_file+ and write - # it out to +out_file+. - # - # Both +template_file+ and +out_file+ should be Pathname-like objects. - # - # An io will be yielded which must be captured by binding in the caller. - - def render_template template_file, out_file = nil # :yield: io - io_output = out_file && !@dry_run && @file_output - erb_klass = io_output ? RDoc::ERBIO : ERB - - template = template_for template_file, true, erb_klass - - if io_output then - debug_msg "Outputting to %s" % [out_file.expand_path] - - out_file.dirname.mkpath - out_file.open 'w', 0644 do |io| - io.set_encoding @options.encoding - - @context = yield io - - template_result template, @context, template_file - end - else - @context = yield nil - - output = template_result template, @context, template_file - - debug_msg " would have written %d characters to %s" % [ - output.length, out_file.expand_path - ] if @dry_run - - output - end - end - - ## - # Creates the result for +template+ with +context+. If an error is raised a - # Pathname +template_file+ will indicate the file where the error occurred. - - def template_result template, context, template_file - template.filename = template_file.to_s - template.result context - rescue NoMethodError => e - raise RDoc::Error, "Error while evaluating %s: %s" % [ - template_file.expand_path, - e.message, - ], e.backtrace - end - - ## - # Retrieves a cache template for +file+, if present, or fills the cache. - - def template_for file, page = true, klass = ERB - template = @template_cache[file] - - return template if template - - if page then - template = assemble_template file - erbout = 'io' - else - template = file.read - template = template.encode @options.encoding - - file_var = File.basename(file).sub(/\..*/, '') - - erbout = "_erbout_#{file_var}" - end - - template = klass.new template, trim_mode: '-', eoutvar: erbout - @template_cache[file] = template - template - end - - # Returns an excerpt of the content for usage in meta description tags - def excerpt(content) - text = case content - when RDoc::Comment - content.text - when RDoc::Markup::Document - # This case is for page files that are not markdown nor rdoc - # We convert them to markdown for now as it's easier to extract the text - formatter = RDoc::Markup::ToMarkdown.new - formatter.start_accepting - formatter.accept_document(content) - formatter.end_accepting - else - content - end - - # Match from a capital letter to the first period, discarding any links, so - # that we don't end up matching badges in the README - first_paragraph_match = text.match(/[A-Z][^\.:\/]+\./) - return text[0...150].gsub(/\n/, " ").squeeze(" ") unless first_paragraph_match - - extracted_text = first_paragraph_match[0] - second_paragraph = first_paragraph_match.post_match.match(/[A-Z][^\.:\/]+\./) - extracted_text << " " << second_paragraph[0] if second_paragraph - - extracted_text[0...150].gsub(/\n/, " ").squeeze(" ") - end - - def generate_ancestor_list(ancestors, klass) - return '' if ancestors.empty? - - ancestor = ancestors.shift - content = +'
  • ' - - if ancestor.is_a?(RDoc::NormalClass) - content << "#{ancestor.full_name}" - else - content << ancestor.to_s - end - - # Recursively call the method for the remaining ancestors - content << generate_ancestor_list(ancestors, klass) - - content << '
' - end -end diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb deleted file mode 100644 index c454910d5c..0000000000 --- a/lib/rdoc/generator/json_index.rb +++ /dev/null @@ -1,300 +0,0 @@ -# frozen_string_literal: true -require 'json' -begin - require 'zlib' -rescue LoadError -end - -## -# The JsonIndex generator is designed to complement an HTML generator and -# produces a JSON search index. This generator is derived from sdoc by -# Vladimir Kolesnikov and contains verbatim code written by him. -# -# This generator is designed to be used with a regular HTML generator: -# -# class RDoc::Generator::Darkfish -# def initialize options -# # ... -# @base_dir = Pathname.pwd.expand_path -# -# @json_index = RDoc::Generator::JsonIndex.new self, options -# end -# -# def generate -# # ... -# @json_index.generate -# end -# end -# -# == Index Format -# -# The index is output as a JSON file assigned to the global variable -# +search_data+. The structure is: -# -# var search_data = { -# "index": { -# "searchIndex": -# ["a", "b", ...], -# "longSearchIndex": -# ["a", "a::b", ...], -# "info": [ -# ["A", "A", "A.html", "", ""], -# ["B", "A::B", "A::B.html", "", ""], -# ... -# ] -# } -# } -# -# The same item is described across the +searchIndex+, +longSearchIndex+ and -# +info+ fields. The +searchIndex+ field contains the item's short name, the -# +longSearchIndex+ field contains the full_name (when appropriate) and the -# +info+ field contains the item's name, full_name, path, parameters and a -# snippet of the item's comment. -# -# == LICENSE -# -# Copyright (c) 2009 Vladimir Kolesnikov -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -class RDoc::Generator::JsonIndex - - include RDoc::Text - - ## - # Where the search index lives in the generated output - - SEARCH_INDEX_FILE = File.join 'js', 'search_index.js' - - attr_reader :index # :nodoc: - - ## - # Creates a new generator. +parent_generator+ is used to determine the - # class_dir and file_dir of links in the output index. - # - # +options+ are the same options passed to the parent generator. - - def initialize parent_generator, options - @parent_generator = parent_generator - @store = parent_generator.store - @options = options - - @template_dir = File.expand_path '../template/json_index', __FILE__ - @base_dir = @parent_generator.base_dir - - @classes = nil - @files = nil - @index = nil - end - - ## - # Builds the JSON index as a Hash. - - def build_index - reset @store.all_files.sort, @store.all_classes_and_modules.sort - - index_classes - index_methods - index_pages - - { :index => @index } - end - - ## - # Output progress information if debugging is enabled - - def debug_msg *msg - return unless $DEBUG_RDOC - $stderr.puts(*msg) - end - - ## - # Writes the JSON index to disk - - def generate - debug_msg "Generating JSON index" - - debug_msg " writing search index to %s" % SEARCH_INDEX_FILE - data = build_index - - return if @options.dry_run - - out_dir = @base_dir + @options.op_dir - index_file = out_dir + SEARCH_INDEX_FILE - - FileUtils.mkdir_p index_file.dirname, :verbose => $DEBUG_RDOC - - index_file.open 'w', 0644 do |io| - io.set_encoding Encoding::UTF_8 - io.write 'var search_data = ' - - JSON.dump data, io, 0 - end - unless ENV['SOURCE_DATE_EPOCH'].nil? - index_file.utime index_file.atime, Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime - end - - Dir.chdir @template_dir do - Dir['**/*.js'].each do |source| - dest = File.join out_dir, source - - FileUtils.install source, dest, :mode => 0644, :preserve => true, :verbose => $DEBUG_RDOC - end - end - end - - ## - # Compress the search_index.js file using gzip - - def generate_gzipped - return if @options.dry_run or not defined?(Zlib) - - debug_msg "Compressing generated JSON index" - out_dir = @base_dir + @options.op_dir - - search_index_file = out_dir + SEARCH_INDEX_FILE - outfile = out_dir + "#{search_index_file}.gz" - - debug_msg "Reading the JSON index file from %s" % search_index_file - search_index = search_index_file.read(mode: 'r:utf-8') - - debug_msg "Writing gzipped search index to %s" % outfile - - Zlib::GzipWriter.open(outfile) do |gz| - gz.mtime = File.mtime(search_index_file) - gz.orig_name = search_index_file.basename.to_s - gz.write search_index - gz.close - end - - # GZip the rest of the js files - Dir.chdir @template_dir do - Dir['**/*.js'].each do |source| - dest = out_dir + source - outfile = out_dir + "#{dest}.gz" - - debug_msg "Reading the original js file from %s" % dest - data = dest.read - - debug_msg "Writing gzipped file to %s" % outfile - - Zlib::GzipWriter.open(outfile) do |gz| - gz.mtime = File.mtime(dest) - gz.orig_name = dest.basename.to_s - gz.write data - gz.close - end - end - end - end - - ## - # Adds classes and modules to the index - - def index_classes - debug_msg " generating class search index" - - documented = @classes.uniq.select do |klass| - klass.document_self_or_methods - end - - documented.each do |klass| - debug_msg " #{klass.full_name}" - record = klass.search_record - @index[:searchIndex] << search_string(record.shift) - @index[:longSearchIndex] << search_string(record.shift) - @index[:info] << record - end - end - - ## - # Adds methods to the index - - def index_methods - debug_msg " generating method search index" - - list = @classes.uniq.flat_map do |klass| - klass.method_list - end.sort_by do |method| - [method.name, method.parent.full_name] - end - - list.each do |method| - debug_msg " #{method.full_name}" - record = method.search_record - @index[:searchIndex] << "#{search_string record.shift}()" - @index[:longSearchIndex] << "#{search_string record.shift}()" - @index[:info] << record - end - end - - ## - # Adds pages to the index - - def index_pages - debug_msg " generating pages search index" - - pages = @files.select do |file| - file.text? - end - - pages.each do |page| - debug_msg " #{page.page_name}" - record = page.search_record - @index[:searchIndex] << search_string(record.shift) - @index[:longSearchIndex] << '' - record.shift - @index[:info] << record - end - end - - ## - # The directory classes are written to - - def class_dir - @parent_generator.class_dir - end - - ## - # The directory files are written to - - def file_dir - @parent_generator.file_dir - end - - def reset files, classes # :nodoc: - @files = files - @classes = classes - - @index = { - :searchIndex => [], - :longSearchIndex => [], - :info => [] - } - end - - ## - # Removes whitespace and downcases +string+ - - def search_string string - string.downcase.gsub(/\s/, '') - end - -end diff --git a/lib/rdoc/generator/markup.rb b/lib/rdoc/generator/markup.rb deleted file mode 100644 index 76b7d458aa..0000000000 --- a/lib/rdoc/generator/markup.rb +++ /dev/null @@ -1,159 +0,0 @@ -# frozen_string_literal: true -## -# Handle common RDoc::Markup tasks for various CodeObjects -# -# This module is loaded by generators. It allows RDoc's CodeObject tree to -# avoid loading generator code to improve startup time for +ri+. - -module RDoc::Generator::Markup - - ## - # Generates a relative URL from this object's path to +target_path+ - - def aref_to(target_path) - RDoc::Markup::ToHtml.gen_relative_url path, target_path - end - - ## - # Generates a relative URL from +from_path+ to this object's path - - def as_href(from_path) - RDoc::Markup::ToHtml.gen_relative_url from_path, path - end - - ## - # Handy wrapper for marking up this object's comment - - def description - markup @comment - end - - ## - # Creates an RDoc::Markup::ToHtmlCrossref formatter - - def formatter - return @formatter if defined? @formatter - - options = @store.rdoc.options - this = RDoc::Context === self ? self : @parent - - @formatter = RDoc::Markup::ToHtmlCrossref.new options, this.path, this - @formatter.code_object = self - @formatter - end - - ## - # Build a webcvs URL starting for the given +url+ with +full_path+ appended - # as the destination path. If +url+ contains '%s' +full_path+ will be - # will replace the %s using sprintf on the +url+. - - def cvs_url(url, full_path) - if /%s/ =~ url then - sprintf url, full_path - else - url + full_path - end - end - -end - -class RDoc::CodeObject - - include RDoc::Generator::Markup - -end - -class RDoc::MethodAttr - - ## - # Prepend +src+ with line numbers. Relies on the first line of a source - # code listing having: - # - # # File xxxxx, line dddd - # - # If it has this comment then line numbers are added to +src+ and the , - # line dddd portion of the comment is removed. - - def add_line_numbers(src) - return unless src.sub!(/\A(.*)(, line (\d+))/, '\1') - first = $3.to_i - 1 - last = first + src.count("\n") - size = last.to_s.length - - line = first - src.gsub!(/^/) do - res = if line == first then - " " * (size + 1) - else - "%2$*1$d " % [size, line] - end - - line += 1 - res - end - end - - ## - # Turns the method's token stream into HTML. - # - # Prepends line numbers if +options.line_numbers+ is true. - - def markup_code - return '' unless @token_stream - - src = RDoc::TokenStream.to_html @token_stream - - # dedent the source - indent = src.length - lines = src.lines.to_a - lines.shift if src =~ /\A.*#\ *File/i # remove '# File' comment - lines.each do |line| - if line =~ /^ *(?=\S)/ - n = $~.end(0) - indent = n if n < indent - break if n == 0 - end - end - src.gsub!(/^#{' ' * indent}/, '') if indent > 0 - - add_line_numbers(src) if options.line_numbers - - src - end - -end - -class RDoc::ClassModule - - ## - # Handy wrapper for marking up this class or module's comment - - def description - markup @comment_location - end - -end - -class RDoc::Context::Section - - include RDoc::Generator::Markup - -end - -class RDoc::TopLevel - - ## - # Returns a URL for this source file on some web repository. Use the -W - # command line option to set. - - def cvs_url - url = @store.rdoc.options.webcvs - - if /%s/ =~ url then - url % @relative_name - else - url + @relative_name - end - end - -end diff --git a/lib/rdoc/generator/pot.rb b/lib/rdoc/generator/pot.rb deleted file mode 100644 index b0b7c07179..0000000000 --- a/lib/rdoc/generator/pot.rb +++ /dev/null @@ -1,99 +0,0 @@ -# frozen_string_literal: true -## -# Generates a POT file. -# -# Here is a translator work flow with the generator. -# -# == Create .pot -# -# You create .pot file by pot formatter: -# -# % rdoc --format pot -# -# It generates doc/rdoc.pot. -# -# == Create .po -# -# You create .po file from doc/rdoc.pot. This operation is needed only -# the first time. This work flow assumes that you are a translator -# for Japanese. -# -# You create locale/ja/rdoc.po from doc/rdoc.pot. You can use msginit -# provided by GNU gettext or rmsginit provided by gettext gem. This -# work flow uses gettext gem because it is more portable than GNU -# gettext for Rubyists. Gettext gem is implemented by pure Ruby. -# -# % gem install gettext -# % mkdir -p locale/ja -# % rmsginit --input doc/rdoc.pot --output locale/ja/rdoc.po --locale ja -# -# Translate messages in .po -# -# You translate messages in .po by a PO file editor. po-mode.el exists -# for Emacs users. There are some GUI tools such as GTranslator. -# There are some Web services such as POEditor and Tansifex. You can -# edit by your favorite text editor because .po is a text file. -# Generate localized documentation -# -# You can generate localized documentation with locale/ja/rdoc.po: -# -# % rdoc --locale ja -# -# You can find documentation in Japanese in doc/. Yay! -# -# == Update translation -# -# You need to update translation when your application is added or -# modified messages. -# -# You can update .po by the following command lines: -# -# % rdoc --format pot -# % rmsgmerge --update locale/ja/rdoc.po doc/rdoc.pot -# -# You edit locale/ja/rdoc.po to translate new messages. - -class RDoc::Generator::POT - - RDoc::RDoc.add_generator self - - ## - # Description of this generator - - DESCRIPTION = 'creates .pot file' - - ## - # Set up a new .pot generator - - def initialize store, options #:not-new: - @options = options - @store = store - end - - ## - # Writes .pot to disk. - - def generate - po = extract_messages - pot_path = 'rdoc.pot' - File.open(pot_path, "w") do |pot| - pot.print(po.to_s) - end - end - - # :nodoc: - def class_dir - nil - end - - private - def extract_messages - extractor = MessageExtractor.new(@store) - extractor.extract - end - - require_relative 'pot/message_extractor' - require_relative 'pot/po' - require_relative 'pot/po_entry' - -end diff --git a/lib/rdoc/generator/pot/message_extractor.rb b/lib/rdoc/generator/pot/message_extractor.rb deleted file mode 100644 index 4938858bdc..0000000000 --- a/lib/rdoc/generator/pot/message_extractor.rb +++ /dev/null @@ -1,68 +0,0 @@ -# frozen_string_literal: true -## -# Extracts message from RDoc::Store - -class RDoc::Generator::POT::MessageExtractor - - ## - # Creates a message extractor for +store+. - - def initialize store - @store = store - @po = RDoc::Generator::POT::PO.new - end - - ## - # Extracts messages from +store+, stores them into - # RDoc::Generator::POT::PO and returns it. - - def extract - @store.all_classes_and_modules.each do |klass| - extract_from_klass(klass) - end - @po - end - - private - - def extract_from_klass klass - extract_text(klass.comment_location, klass.full_name) - - klass.each_section do |section, constants, attributes| - extract_text(section.title, "#{klass.full_name}: section title") - section.comments.each do |comment| - extract_text(comment, "#{klass.full_name}: #{section.title}") - end - end - - klass.each_constant do |constant| - extract_text(constant.comment, constant.full_name) - end - - klass.each_attribute do |attribute| - extract_text(attribute.comment, attribute.full_name) - end - - klass.each_method do |method| - extract_text(method.comment, method.full_name) - end - end - - def extract_text text, comment, location = nil - return if text.nil? - - options = { - :extracted_comment => comment, - :references => [location].compact, - } - i18n_text = RDoc::I18n::Text.new(text) - i18n_text.extract_messages do |part| - @po.add(entry(part[:paragraph], options)) - end - end - - def entry msgid, options - RDoc::Generator::POT::POEntry.new(msgid, options) - end - -end diff --git a/lib/rdoc/generator/pot/po.rb b/lib/rdoc/generator/pot/po.rb deleted file mode 100644 index 37d45e5258..0000000000 --- a/lib/rdoc/generator/pot/po.rb +++ /dev/null @@ -1,84 +0,0 @@ -# frozen_string_literal: true -## -# Generates a PO format text - -class RDoc::Generator::POT::PO - - ## - # Creates an object that represents PO format. - - def initialize - @entries = {} - add_header - end - - ## - # Adds a PO entry to the PO. - - def add entry - existing_entry = @entries[entry.msgid] - if existing_entry - entry = existing_entry.merge(entry) - end - @entries[entry.msgid] = entry - end - - ## - # Returns PO format text for the PO. - - def to_s - po = '' - sort_entries.each do |entry| - po += "\n" unless po.empty? - po += entry.to_s - end - po - end - - private - - def add_header - add(header_entry) - end - - def header_entry - comment = <<-COMMENT -SOME DESCRIPTIVE TITLE. -Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -This file is distributed under the same license as the PACKAGE package. -FIRST AUTHOR , YEAR. - COMMENT - - content = <<-CONTENT -Project-Id-Version: PACKAGE VERSEION -Report-Msgid-Bugs-To: -PO-Revision-Date: YEAR-MO_DA HO:MI+ZONE -Last-Translator: FULL NAME -Language-Team: LANGUAGE -Language: -MIME-Version: 1.0 -Content-Type: text/plain; charset=CHARSET -Content-Transfer-Encoding: 8bit -Plural-Forms: nplurals=INTEGER; plural=EXPRESSION; - CONTENT - - options = { - :msgstr => content, - :translator_comment => comment, - :flags => ['fuzzy'], - } - RDoc::Generator::POT::POEntry.new('', options) - end - - def sort_entries - headers, messages = @entries.values.partition do |entry| - entry.msgid.empty? - end - # TODO: sort by location - sorted_messages = messages.sort_by do |entry| - entry.msgid - end - headers + sorted_messages - end - -end diff --git a/lib/rdoc/generator/pot/po_entry.rb b/lib/rdoc/generator/pot/po_entry.rb deleted file mode 100644 index 7454b29273..0000000000 --- a/lib/rdoc/generator/pot/po_entry.rb +++ /dev/null @@ -1,141 +0,0 @@ -# frozen_string_literal: true -## -# A PO entry in PO - -class RDoc::Generator::POT::POEntry - - # The msgid content - attr_reader :msgid - - # The msgstr content - attr_reader :msgstr - - # The comment content created by translator (PO editor) - attr_reader :translator_comment - - # The comment content extracted from source file - attr_reader :extracted_comment - - # The locations where the PO entry is extracted - attr_reader :references - - # The flags of the PO entry - attr_reader :flags - - ## - # Creates a PO entry for +msgid+. Other values can be specified by - # +options+. - - def initialize msgid, options = {} - @msgid = msgid - @msgstr = options[:msgstr] || "" - @translator_comment = options[:translator_comment] - @extracted_comment = options[:extracted_comment] - @references = options[:references] || [] - @flags = options[:flags] || [] - end - - ## - # Returns the PO entry in PO format. - - def to_s - entry = '' - entry += format_translator_comment - entry += format_extracted_comment - entry += format_references - entry += format_flags - entry += <<-ENTRY -msgid #{format_message(@msgid)} -msgstr #{format_message(@msgstr)} - ENTRY - end - - ## - # Merges the PO entry with +other_entry+. - - def merge other_entry - options = { - :extracted_comment => merge_string(@extracted_comment, - other_entry.extracted_comment), - :translator_comment => merge_string(@translator_comment, - other_entry.translator_comment), - :references => merge_array(@references, - other_entry.references), - :flags => merge_array(@flags, - other_entry.flags), - } - self.class.new(@msgid, options) - end - - private - - def format_comment mark, comment - return '' unless comment - return '' if comment.empty? - - formatted_comment = '' - comment.each_line do |line| - formatted_comment += "#{mark} #{line}" - end - formatted_comment += "\n" unless formatted_comment.end_with?("\n") - formatted_comment - end - - def format_translator_comment - format_comment('#', @translator_comment) - end - - def format_extracted_comment - format_comment('#.', @extracted_comment) - end - - def format_references - return '' if @references.empty? - - formatted_references = '' - @references.sort.each do |file, line| - formatted_references += "\#: #{file}:#{line}\n" - end - formatted_references - end - - def format_flags - return '' if @flags.empty? - - formatted_flags = flags.join(",") - "\#, #{formatted_flags}\n" - end - - def format_message message - return "\"#{escape(message)}\"" unless message.include?("\n") - - formatted_message = '""' - message.each_line do |line| - formatted_message += "\n" - formatted_message += "\"#{escape(line)}\"" - end - formatted_message - end - - def escape string - string.gsub(/["\\\t\n]/) do |special_character| - case special_character - when "\t" - "\\t" - when "\n" - "\\n" - else - "\\#{special_character}" - end - end - end - - def merge_string string1, string2 - [string1, string2].compact.join("\n") - end - - def merge_array array1, array2 - (array1 + array2).uniq - end - -end diff --git a/lib/rdoc/generator/ri.rb b/lib/rdoc/generator/ri.rb deleted file mode 100644 index 1c2f018f97..0000000000 --- a/lib/rdoc/generator/ri.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true -## -# Generates ri data files - -class RDoc::Generator::RI - - RDoc::RDoc.add_generator self - - ## - # Description of this generator - - DESCRIPTION = 'creates ri data files' - - ## - # Set up a new ri generator - - def initialize store, options #:not-new: - @options = options - @store = store - @store.path = '.' - end - - ## - # Writes the parsed data store to disk for use by ri. - - def generate - @store.save - end - -end diff --git a/lib/rdoc/generator/template/darkfish/.document b/lib/rdoc/generator/template/darkfish/.document deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lib/rdoc/generator/template/darkfish/_footer.rhtml b/lib/rdoc/generator/template/darkfish/_footer.rhtml deleted file mode 100644 index 9791b42901..0000000000 --- a/lib/rdoc/generator/template/darkfish/_footer.rhtml +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/lib/rdoc/generator/template/darkfish/_head.rhtml b/lib/rdoc/generator/template/darkfish/_head.rhtml deleted file mode 100644 index 9e6fb4f94c..0000000000 --- a/lib/rdoc/generator/template/darkfish/_head.rhtml +++ /dev/null @@ -1,43 +0,0 @@ - - - -<%= h @title %> - -<%- if defined?(klass) -%> - "> - - <%- if klass.comment.empty? -%> - "> - <%- else -%> - "> - <%- end -%> -<%- elsif defined?(file) -%> - - "> -<%- elsif @title -%> - - - <%- if @options.main_page and - main_page = @files.find { |f| f.full_name == @options.main_page } then %> - "> - <%- else -%> - - <%- end -%> -<%- end -%> - - - - - - - - - - - -<%- @options.template_stylesheets.each do |stylesheet| -%> - -<%- end -%> diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml deleted file mode 100644 index 22a12d9e95..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +++ /dev/null @@ -1,19 +0,0 @@ -<%- if !svninfo.empty? then %> - -<%- end -%> diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml deleted file mode 100644 index 06b5542fa1..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +++ /dev/null @@ -1,34 +0,0 @@ - diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml deleted file mode 100644 index 7602076c96..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +++ /dev/null @@ -1,15 +0,0 @@ -<%- unless klass.extends.empty? then %> - -<%- end -%> diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml deleted file mode 100644 index 74869a4b51..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml deleted file mode 100644 index 5b600e5975..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +++ /dev/null @@ -1,15 +0,0 @@ -<%- unless klass.includes.empty? then %> - -<%- end -%> diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml deleted file mode 100644 index faed7e0a94..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml deleted file mode 100644 index d09216a0f6..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +++ /dev/null @@ -1,21 +0,0 @@ -<% if (class_methods = klass.class_method_list.sort).any? %> - -<% end %> - -<% if (instance_methods = klass.instance_methods.sort).any? %> - -<% end %> diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml deleted file mode 100644 index d7f330840a..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml deleted file mode 100644 index 3f68f0c0dc..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +++ /dev/null @@ -1,32 +0,0 @@ -<%- simple_files = @files.select { |f| f.text? } %> -<%- if defined?(current) -%> - <%- dir = current.full_name[%r{\A[^/]+(?=/)}] || current.page_name -%> -<%- end -%> -<%- unless simple_files.empty? then -%> - -<%- end -%> diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml deleted file mode 100644 index 6808b2bf87..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%- if klass.type == 'class' && (ancestors = klass.super_classes).any? -%> - -<%- end -%> diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml deleted file mode 100644 index afc7f7b88d..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml deleted file mode 100644 index 6dcd2ae81f..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +++ /dev/null @@ -1,11 +0,0 @@ -<%- unless klass.sections.length == 1 then %> - -<%- end -%> diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml deleted file mode 100644 index b1e047b5f7..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +++ /dev/null @@ -1,39 +0,0 @@ -<%- comment = if current.respond_to? :comment_location then - current.comment_location - else - current.comment - end - table = current.parse(comment).table_of_contents.dup - - if table.length > 1 then %> - -<%- end -%> diff --git a/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml b/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml deleted file mode 100644 index ed2cbe31a0..0000000000 --- a/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/lib/rdoc/generator/template/darkfish/class.rhtml b/lib/rdoc/generator/template/darkfish/class.rhtml deleted file mode 100644 index 0bec9fc9ce..0000000000 --- a/lib/rdoc/generator/template/darkfish/class.rhtml +++ /dev/null @@ -1,206 +0,0 @@ - -<%= render '_sidebar_toggle.rhtml' %> - - - -
-

- <%= klass.type %> <%= klass.full_name %> -

- -
- <%= klass.description %> -
- - <%- klass.each_section do |section, constants, attributes| -%> - -<%- end -%> -
diff --git a/lib/rdoc/generator/template/darkfish/css/fonts.css b/lib/rdoc/generator/template/darkfish/css/fonts.css deleted file mode 100644 index 57302b5183..0000000000 --- a/lib/rdoc/generator/template/darkfish/css/fonts.css +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), - * with Reserved Font Name "Source". All Rights Reserved. Source is a - * trademark of Adobe Systems Incorporated in the United States and/or other - * countries. - * - * This Font Software is licensed under the SIL Open Font License, Version - * 1.1. - * - * This license is copied below, and is also available with a FAQ at: - * http://scripts.sil.org/OFL - */ - -@font-face { - font-family: "Source Code Pro"; - font-style: normal; - font-weight: 400; - src: local("Source Code Pro"), - local("SourceCodePro-Regular"), - url("../fonts/SourceCodePro-Regular.ttf") format("truetype"); -} - -@font-face { - font-family: "Source Code Pro"; - font-style: normal; - font-weight: 700; - src: local("Source Code Pro Bold"), - local("SourceCodePro-Bold"), - url("../fonts/SourceCodePro-Bold.ttf") format("truetype"); -} - -/* - * Copyright (c) 2010, Łukasz Dziedzic (dziedzic@typoland.com), - * with Reserved Font Name Lato. - * - * This Font Software is licensed under the SIL Open Font License, Version - * 1.1. - * - * This license is copied below, and is also available with a FAQ at: - * http://scripts.sil.org/OFL - */ - -@font-face { - font-family: "Lato"; - font-style: normal; - font-weight: 300; - src: local("Lato Light"), - local("Lato-Light"), - url("../fonts/Lato-Light.ttf") format("truetype"); -} - -@font-face { - font-family: "Lato"; - font-style: italic; - font-weight: 300; - src: local("Lato Light Italic"), - local("Lato-LightItalic"), - url("../fonts/Lato-LightItalic.ttf") format("truetype"); -} - -@font-face { - font-family: "Lato"; - font-style: normal; - font-weight: 700; - src: local("Lato Regular"), - local("Lato-Regular"), - url("../fonts/Lato-Regular.ttf") format("truetype"); -} - -@font-face { - font-family: "Lato"; - font-style: italic; - font-weight: 700; - src: local("Lato Italic"), - local("Lato-Italic"), - url("../fonts/Lato-RegularItalic.ttf") format("truetype"); -} - -/* - * ----------------------------------------------------------- - * SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 - * ----------------------------------------------------------- - * - * PREAMBLE - * The goals of the Open Font License (OFL) are to stimulate worldwide - * development of collaborative font projects, to support the font creation - * efforts of academic and linguistic communities, and to provide a free and - * open framework in which fonts may be shared and improved in partnership - * with others. - * - * The OFL allows the licensed fonts to be used, studied, modified and - * redistributed freely as long as they are not sold by themselves. The - * fonts, including any derivative works, can be bundled, embedded, - * redistributed and/or sold with any software provided that any reserved - * names are not used by derivative works. The fonts and derivatives, - * however, cannot be released under any other type of license. The - * requirement for fonts to remain under this license does not apply - * to any document created using the fonts or their derivatives. - * - * DEFINITIONS - * "Font Software" refers to the set of files released by the Copyright - * Holder(s) under this license and clearly marked as such. This may - * include source files, build scripts and documentation. - * - * "Reserved Font Name" refers to any names specified as such after the - * copyright statement(s). - * - * "Original Version" refers to the collection of Font Software components as - * distributed by the Copyright Holder(s). - * - * "Modified Version" refers to any derivative made by adding to, deleting, - * or substituting -- in part or in whole -- any of the components of the - * Original Version, by changing formats or by porting the Font Software to a - * new environment. - * - * "Author" refers to any designer, engineer, programmer, technical - * writer or other person who contributed to the Font Software. - * - * PERMISSION & CONDITIONS - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of the Font Software, to use, study, copy, merge, embed, modify, - * redistribute, and sell modified and unmodified copies of the Font - * Software, subject to the following conditions: - * - * 1) Neither the Font Software nor any of its individual components, - * in Original or Modified Versions, may be sold by itself. - * - * 2) Original or Modified Versions of the Font Software may be bundled, - * redistributed and/or sold with any software, provided that each copy - * contains the above copyright notice and this license. These can be - * included either as stand-alone text files, human-readable headers or - * in the appropriate machine-readable metadata fields within text or - * binary files as long as those fields can be easily viewed by the user. - * - * 3) No Modified Version of the Font Software may use the Reserved Font - * Name(s) unless explicit written permission is granted by the corresponding - * Copyright Holder. This restriction only applies to the primary font name as - * presented to the users. - * - * 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font - * Software shall not be used to promote, endorse or advertise any - * Modified Version, except to acknowledge the contribution(s) of the - * Copyright Holder(s) and the Author(s) or with their explicit written - * permission. - * - * 5) The Font Software, modified or unmodified, in part or in whole, - * must be distributed entirely under this license, and must not be - * distributed under any other license. The requirement for fonts to - * remain under this license does not apply to any document created - * using the Font Software. - * - * TERMINATION - * This license becomes null and void if any of the above conditions are - * not met. - * - * DISCLAIMER - * THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL - * DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM - * OTHER DEALINGS IN THE FONT SOFTWARE. - */ - diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css deleted file mode 100644 index ed9b3e9c3b..0000000000 --- a/lib/rdoc/generator/template/darkfish/css/rdoc.css +++ /dev/null @@ -1,668 +0,0 @@ -/* - * "Darkfish" RDoc CSS - * $Id: rdoc.css 54 2009-01-27 01:09:48Z deveiant $ - * - * Author: Michael Granger - * - */ - -/* vim: ft=css et sw=2 ts=2 sts=2 */ - -/* 1. Variables and Root Styles */ -:root { - --sidebar-width: 300px; - --highlight-color: #cc342d; /* Reddish color for accents and headings */ - --secondary-highlight-color: #c83045; /* Darker reddish color for secondary highlights */ - --text-color: #505050; /* Dark bluish-grey for text */ - --background-color: #fefefe; /* Near white background */ - --code-block-background-color: #f6f6f3; /* Slightly darker grey for code blocks */ - --link-color: #42405F; /* Dark bluish-grey for links */ - --link-hover-color: var(--highlight-color); /* Reddish color on hover */ - --border-color: #e0e0e0;; /* General border color */ - --source-code-toggle-color: var(--secondary-highlight-color); - --scrollbar-thumb-hover-background: #505050; /* Hover color for scrollbar thumb */ - --table-header-background-color: #eceaed; - --table-td-background-color: #f5f4f6; - - /* Font family variables */ - --font-primary: 'Segoe UI', 'Verdana', 'Arial', sans-serif; - --font-heading: 'Helvetica', 'Arial', sans-serif; - --font-code: monospace; -} - -/* 2. Global Styles */ -body { - background: var(--background-color); - font-family: var(--font-primary); - font-weight: 400; - color: var(--text-color); - line-height: 1.6; - - /* Layout */ - display: flex; - flex-direction: column; - min-height: 100vh; - margin: 0; -} - -/* 3. Typography */ -h1 span, -h2 span, -h3 span, -h4 span, -h5 span, -h6 span { - position: relative; - - display: none; - padding-left: 1em; - line-height: 0; - vertical-align: baseline; - font-size: 10px; -} - -h1 span { top: -1.3em; } -h2 span { top: -1.2em; } -h3 span { top: -1.0em; } -h4 span { top: -0.8em; } -h5 span { top: -0.5em; } -h6 span { top: -0.5em; } - -h1:hover span, -h2:hover span, -h3:hover span, -h4:hover span, -h5:hover span, -h6:hover span { - display: inline; -} - -h1:target, -h2:target, -h3:target, -h4:target, -h5:target, -h6:target { - margin-left: -10px; - border-left: 10px solid var(--border-color); - scroll-margin-top: 1rem; -} - -main .anchor-link:target { - scroll-margin-top: 1rem; -} - -/* 4. Links */ -a { - color: var(--link-color); - transition: color 0.3s ease; -} - -a:hover { - color: var(--link-hover-color); -} - -a code:hover { - color: var(--link-hover-color); -} - -/* 5. Code and Pre */ -code, -pre { - font-family: var(--font-code); - background-color: var(--code-block-background-color); - border: 1px solid var(--border-color); - border-radius: 6px; - padding: 16px; - overflow-x: auto; - font-size: 15px; - line-height: 1.5; - margin: 1em 0; -} - -code { - background-color: var(--code-block-background-color); - padding: 0.1em 0.3em; - border-radius: 3px; - font-size: 85%; -} - -/* Tables */ -table { - margin: 0; - border-spacing: 0; - border-collapse: collapse; -} - -table tr th, table tr td { - padding: 0.2em 0.4em; - border: 1px solid var(--border-color); -} - -table tr th { - background-color: var(--table-header-background-color); -} - -table tr:nth-child(even) td { - background-color: var(--table-td-background-color); -} - -/* 7. Navigation and Sidebar */ -nav { - font-family: var(--font-heading); - font-size: 16px; - border-right: 1px solid var(--border-color); - position: fixed; - top: 0; - bottom: 0; - left: 0; - width: var(--sidebar-width); - background: var(--background-color); /* It needs an explicit background for toggling narrow screens */ - overflow-y: auto; - z-index: 10; - display: flex; - flex-direction: column; - color: var(--text-color); -} - -nav[hidden] { - display: none; -} - -nav footer { - padding: 1em; - border-top: 1px solid var(--border-color); -} - -nav footer a { - color: var(--secondary-highlight-color); -} - -nav .nav-section { - margin-top: 1em; - padding: 0 1em; -} - -nav h2, nav h3 { - margin: 0 0 0.5em; - padding: 0.5em 0; - color: var(--highlight-color); - border-bottom: 1px solid var(--border-color); -} - -nav h2 { - font-size: 1.2em; -} - -nav h3, -#table-of-contents-navigation { - font-size: 1em; -} - -nav ul, -nav dl, -nav p { - padding: 0; - list-style: none; - margin: 0.5em 0; -} - -nav ul li { - margin-bottom: 0.3em; -} - -nav ul ul { - padding-left: 1em; -} - -nav ul ul ul { - padding-left: 1em; -} - -nav ul ul ul ul { - padding-left: 1em; -} - -nav a { - color: var(--link-color); - text-decoration: none; -} - -nav a:hover { - color: var(--link-hover-color); - text-decoration: underline; -} - -#navigation-toggle { - z-index: 1000; - font-size: 2em; - display: block; - position: fixed; - top: 10px; - left: 20px; - cursor: pointer; -} - -#navigation-toggle[aria-expanded="true"] { - top: 10px; - left: 250px; -} - -nav ul li details { - position: relative; - padding-right: 1.5em; /* Add space for the marker on the right */ -} - -nav ul li details > summary { - list-style: none; /* Remove the default marker */ - position: relative; /* So that the open/close triangle can position itself absolutely inside */ -} - -nav ul li details > summary::-webkit-details-marker { - display: none; /* Removes the default marker, in Safari 18. */ -} - -nav ul li details > summary::after { - content: '▶'; /* Unicode right-pointing triangle */ - position: absolute; - font-size: 0.8em; - bottom: 0.1em; - margin-left: 0.3em; - transition: transform 0.2s ease; -} - -nav ul li details[open] > summary::after { - transform: rotate(90deg); /* Rotate the triangle when open */ -} - -/* 8. Main Content */ -main { - flex: 1; - display: block; - margin: 3em auto; - padding: 0 2em; - max-width: 800px; - font-size: 16px; - line-height: 1.6; - color: var(--text-color); - box-sizing: border-box; -} - -@media (min-width: 1024px) { - main { - margin-left: var(--sidebar-width); - } - - .table-of-contents main { - margin-left: 20em; - } - - #navigation-toggle { - display: none; - } -} - -main h1[class] { - margin-top: 0; - margin-bottom: 1em; - font-size: 2.5em; - color: var(--highlight-color); -} - -main h1, -main h2, -main h3, -main h4, -main h5, -main h6 { - font-family: var(--font-heading); - color: var(--highlight-color); -} - -/* Search */ -#search-section { - padding: 1em; - background-color: var(--background-color); - border-bottom: 1px solid var(--border-color); -} - -#search-field-wrapper { - position: relative; - display: flex; - align-items: center; -} - -#search-field { - width: 100%; - padding: 0.5em 1em 0.5em 2.5em; - border: 1px solid var(--border-color); - border-radius: 20px; - font-size: 14px; - outline: none; - transition: border-color 0.3s ease; - color: var(--text-color); -} - -#search-field:focus { - border-color: var(--highlight-color); -} - -#search-field::placeholder { - color: var(--text-color); -} - -#search-field-wrapper::before { - content: "\1F50D"; - position: absolute; - left: 0.75em; - top: 50%; - transform: translateY(-50%); - font-size: 14px; - color: var(--text-color); - opacity: 0.6; -} - -/* Search Results */ -#search-results { - font-family: var(--font-primary); - font-weight: 300; -} - -#search-results .search-match { - font-family: var(--font-heading); - font-weight: normal; -} - -#search-results .search-selected { - background: var(--code-block-background-color); - border-bottom: 1px solid transparent; -} - -#search-results li { - list-style: none; - border-bottom: 1px solid var(--border-color); - margin-bottom: 0.5em; -} - -#search-results li:last-child { - border-bottom: none; - margin-bottom: 0; -} - -#search-results li p { - padding: 0; - margin: 0.5em; -} - -#search-results .search-namespace { - font-weight: bold; -} - -#search-results li em { - background-color: rgba(224, 108, 117, 0.1); - font-style: normal; -} - -#search-results pre { - margin: 0.5em; - font-family: var(--font-code); -} - -/* Syntax Highlighting - Gruvbox Light Scheme */ - -.ruby-constant { color: #AF3A03; } /* Dark Orange */ -.ruby-keyword { color: #9D0006; } /* Dark Red */ -.ruby-ivar { color: #B57614; } /* Brown */ -.ruby-operator { color: #427B58; } /* Dark Teal */ -.ruby-identifier { color: #076678; } /* Deep Teal */ -.ruby-node { color: #8F3F71; } /* Plum */ -.ruby-comment { color: #928374; font-style: italic; } /* Gray */ -.ruby-regexp { color: #8F3F71; } /* Plum */ -.ruby-value { color: #AF3A03; } /* Dark Orange */ -.ruby-string { color: #79740E; } /* Olive */ - -/* Emphasis */ -em { - text-decoration-color: rgba(52, 48, 64, 0.25); - text-decoration-line: underline; - text-decoration-style: dotted; -} - -strong, -em { - color: var(--highlight-color); - background-color: rgba(255, 111, 97, 0.1); /* Light red background for emphasis */ -} - -/* Paragraphs */ -main p { - line-height: 1.5em; - font-weight: 400; -} - -/* Preformatted Text */ -main pre { - margin: 1.2em 0.5em; - padding: 1em; - font-size: 0.8em; -} - -/* Horizontal Rules */ -main hr { - margin: 1.5em 1em; - border: 2px solid var(--border-color); -} - -/* Blockquotes */ -main blockquote { - margin: 0 2em 1.2em 1.2em; - padding-left: 0.5em; - border-left: 2px solid var(--border-color); -} - -/* Lists */ -main li > p { - margin: 0.5em; -} - -/* Definition Lists */ -main dl { - margin: 1em 0.5em; -} - -main dt { - line-height: 1.5; /* matches `main p` */ - font-weight: bold; -} - -main dl.note-list dt { - margin-right: 1em; - float: left; -} - -main dl.note-list dt:has(+ dt) { - margin-right: 0.25em; -} - -main dl.note-list dt:has(+ dt)::after { - content: ', '; - font-weight: normal; -} - -main dd { - margin: 0 0 1em 1em; -} - -main dd p:first-child { - margin-top: 0; -} - -/* Headers within Main */ -main header h2 { - margin-top: 2em; - border-width: 0; - border-top: 4px solid var(--border-color); - font-size: 130%; -} - -main header h3 { - margin: 2em 0 1.5em; - border-width: 0; - border-top: 3px solid var(--border-color); - font-size: 120%; -} - -/* Utility Classes */ -.hide { display: none !important; } -.initially-hidden { display: none; } - -/* Table of Contents */ -.table-of-contents ul { - margin: 1em; - list-style: none; -} - -.table-of-contents ul ul { - margin-top: 0.25em; -} - -.table-of-contents ul :link, -.table-of-contents ul :visited { - font-size: 16px; -} - -.table-of-contents li { - margin-bottom: 0.25em; -} - -/* Method Details */ -main .method-source-code { - visibility: hidden; - max-height: 0; - overflow: auto; - transition-duration: 200ms; - transition-delay: 0ms; - transition-property: all; - transition-timing-function: ease-in-out; -} - -main .method-source-code pre { - border-color: var(--source-code-toggle-color); -} - -main .method-source-code.active-menu { - visibility: visible; - max-height: 100vh; -} - -main .method-description .method-calls-super { - color: var(--text-color); - font-weight: bold; -} - -main .method-detail { - margin-bottom: 2.5em; -} - -main .method-detail:target { - margin-left: -10px; - border-left: 10px solid var(--border-color); -} - -main .method-header { - display: inline-block; -} - -main .method-heading { - position: relative; - font-family: var(--font-code); - font-size: 110%; - font-weight: bold; -} - -main .method-heading::after { - content: '¶'; - position: absolute; - visibility: hidden; - color: var(--highlight-color); - font-size: 0.5em; -} - -main .method-heading:hover::after { - visibility: visible; -} - -main .method-controls { - line-height: 20px; - float: right; - color: var(--source-code-toggle-color); - cursor: pointer; -} - -main .method-description, -main .aliases { - margin-top: 0.75em; - color: var(--text-color); -} - -main .aliases { - padding-top: 4px; - font-style: italic; - cursor: default; -} - -main .aliases a { - color: var(--secondary-highlight-color); -} - -main .mixin-from { - font-size: 80%; - font-style: italic; - margin-bottom: 0.75em; -} - -main .method-description ul { - margin-left: 1.5em; -} - -main #attribute-method-details .method-detail:hover { - background-color: transparent; - cursor: default; -} - -main .attribute-access-type { - text-transform: uppercase; -} - -/* Responsive Adjustments */ -@media (max-width: 480px) { - nav { - width: 100%; - } - - main { - margin: 1em auto; - padding: 0 1em; - max-width: 100%; - } - - #navigation-toggle { - right: 10px; - left: auto; - } - - #navigation-toggle[aria-expanded="true"] { - left: auto; - } - - table { - display: block; - overflow-x: auto; - white-space: nowrap; - } - - main .method-controls { - margin-top: 10px; - float: none; - } -} diff --git a/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf b/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf deleted file mode 100644 index b49dd43729..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf b/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf deleted file mode 100644 index 7959fef075..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf b/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf deleted file mode 100644 index 839cd589dc..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf b/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf deleted file mode 100644 index bababa09e3..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf b/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf deleted file mode 100644 index dd00982d49..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf b/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf deleted file mode 100644 index 1decfb95af..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/add.png b/lib/rdoc/generator/template/darkfish/images/add.png deleted file mode 100644 index 6332fefea4..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/add.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/arrow_up.png b/lib/rdoc/generator/template/darkfish/images/arrow_up.png deleted file mode 100644 index 1ebb193243..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/arrow_up.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/brick.png b/lib/rdoc/generator/template/darkfish/images/brick.png deleted file mode 100644 index 7851cf34c9..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/brick.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/brick_link.png b/lib/rdoc/generator/template/darkfish/images/brick_link.png deleted file mode 100644 index 9ebf013a23..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/brick_link.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/bug.png b/lib/rdoc/generator/template/darkfish/images/bug.png deleted file mode 100644 index 2d5fb90ec6..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/bug.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/bullet_black.png b/lib/rdoc/generator/template/darkfish/images/bullet_black.png deleted file mode 100644 index 57619706d1..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/bullet_black.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png b/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png deleted file mode 100644 index b47ce55f68..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png b/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png deleted file mode 100644 index 9ab4a89664..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/date.png b/lib/rdoc/generator/template/darkfish/images/date.png deleted file mode 100644 index 783c83357f..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/date.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/delete.png b/lib/rdoc/generator/template/darkfish/images/delete.png deleted file mode 100644 index 08f249365a..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/delete.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/find.png b/lib/rdoc/generator/template/darkfish/images/find.png deleted file mode 100644 index 1547479646..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/find.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif b/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif deleted file mode 100644 index 82290f4833..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png b/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png deleted file mode 100644 index c6473b324e..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/package.png b/lib/rdoc/generator/template/darkfish/images/package.png deleted file mode 100644 index da3c2a2d74..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/package.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/page_green.png b/lib/rdoc/generator/template/darkfish/images/page_green.png deleted file mode 100644 index de8e003f9f..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/page_green.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/page_white_text.png b/lib/rdoc/generator/template/darkfish/images/page_white_text.png deleted file mode 100644 index 813f712f72..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/page_white_text.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/page_white_width.png b/lib/rdoc/generator/template/darkfish/images/page_white_width.png deleted file mode 100644 index 1eb880947d..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/page_white_width.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/plugin.png b/lib/rdoc/generator/template/darkfish/images/plugin.png deleted file mode 100644 index 6187b15aec..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/plugin.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/ruby.png b/lib/rdoc/generator/template/darkfish/images/ruby.png deleted file mode 100644 index f763a16880..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/ruby.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/tag_blue.png b/lib/rdoc/generator/template/darkfish/images/tag_blue.png deleted file mode 100644 index 3f02b5f8f8..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/tag_blue.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/tag_green.png b/lib/rdoc/generator/template/darkfish/images/tag_green.png deleted file mode 100644 index 83ec984bd7..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/tag_green.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/transparent.png b/lib/rdoc/generator/template/darkfish/images/transparent.png deleted file mode 100644 index d665e179ef..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/transparent.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/wrench.png b/lib/rdoc/generator/template/darkfish/images/wrench.png deleted file mode 100644 index 5c8213fef5..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/wrench.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/wrench_orange.png b/lib/rdoc/generator/template/darkfish/images/wrench_orange.png deleted file mode 100644 index 565a9330e0..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/wrench_orange.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/images/zoom.png b/lib/rdoc/generator/template/darkfish/images/zoom.png deleted file mode 100644 index 908612e394..0000000000 Binary files a/lib/rdoc/generator/template/darkfish/images/zoom.png and /dev/null differ diff --git a/lib/rdoc/generator/template/darkfish/index.rhtml b/lib/rdoc/generator/template/darkfish/index.rhtml deleted file mode 100644 index a5c0dd54da..0000000000 --- a/lib/rdoc/generator/template/darkfish/index.rhtml +++ /dev/null @@ -1,23 +0,0 @@ - -<%= render '_sidebar_toggle.rhtml' %> - - - -
-<%- if @options.main_page and - main_page = @files.find { |f| f.full_name == @options.main_page } then %> -<%= main_page.description %> -<%- else -%> -

This is the API documentation for <%= h @title %>. -<%- end -%> -

diff --git a/lib/rdoc/generator/template/darkfish/js/darkfish.js b/lib/rdoc/generator/template/darkfish/js/darkfish.js deleted file mode 100644 index 4c15efde66..0000000000 --- a/lib/rdoc/generator/template/darkfish/js/darkfish.js +++ /dev/null @@ -1,120 +0,0 @@ -/** - * - * Darkfish Page Functions - * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $ - * - * Author: Michael Granger - * - */ - -/* Provide console simulation for firebug-less environments */ -/* -if (!("console" in window) || !("firebug" in console)) { - var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", - "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; - - window.console = {}; - for (var i = 0; i < names.length; ++i) - window.console[names[i]] = function() {}; -}; -*/ - - -function showSource( e ) { - var target = e.target; - while (!target.classList.contains('method-detail')) { - target = target.parentNode; - } - if (typeof target !== "undefined" && target !== null) { - target = target.querySelector('.method-source-code'); - } - if (typeof target !== "undefined" && target !== null) { - target.classList.toggle('active-menu') - } -}; - -function hookSourceViews() { - document.querySelectorAll('.method-source-toggle').forEach(function (codeObject) { - codeObject.addEventListener('click', showSource); - }); -}; - -function hookSearch() { - var input = document.querySelector('#search-field'); - var result = document.querySelector('#search-results'); - result.classList.remove("initially-hidden"); - - var search_section = document.querySelector('#search-section'); - search_section.classList.remove("initially-hidden"); - - var search = new Search(search_data, input, result); - - search.renderItem = function(result) { - var li = document.createElement('li'); - var html = ''; - - // TODO add relative path to >, yield_arg' - @attr = RDoc::Attr.new nil, 'attr', 'RW', '' - - @klass.add_method @meth - @klass.add_method @meth_bang - @klass.add_method @meth_with_html_tag_yield - @klass.add_attribute @attr - - @ignored = @top_level.add_class RDoc::NormalClass, 'Ignored' - @ignored.ignore - - @store.complete :private - - @object = @store.find_class_or_module 'Object' - @klass_alias = @store.find_class_or_module 'Klass::A' - end - - def teardown - super - - $LOAD_PATH.shift - Dir.chdir @pwd - FileUtils.rm_rf @tmpdir - end - - def test_generate - top_level = @store.add_file 'file.rb' - top_level.add_class @klass.class, @klass.name - @klass.add_class RDoc::NormalClass, 'Inner' - @klass.add_comment <<~RDOC, top_level - = Heading 1 - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod - == Heading 1.1 - tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, - === Heading 1.1.1 - quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo - ==== Heading 1.1.1.1 - consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse - == Heading 1.2 - cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat - == Heading 1.3 - non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. - === Heading 1.3.1 - etc etc... - RDOC - - @g.generate - - assert_file 'index.html' - assert_file 'Object.html' - assert_file 'Klass.html' - assert_file 'Klass/Inner.html' - assert_file 'table_of_contents.html' - assert_file 'js/search_index.js' - - assert_hard_link 'css/rdoc.css' - assert_hard_link 'css/fonts.css' - - assert_hard_link 'fonts/SourceCodePro-Bold.ttf' - assert_hard_link 'fonts/SourceCodePro-Regular.ttf' - - encoding = Regexp.escape Encoding::UTF_8.name - - assert_match %r%%, File.binread('index.html') - assert_match %r%%, File.binread('Object.html') - - refute_match(/Ignored/, File.binread('index.html')) - summary = File.binread('index.html')[%r[.*]m] - assert_match(%r[Klass/Inner\.html".*>Inner<], summary) - - klass = File.binread('Klass.html') - klassnav = klass[%r[