From aa45e72407f7e0da35cdf890f5bad73da2284ece Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Jan 2025 22:50:41 +0900 Subject: [PATCH 1/2] [DOC] Add config files for RDoc --- .document | 4 ++++ .rdoc_options | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 .document create mode 100644 .rdoc_options diff --git a/.document b/.document new file mode 100644 index 0000000..e2b9569 --- /dev/null +++ b/.document @@ -0,0 +1,4 @@ +BSDL +COPYING +README.md +lib/ diff --git a/.rdoc_options b/.rdoc_options new file mode 100644 index 0000000..b1f9cda --- /dev/null +++ b/.rdoc_options @@ -0,0 +1,4 @@ +main_page: README.md +op_dir: _site +warn_missing_rdoc_ref: true +title: URI Documentation From fe7aa3dac2b3415758635a616ce44afb15bf4900 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Jan 2025 22:55:31 +0900 Subject: [PATCH 2/2] [DOC] Make documentation 100% --- .document | 1 + docs/kernel.rb | 2 ++ lib/uri/common.rb | 10 +++++++--- lib/uri/generic.rb | 8 +++++--- lib/uri/rfc2396_parser.rb | 12 ++++++------ 5 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 docs/kernel.rb diff --git a/.document b/.document index e2b9569..1d07bdf 100644 --- a/.document +++ b/.document @@ -1,4 +1,5 @@ BSDL COPYING README.md +docs/ lib/ diff --git a/docs/kernel.rb b/docs/kernel.rb new file mode 100644 index 0000000..68ed335 --- /dev/null +++ b/docs/kernel.rb @@ -0,0 +1,2 @@ +# :stopdoc: +module Kernel end diff --git a/lib/uri/common.rb b/lib/uri/common.rb index c3fe0b4..bf28dea 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -13,15 +13,19 @@ require_relative "rfc3986_parser" module URI + # The default parser instance for RFC 2396. RFC2396_PARSER = RFC2396_Parser.new Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor) + # The default parser instance for RFC 3986. RFC3986_PARSER = RFC3986_Parser.new Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor) + # The default parser instance. DEFAULT_PARSER = RFC3986_PARSER Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor) + # Set the default parser instance. def self.parser=(parser = RFC3986_PARSER) remove_const(:Parser) if defined?(::URI::Parser) const_set("Parser", parser.class) @@ -40,7 +44,7 @@ def self.parser=(parser = RFC3986_PARSER) end self.parser = RFC3986_PARSER - def self.const_missing(const) + def self.const_missing(const) # :nodoc: if const == :REGEXP warn "URI::REGEXP is obsolete. Use URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE URI::RFC2396_REGEXP @@ -87,7 +91,7 @@ def make_components_hash(klass, array_hash) module_function :make_components_hash end - module Schemes + module Schemes # :nodoc: end private_constant :Schemes @@ -305,7 +309,7 @@ def self.regexp(schemes = nil)# :nodoc: 256.times do |i| TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i) end - TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze + TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze # :nodoc: TBLENCWWWCOMP_[' '] = '+' TBLENCWWWCOMP_.freeze TBLDECWWWCOMP_ = {} # :nodoc: diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index d4bfa3b..f5cdb73 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -737,12 +737,12 @@ def check_registry(v) # :nodoc: end private :check_registry - def set_registry(v) #:nodoc: + def set_registry(v) # :nodoc: raise InvalidURIError, "cannot set registry" end protected :set_registry - def registry=(v) + def registry=(v) # :nodoc: raise InvalidURIError, "cannot set registry" end @@ -1392,10 +1392,12 @@ def ==(oth) end end + # Returns the hash value. def hash self.component_ary.hash end + # Compares with _oth_ for Hash. def eql?(oth) self.class == oth.class && parser == oth.parser && @@ -1438,7 +1440,7 @@ def select(*components) end end - def inspect + def inspect # :nodoc: "#<#{self.class} #{self}>" end diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index 0336366..75a2d2d 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -321,14 +321,14 @@ def unescape(str, escaped = @regexp[:ESCAPED]) str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) } end - @@to_s = Kernel.instance_method(:to_s) - if @@to_s.respond_to?(:bind_call) - def inspect - @@to_s.bind_call(self) + TO_S = Kernel.instance_method(:to_s) # :nodoc: + if TO_S.respond_to?(:bind_call) + def inspect # :nodoc: + TO_S.bind_call(self) end else - def inspect - @@to_s.bind(self).call + def inspect # :nodoc: + TO_S.bind(self).call end end