diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml index 72fcbe69964ab1..4b0da6a0fe9c9a 100644 --- a/.github/workflows/check_misc.yml +++ b/.github/workflows/check_misc.yml @@ -64,8 +64,11 @@ jobs: - name: Generate docs id: docs run: | - ruby -W0 --disable-gems tool/rdoc-srcdir -q --op html . + $RDOC -C -x ^ext -x ^lib . + $RDOC --op html . echo htmlout=ruby-html-${GITHUB_SHA:0:10} >> $GITHUB_OUTPUT + env: + RDOC: ruby -W0 --disable-gems tool/rdoc-srcdir -q # Generate only when document commit/PR if: >- ${{false diff --git a/.rdoc_options b/.rdoc_options index 27d35e2f58b97f..02cf1f00d8771b 100644 --- a/.rdoc_options +++ b/.rdoc_options @@ -9,7 +9,6 @@ rdoc_include: - doc exclude: -- \Alib/irb - \.gemspec\z autolink_excluded_words: diff --git a/common.mk b/common.mk index b5a4526ccce8f5..f362948593e1d9 100644 --- a/common.mk +++ b/common.mk @@ -697,10 +697,10 @@ html: PHONY main srcs-doc rdoc-coverage: PHONY main srcs-doc @echo Generating RDoc coverage report - $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) "$(srcdir)" + $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) . undocumented: PHONY main srcs-doc - $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) "$(srcdir)" | \ + $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) . | \ sed -n \ -e '/^ *# in file /{' -e 's///;N;s/\n/: /p' -e '}' \ -e 's/^ *\(.*[^ ]\) *# in file \(.*\)/\2: \1/p' | sort diff --git a/encoding.c b/encoding.c index 3be39d8e0965b9..7bca8d1b2b3d38 100644 --- a/encoding.c +++ b/encoding.c @@ -1988,6 +1988,7 @@ Init_unicode_version(void) VALUE str = rb_usascii_str_new_static(onigenc_unicode_version_string, strlen(onigenc_unicode_version_string)); OBJ_FREEZE(str); + /* The supported Unicode version. */ rb_define_const(rb_cEncoding, "UNICODE_VERSION", str); } diff --git a/error.c b/error.c index d3aeec54d8b97c..e14ecd2393dcb6 100644 --- a/error.c +++ b/error.c @@ -3499,6 +3499,18 @@ syserr_eqq(VALUE self, VALUE exc) * incompatible with the target encoding. */ +/* + * Document-class: NoMatchingPatternError + * + * Raised when matching pattern not found. + */ + +/* + * Document-class: NoMatchingPatternKeyError + * + * Raised when matching key not found. + */ + /* * Document-class: fatal * diff --git a/lib/optparse.rb b/lib/optparse.rb index 332aea2148f696..23b4844b2c687a 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -2047,19 +2047,21 @@ def candidate(word) def load(filename = nil, **keywords) unless filename basename = File.basename($0, '.*') - return true if load(File.expand_path(basename, '~/.options'), **keywords) rescue nil + return true if load(File.expand_path("~/.options/#{basename}"), **keywords) rescue nil basename << ".options" return [ # XDG ENV['XDG_CONFIG_HOME'], - '~/.config', + ['~/.config', true], *ENV['XDG_CONFIG_DIRS']&.split(File::PATH_SEPARATOR), # Haiku - '~/config/settings', - ].any? {|dir| + ['~/config/settings', true], + ].any? {|dir, expand| next if !dir or dir.empty? - load(File.expand_path(basename, dir), **keywords) rescue nil + filename = File.join(dir, basename) + filename = File.expand_path(filename) if expand + load(filename, **keywords) rescue nil } end begin diff --git a/namespace.c b/namespace.c index e6675908903c92..55b7580c72e3ab 100644 --- a/namespace.c +++ b/namespace.c @@ -411,6 +411,12 @@ rb_get_namespace_object(rb_namespace_t *ns) static void setup_pushing_loading_namespace(rb_namespace_t *ns); +/* + * call-seq: + * Namespace.new -> new_namespace + * + * Returns a new Namespace object. + */ static VALUE namespace_initialize(VALUE namespace) { @@ -450,12 +456,26 @@ namespace_initialize(VALUE namespace) return namespace; } +/* + * call-seq: + * Namespace.enabled? -> true or false + * + * Returns +true+ if namespace is enabled. + */ static VALUE rb_namespace_s_getenabled(VALUE namespace) { return RBOOL(rb_namespace_available()); } +/* + * call-seq: + * Namespace.current -> namespace, nil or false + * + * Returns the current namespace. + * Returns +nil+ if it is the built-in namespace. + * Returns +false+ if namespace is not enabled. + */ static VALUE rb_namespace_current(VALUE klass) { @@ -469,6 +489,12 @@ rb_namespace_current(VALUE klass) return Qfalse; } +/* + * call-seq: + * Namespace.is_builtin?(klass) -> true or false + * + * Returns +true+ if +klass+ is only in a user namespace. + */ static VALUE rb_namespace_s_is_builtin_p(VALUE namespace, VALUE klass) { @@ -477,6 +503,12 @@ rb_namespace_s_is_builtin_p(VALUE namespace, VALUE klass) return Qfalse; } +/* + * call-seq: + * load_path -> array + * + * Returns namespace local load path. + */ static VALUE rb_namespace_load_path(VALUE namespace) { @@ -1048,6 +1080,13 @@ Init_enable_namespace(void) } } +/* + * Document-class: Namespace + * + * Namespace is designed to provide separated spaces in a Ruby + * process, to isolate applications and libraries. + * See {Namespace}[rdoc-ref:namespace.md]. + */ void Init_Namespace(void) { @@ -1057,14 +1096,17 @@ Init_Namespace(void) rb_cNamespace = rb_define_class("Namespace", rb_cModule); rb_define_method(rb_cNamespace, "initialize", namespace_initialize, 0); + /* :nodoc: */ rb_cNamespaceEntry = rb_define_class_under(rb_cNamespace, "Entry", rb_cObject); rb_define_alloc_func(rb_cNamespaceEntry, rb_namespace_entry_alloc); + /* :nodoc: */ rb_mNamespaceRefiner = rb_define_module_under(rb_cNamespace, "Refiner"); if (rb_namespace_available()) { setup_builtin_refinement(rb_mNamespaceRefiner); } + /* :nodoc: */ rb_mNamespaceLoader = rb_define_module_under(rb_cNamespace, "Loader"); namespace_define_loader_method("require"); namespace_define_loader_method("require_relative"); diff --git a/pathname_builtin.rb b/pathname_builtin.rb index 17ec1557040f96..95bd8d0e3a6462 100644 --- a/pathname_builtin.rb +++ b/pathname_builtin.rb @@ -12,6 +12,7 @@ class Pathname + # The version string. VERSION = "0.4.0" # :stopdoc: @@ -36,9 +37,9 @@ class Pathname end if File.dirname('A:') == 'A:.' # DOSish drive letter - ABSOLUTE_PATH = /\A(?:[A-Za-z]:|#{SEPARATOR_PAT})/o + ABSOLUTE_PATH = /\A(?:[A-Za-z]:|#{SEPARATOR_PAT})/ else - ABSOLUTE_PATH = /\A#{SEPARATOR_PAT}/o + ABSOLUTE_PATH = /\A#{SEPARATOR_PAT}/ end private_constant :ABSOLUTE_PATH diff --git a/prelude.rb b/prelude.rb index f49cada637968e..36da381804e6a7 100644 --- a/prelude.rb +++ b/prelude.rb @@ -15,15 +15,17 @@ def irb(...) end module Kernel + # :stopdoc: def pp(*objs) require 'pp' pp(*objs) end # suppress redefinition warning - alias pp pp # :nodoc: + alias pp pp private :pp + # :startdoc: end module Enumerable diff --git a/proc.c b/proc.c index 85431104761512..68f63040b7cf0f 100644 --- a/proc.c +++ b/proc.c @@ -2026,6 +2026,12 @@ method_owner(VALUE obj) return data->owner; } +/* + * call-see: + * meth.namespace -> namespace or nil + * + * Returns the namespace where +meth+ is defined in. + */ static VALUE method_namespace(VALUE obj) { diff --git a/ractor.c b/ractor.c index 721234a98bde2f..a46eb00685d4a4 100644 --- a/ractor.c +++ b/ractor.c @@ -874,6 +874,12 @@ ractor_moved_missing(int argc, VALUE *argv, VALUE self) rb_raise(rb_eRactorMovedError, "can not send any methods to a moved object"); } +/* + * Document-class: Ractor::Error + * + * The parent class of Ractor-related error classes. + */ + /* * Document-class: Ractor::ClosedError * @@ -911,6 +917,13 @@ ractor_moved_missing(int argc, VALUE *argv, VALUE self) * Continue successfully */ +/* + * Document-class: Ractor::IsolationError + * + * Raised on attempt to make a Ractor-unshareable object + * Ractor-shareable. + */ + /* * Document-class: Ractor::RemoteError * @@ -960,6 +973,12 @@ ractor_moved_missing(int argc, VALUE *argv, VALUE self) * # Ractor::MovedError (can not send any methods to a moved object) */ +/* + * Document-class: Ractor::UnsafeError + * + * Raised when Ractor-unsafe C-methods is invoked by a non-main Ractor. + */ + // Main docs are in ractor.rb, but without this clause there are weird artifacts // in their rendering. /* diff --git a/ractor.rb b/ractor.rb index ee6135b81e5841..5827f6672b99c3 100644 --- a/ractor.rb +++ b/ractor.rb @@ -612,6 +612,7 @@ def unmonitor port __builtin_ractor_unmonitor(port) end + # \Port objects transmit messages between Ractors. class Port # # call-seq: diff --git a/ractor_sync.c b/ractor_sync.c index 8437516bfb5c05..a3ed38295b29c6 100644 --- a/ractor_sync.c +++ b/ractor_sync.c @@ -91,12 +91,19 @@ ractor_port_init(VALUE rpv, rb_ractor_t *r) return rpv; } +/* + * call-seq: + * Ractor::Port.new -> new_port + * + * Returns a new Ractor::Port object. + */ static VALUE ractor_port_initialzie(VALUE self) { return ractor_port_init(self, GET_RACTOR()); } +/* :nodoc: */ static VALUE ractor_port_initialzie_copy(VALUE self, VALUE orig) { diff --git a/re.c b/re.c index b47538d59415dc..9348622eea2936 100644 --- a/re.c +++ b/re.c @@ -4855,6 +4855,7 @@ Init_Regexp(void) rb_define_method(rb_cRegexp, "named_captures", rb_reg_named_captures, 0); rb_define_method(rb_cRegexp, "timeout", rb_reg_timeout_get, 0); + /* Raised when regexp matching timed out. */ rb_eRegexpTimeoutError = rb_define_class_under(rb_cRegexp, "TimeoutError", rb_eRegexpError); rb_define_singleton_method(rb_cRegexp, "timeout", rb_reg_s_timeout_get, 0); rb_define_singleton_method(rb_cRegexp, "timeout=", rb_reg_s_timeout_set, 1); diff --git a/scheduler.c b/scheduler.c index 83b9681cc34a25..ddb205da885cee 100644 --- a/scheduler.c +++ b/scheduler.c @@ -798,7 +798,7 @@ rb_fiber_scheduler_io_read(VALUE scheduler, VALUE io, VALUE buffer, size_t lengt } /* - * Document-method: Fiber::Scheduler#io_read + * Document-method: Fiber::Scheduler#io_pread * call-seq: io_pread(io, buffer, from, length, offset) -> read length or -errno * * Invoked by IO#pread or IO::Buffer#pread to read +length+ bytes from +io+ @@ -837,7 +837,7 @@ rb_fiber_scheduler_io_pread(VALUE scheduler, VALUE io, rb_off_t from, VALUE buff } /* - * Document-method: Scheduler#io_write + * Document-method: Fiber::Scheduler#io_write * call-seq: io_write(io, buffer, length, offset) -> written length or -errno * * Invoked by IO#write or IO::Buffer#write to write +length+ bytes to +io+ from diff --git a/set.c b/set.c index 61f1fd8bc43d1b..f83fb0880ca951 100644 --- a/set.c +++ b/set.c @@ -406,6 +406,13 @@ set_s_alloc(VALUE klass) return set_alloc_with_size(klass, 0); } +/* + * call-seq: + * Set[*objects] -> new_set + * + * Returns a new Set object populated with the given objects, + * See Set::new. + */ static VALUE set_s_create(int argc, VALUE *argv, VALUE klass) { @@ -522,6 +529,7 @@ set_i_initialize(int argc, VALUE *argv, VALUE set) return set; } +/* :nodoc: */ static VALUE set_i_initialize_copy(VALUE set, VALUE other) { diff --git a/test/optparse/test_load.rb b/test/optparse/test_load.rb index 0ebe855682a6c4..8c835032ba2811 100644 --- a/test/optparse/test_load.rb +++ b/test/optparse/test_load.rb @@ -31,7 +31,13 @@ def assert_load(result) assert_equal({test: result}, into) end + def assert_load_nothing + assert !new_parser.load + assert_nil @result + end + def setup_options(env, dir, suffix = nil) + env.update({'HOME'=>@tmpdir}) optdir = File.join(@tmpdir, dir) FileUtils.mkdir_p(optdir) file = File.join(optdir, [@basename, suffix].join("")) @@ -50,7 +56,7 @@ def setup_options(env, dir, suffix = nil) end def setup_options_home(&block) - setup_options({'HOME'=>@tmpdir}, ".options", &block) + setup_options({}, ".options", &block) end def setup_options_xdg_config_home(&block) @@ -58,7 +64,7 @@ def setup_options_xdg_config_home(&block) end def setup_options_home_config(&block) - setup_options({'HOME'=>@tmpdir}, ".config", ".options", &block) + setup_options({}, ".config", ".options", &block) end def setup_options_xdg_config_dirs(&block) @@ -66,7 +72,11 @@ def setup_options_xdg_config_dirs(&block) end def setup_options_home_config_settings(&block) - setup_options({'HOME'=>@tmpdir}, "config/settings", ".options", &block) + setup_options({}, "config/settings", ".options", &block) + end + + def setup_options_home_options(envname, &block) + setup_options({envname => '~/options'}, "options", ".options", &block) end def test_load_home_options @@ -135,7 +145,34 @@ def test_load_home_config_settings end def test_load_nothing - assert !new_parser.load - assert_nil @result + setup_options({}, "") do + assert_load_nothing + end + end + + def test_not_expand_path_basename + basename = @basename + @basename = "~" + $test_optparse_basename = "/" + @basename + alias $test_optparse_prog $0 + alias $0 $test_optparse_basename + setup_options({'HOME'=>@tmpdir+"/~options"}, "", "options") do + assert_load_nothing + end + ensure + alias $0 $test_optparse_prog + @basename = basename + end + + def test_not_expand_path_xdg_config_home + setup_options_home_options('XDG_CONFIG_HOME') do + assert_load_nothing + end + end + + def test_not_expand_path_xdg_config_dirs + setup_options_home_options('XDG_CONFIG_DIRS') do + assert_load_nothing + end end end diff --git a/win32/mkexports.rb b/win32/mkexports.rb index 97939cdd093436..1a9f474be28826 100755 --- a/win32/mkexports.rb +++ b/win32/mkexports.rb @@ -146,9 +146,7 @@ def exports(*) end def each_line(objs, &block) - IO.popen(%W[#{self.class.nm} --extern-only --defined-only] + objs) do |f| - f.each(&block) - end + IO.foreach("|#{self.class.nm} --extern-only --defined-only #{objs.join(' ')}", &block) end def each_export(objs)