Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ updates:
directories:
- '/yjit'
- '/zjit'
exclude-paths:
- 'gc/mmtk/**'
schedule:
interval: 'daily'
groups:
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ releases.
* resolv-replace 0.2.0
* syslog 0.4.0
* repl_type_completor 0.1.13
* rdoc 7.1.0
* rdoc 7.2.0
* irb 1.17.0

### RubyGems and Bundler

Expand Down
30 changes: 15 additions & 15 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -6747,16 +6747,16 @@ flatten(VALUE ary, int level)
* With non-negative integer argument +depth+, flattens recursively through +depth+ levels:
*
* a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ]
* a # => [0, [1, [2, 3], 4], 5, {:foo=>0}, #<Set: {6, 7}>]
* a.dup.flatten!(1) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a.dup.flatten!(1.1) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a.dup.flatten!(2) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a.dup.flatten!(3) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
* a.dup.flatten!(1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
* a.dup.flatten!(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
* a.dup.flatten!(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
* a.dup.flatten!(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
*
* With +nil+ or negative argument +depth+, flattens all levels:
*
* a.dup.flatten! # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a.dup.flatten!(-1) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a.dup.flatten! # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
* a.dup.flatten!(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
*
* Related: Array#flatten;
* see also {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
Expand Down Expand Up @@ -6803,17 +6803,17 @@ rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary)
* With non-negative integer argument +depth+, flattens recursively through +depth+ levels:
*
* a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ]
* a # => [0, [1, [2, 3], 4], 5, {:foo=>0}, #<Set: {6, 7}>]
* a.flatten(0) # => [0, [1, [2, 3], 4], 5, {:foo=>0}, #<Set: {6, 7}>]
* a.flatten(1 ) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a.flatten(1.1) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a.flatten(2) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a.flatten(3) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
* a.flatten(0) # => [0, [1, [2, 3], 4], 5, {foo: 0}, #<Set: {6, 7}>]
* a.flatten(1 ) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
* a.flatten(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #<Set: {6, 7}>]
* a.flatten(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
* a.flatten(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
*
* With +nil+ or negative +depth+, flattens all levels.
*
* a.flatten # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a.flatten(-1) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #<Set: {6, 7}>]
* a.flatten # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
* a.flatten(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #<Set: {6, 7}>]
*
* Related: Array#flatten!;
* see also {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
Expand Down
64 changes: 34 additions & 30 deletions doc/contributing/documentation_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ in the Ruby core and in the Ruby standard library.

## Generating documentation

Most Ruby documentation lives in the source files and is written in
[RDoc format](https://ruby.github.io/rdoc/RDoc/MarkupReference.html).
Most Ruby documentation lives in the source files, and is written in RDoc format
(described in the [RDoc Markup Reference]).

Some pages live under the `doc` folder and can be written in either
`.rdoc` or `.md` format, determined by the file extension.
Expand Down Expand Up @@ -43,14 +43,12 @@ Use your judgment about what the user needs to know.
- Write short declarative or imperative sentences.
- Group sentences into (ideally short) paragraphs,
each covering a single topic.
- Organize material with
[headings].
- Refer to authoritative and relevant sources using
[links](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Links).
- Organize material with [headings].
- Refer to authoritative and relevant sources using [links].
- Use simple verb tenses: simple present, simple past, simple future.
- Use simple sentence structure, not compound or complex structure.
- Avoid:
- Excessive comma-separated phrases; consider a [list].
- Excessive comma-separated phrases; consider a [list][lists].
- Idioms and culture-specific references.
- Overuse of headings.
- Using US-ASCII-incompatible characters in C source files;
Expand Down Expand Up @@ -105,16 +103,16 @@ involving new files `doc/*.rdoc`:
*/
```

### \RDoc
### RDoc

Ruby is documented using RDoc.
For information on \RDoc syntax and features, see the
[RDoc Markup Reference](https://ruby.github.io/rdoc/RDoc/MarkupReference.html).
For information on RDoc syntax and features,
see the [RDoc Markup Reference].

### Output from `irb`

For code examples, consider using interactive Ruby,
[irb](https://ruby-doc.org/stdlib/libdoc/irb/rdoc/IRB.html).
[irb].

For a code example that includes `irb` output,
consider aligning `# => ...` in successive lines.
Expand All @@ -133,16 +131,15 @@ Organize a long discussion for a class or module with [headings].
Do not use formal headings in the documentation for a method or constant.

In the rare case where heading-like structures are needed
within the documentation for a method or constant, use
[bold text](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Bold)
as pseudo-headings.
within the documentation for a method or constant,
use [bold text] as pseudo-headings.

### Blank Lines

A blank line begins a new paragraph.

A [code block](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Code+Blocks)
or [list] should be preceded by and followed by a blank line.
A [code block][code blocks]
or [list][lists] should be preceded by and followed by a blank line.
This is unnecessary for the HTML output, but helps in the `ri` output.

### \Method Names
Expand Down Expand Up @@ -185,7 +182,7 @@ renders as:
> - File.new
> - File#read.

In general, \RDoc's auto-linking should not be suppressed.
In general, RDoc's auto-linking should not be suppressed.
For example, we should write just plain _Float_ (which is auto-linked):

```rdoc
Expand Down Expand Up @@ -312,10 +309,9 @@ In particular, avoid building tables with HTML tags

Alternatives:

- A {verbatim text block}[https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Verbatim+Text+Blocks],
- A [verbatim text block][verbatim text blocks],
using spaces and punctuation to format the text;
note that {text markup}[https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Text+Markup]
will not be honored:
note that [text markup][text markup] will not be honored:

- Example {source}[https://github.com/ruby/ruby/blob/34d802f32f00df1ac0220b62f72605827c16bad8/file.c#L6570-L6596].
- Corresponding {output}[rdoc-ref:File@ReadWrite+Mode].
Expand Down Expand Up @@ -374,9 +370,9 @@ Guidelines:
and a short description.
- If the method has aliases, mention them in parentheses before the colon
(and do not list the aliases separately).
- Check the rendered documentation to determine whether \RDoc has recognized
- Check the rendered documentation to determine whether RDoc has recognized
the method and linked to it; if not, manually insert a
[link](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Links).
[link][links].

- If there are numerous entries, consider grouping them into subsections with headings.
- If there are more than a few such subsections,
Expand All @@ -398,11 +394,11 @@ The general structure of the method documentation should be:

### Calling Sequence (for methods written in C)

For methods written in Ruby, \RDoc documents the calling sequence automatically.
For methods written in Ruby, RDoc documents the calling sequence automatically.

For methods written in C, \RDoc cannot determine what arguments
the method accepts, so those need to be documented using \RDoc directive
[`call-seq:`](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Directives+for+Method+Documentation).
For methods written in C, RDoc cannot determine what arguments
the method accepts, so those need to be documented using RDoc directive
[`call-seq:`][call-seq]

For a singleton method, use the form:

Expand Down Expand Up @@ -577,7 +573,7 @@ argument passed if it is not obvious, not explicitly mentioned in the
details, and not implicitly shown in the examples.

If there is more than one argument or block argument, use a
[labeled list](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Labeled+Lists).
[labeled list][lists].

### Corner Cases and Exceptions

Expand Down Expand Up @@ -618,6 +614,14 @@ For methods that accept multiple argument types, in some cases it can
be useful to document the different argument types separately. It's
best to use a separate paragraph for each case you are discussing.

[headings]: https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Headings
[list]: https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Lists
[monofont]: https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Monofont
[bold text]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#bold
[call-seq]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#directive-for-specifying-rdoc-source-format
[code blocks]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#code-blocks
[headings]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#headings
[irb]: https://ruby.github.io/irb/index.html
[links]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#links
[lists]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#lists
[monofont]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#monofont
[RDoc Markup Reference]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html
[text markup]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#text-markup
[verbatim text blocks]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#verbatim-text-blocks
5 changes: 4 additions & 1 deletion doc/jit/yjit.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ git clone https://github.com/ruby/ruby yjit
cd yjit
```

The YJIT `ruby` binary can be built with either GCC or Clang. It can be built either in dev (debug) mode or in release mode. For maximum performance, compile YJIT in release mode with GCC. More detailed build instructions are provided in the [Ruby README](https://github.com/ruby/ruby#how-to-build).
The YJIT `ruby` binary can be built with either GCC or Clang.
It can be built either in dev (debug) mode or in release mode.
For maximum performance, compile YJIT in release mode with GCC.
See [Building Ruby](rdoc-ref:./contributing/building_ruby_md.html#building-ruby).

```sh
# Configure in release mode for maximum performance, build and install
Expand Down
4 changes: 2 additions & 2 deletions gems/bundled_gems
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ ostruct 0.6.3 https://github.com/ruby/ostruct
pstore 0.2.0 https://github.com/ruby/pstore
benchmark 0.5.0 https://github.com/ruby/benchmark
logger 1.7.0 https://github.com/ruby/logger
rdoc 7.1.0 https://github.com/ruby/rdoc
rdoc 7.2.0 https://github.com/ruby/rdoc
win32ole 1.9.2 https://github.com/ruby/win32ole
irb 1.16.0 https://github.com/ruby/irb
irb 1.17.0 https://github.com/ruby/irb
reline 0.6.3 https://github.com/ruby/reline
readline 0.0.4 https://github.com/ruby/readline
fiddle 1.1.8 https://github.com/ruby/fiddle
Expand Down
12 changes: 11 additions & 1 deletion ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,16 @@ process_options_global_setup(const ruby_cmdline_options_t *opt, const rb_iseq_t
rb_exec_event_hook_script_compiled(ec, iseq, script);
}

static bool
has_dir_sep(const char *path)
{
if (strchr(path, '/')) return true;
#ifdef _WIN32
if (strchr(path, '\\')) return true;
#endif
return false;
}

static VALUE
process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
{
Expand Down Expand Up @@ -2406,7 +2416,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
if (!opt->script || opt->script[0] == '\0') {
opt->script = "-";
}
else if (opt->do_search) {
else if (opt->do_search && !has_dir_sep(opt->script)) {
const char *path = getenv("RUBYPATH");

opt->script = 0;
Expand Down
40 changes: 39 additions & 1 deletion spec/ruby/command_line/dash_upper_s_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,66 @@

describe 'The -S command line option' do
before :each do
@path = [ENV['PATH'], fixture(__FILE__, "bin")].join(':')
@bin = fixture(__FILE__, "bin")
@path = [ENV['PATH'], @bin].join(File::PATH_SEPARATOR)
end

platform_is_not :windows do
# On VirtualBox shared directory (vboxsf) all files are world writable
# and MRI shows warning when including world writable path in ENV['PATH'].
# This is why we are using /success$/ matching in the following cases.

it "runs launcher found in RUBYPATH, but only code after the first /\#!.*ruby.*/-ish line in target file" do
result = ruby_exe(nil, options: '-S hybrid_launcher.sh', env: { 'RUBYPATH' => @bin }, args: '2>&1')
result.should =~ /success$/
end

it "runs launcher found in PATH, but only code after the first /\#!.*ruby.*/-ish line in target file" do
result = ruby_exe(nil, options: '-S hybrid_launcher.sh', env: { 'PATH' => @path }, args: '2>&1')
result.should =~ /success$/
end

it "runs launcher found in RUBYPATH" do
result = ruby_exe(nil, options: '-S launcher.rb', env: { 'RUBYPATH' => @bin }, args: '2>&1')
result.should =~ /success$/
end

it "runs launcher found in PATH" do
result = ruby_exe(nil, options: '-S launcher.rb', env: { 'PATH' => @path }, args: '2>&1')
result.should =~ /success$/
end

it "runs launcher found in RUBYPATH and sets the exit status to 1 if it fails" do
result = ruby_exe(nil, options: '-S dash_s_fail', env: { 'RUBYPATH' => @bin }, args: '2>&1', exit_status: 1)
result.should =~ /\bdie\b/
$?.exitstatus.should == 1
end

it "runs launcher found in PATH and sets the exit status to 1 if it fails" do
result = ruby_exe(nil, options: '-S dash_s_fail', env: { 'PATH' => @path }, args: '2>&1', exit_status: 1)
result.should =~ /\bdie\b/
$?.exitstatus.should == 1
end

ruby_version_is "4.1" do
describe "if the script name contains separator" do
before(:each) do
@bin = File.dirname(@bin)
@path = [ENV['PATH'], @bin].join(File::PATH_SEPARATOR)
end

it "does not search launcher in RUBYPATH" do
result = ruby_exe(nil, options: '-S bin/launcher.rb', env: { 'RUBYPATH' => @bin }, args: '2>&1', exit_status: 1)
result.should =~ /LoadError/
$?.should_not.success?
end

it "does not search launcher in PATH" do
result = ruby_exe(nil, options: '-S bin/launcher.rb', env: { 'PATH' => @path }, args: '2>&1', exit_status: 1)
result.should =~ /LoadError/
$?.should_not.success?
end
end
end
end
end
2 changes: 1 addition & 1 deletion test/ruby/test_require.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_require_too_long_filename
end;

begin
assert_in_out_err(["-S", "-w", "foo/" * 1024 + "foo"], "") do |r, e|
assert_in_out_err(["-S", "-w", (["foo"] * 1025).join("_")], "") do |r, e|
assert_equal([], r)
assert_operator(2, :<=, e.size)
assert_match(/warning: openpath: pathname too long \(ignored\)/, e.first)
Expand Down
33 changes: 12 additions & 21 deletions test/ruby/test_rubyoptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,37 +446,28 @@ def test_rubyopt
def test_search
rubypath_orig = ENV['RUBYPATH']
path_orig = ENV['PATH']
libpath = (path_orig if path_orig && RbConfig::CONFIG['LIBPATHENV'] == 'PATH')

Tempfile.create(["test_ruby_test_rubyoption", ".rb"]) {|t|
t.puts "p 1"
t.close

@verbose = $VERBOSE
$VERBOSE = nil
Dir.mktmpdir("test_ruby_test_rubyoption") do |path|
name = "test_rubyoption.rb"
parent, dir = File.split(path)
File.write("#{path}/#{name}", "p 1")
load_error = %r[#{Regexp.quote dir}/#{Regexp.quote name} \(LoadError\)]

path, name = File.split(t.path)

ENV['PATH'] = (path_orig && RbConfig::CONFIG['LIBPATHENV'] == 'PATH') ?
[path, path_orig].join(File::PATH_SEPARATOR) : path
ENV['PATH'] = [path, *libpath].join(File::PATH_SEPARATOR)
assert_in_out_err(%w(-S) + [name], "", %w(1), [])
ENV['PATH'] = [parent, *libpath].join(File::PATH_SEPARATOR)
assert_in_out_err(%W(-S) + ["#{dir}/#{name}"], "", [], load_error)
ENV['PATH'] = path_orig

ENV['RUBYPATH'] = path
assert_in_out_err(%w(-S) + [name], "", %w(1), [])
}

ensure
if rubypath_orig
ENV['RUBYPATH'] = parent
assert_in_out_err(%w(-S) + ["#{dir}/#{name}"], "", [], load_error)
ensure
ENV['RUBYPATH'] = rubypath_orig
else
ENV.delete('RUBYPATH')
end
if path_orig
ENV['PATH'] = path_orig
else
ENV.delete('PATH')
end
$VERBOSE = @verbose
end

def test_shebang
Expand Down