[DOC] Fix doc/regexp.rdoc links

- Rename regexp.rdoc to exclude from "Pages".  This file is for to be
  included in the "class Regexp" document, but it also appeared as a
  separate page duplicately.
- Fix links on case-sensitive filesystems.
- Fix to use rdoc-ref instead of converted HTML page names.
This commit is contained in:
Nobuyoshi Nakada 2023-11-14 13:53:59 +09:00
parent e020eb26f0
commit caa9881fde
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
5 changed files with 42 additions and 43 deletions

4
dir.rb
View File

@ -320,7 +320,7 @@ class Dir
# Dir.glob('io.?') # => ["io.c"] # Dir.glob('io.?') # => ["io.c"]
# #
# - <tt>'[_set_]'</tt>: Matches any one character in the string _set_; # - <tt>'[_set_]'</tt>: Matches any one character in the string _set_;
# behaves like a {Regexp character class}[rdoc-ref:regexp.rdoc@Character+Classes], # behaves like a {Regexp character class}[rdoc-ref:Regexp@Character+Classes],
# including set negation (<tt>'[^a-z]'</tt>): # including set negation (<tt>'[^a-z]'</tt>):
# #
# Dir.glob('*.[a-z][a-z]').take(3) # Dir.glob('*.[a-z][a-z]').take(3)
@ -328,7 +328,7 @@ class Dir
# #
# - <tt>'{_abc_,_xyz_}'</tt>: # - <tt>'{_abc_,_xyz_}'</tt>:
# Matches either string _abc_ or string _xyz_; # Matches either string _abc_ or string _xyz_;
# behaves like {Regexp alternation}[rdoc-ref:regexp.rdoc@Alternation]: # behaves like {Regexp alternation}[rdoc-ref:Regexp@Alternation]:
# #
# Dir.glob('{LEGAL,BSDL}') # => ["LEGAL", "BSDL"] # Dir.glob('{LEGAL,BSDL}') # => ["LEGAL", "BSDL"]
# #

View File

@ -1,6 +1,6 @@
*.md *.md
*.rb *.rb
*.rdoc [^_]*.rdoc
contributing contributing
NEWS NEWS
syntax syntax

View File

@ -25,46 +25,46 @@ A regexp may be used:
re.match('food') # => #<MatchData "foo"> re.match('food') # => #<MatchData "foo">
re.match('good') # => nil re.match('good') # => nil
See sections {Method match}[rdoc-ref:regexp.rdoc@Method+match] See sections {Method match}[rdoc-ref:Regexp@Method+match]
and {Operator =~}[rdoc-ref:regexp.rdoc@Operator+-3D~]. and {Operator =~}[rdoc-ref:Regexp@Operator+-3D~].
- To determine whether a string matches a given pattern: - To determine whether a string matches a given pattern:
re.match?('food') # => true re.match?('food') # => true
re.match?('good') # => false re.match?('good') # => false
See section {Method match?}[rdoc-ref:regexp.rdoc@Method+match-3F]. See section {Method match?}[rdoc-ref:Regexp@Method+match-3F].
- As an argument for calls to certain methods in other classes and modules; - As an argument for calls to certain methods in other classes and modules;
most such methods accept an argument that may be either a string most such methods accept an argument that may be either a string
or the (much more powerful) regexp. or the (much more powerful) regexp.
See {Regexp Methods}[./Regexp/methods_rdoc.html]. See {Regexp Methods}[rdoc-ref:regexp/methods.rdoc].
== \Regexp Objects == \Regexp Objects
A regexp object has: A regexp object has:
- A source; see {Sources}[rdoc-ref:regexp.rdoc@Sources]. - A source; see {Sources}[rdoc-ref:Regexp@Sources].
- Several modes; see {Modes}[rdoc-ref:regexp.rdoc@Modes]. - Several modes; see {Modes}[rdoc-ref:Regexp@Modes].
- A timeout; see {Timeouts}[rdoc-ref:regexp.rdoc@Timeouts]. - A timeout; see {Timeouts}[rdoc-ref:Regexp@Timeouts].
- An encoding; see {Encodings}[rdoc-ref:regexp.rdoc@Encodings]. - An encoding; see {Encodings}[rdoc-ref:Regexp@Encodings].
== Creating a \Regexp == Creating a \Regexp
A regular expression may be created with: A regular expression may be created with:
- A regexp literal using slash characters - A regexp literal using slash characters
(see {Regexp Literals}[https://docs.ruby-lang.org/en/master/syntax/literals_rdoc.html#label-Regexp+Literals]): (see {Regexp Literals}[rdoc-ref:syntax/literals.rdoc@Regexp+Literals]):
# This is a very common usage. # This is a very common usage.
/foo/ # => /foo/ /foo/ # => /foo/
- A <tt>%r</tt> regexp literal - A <tt>%r</tt> regexp literal
(see {%r: Regexp Literals}[https://docs.ruby-lang.org/en/master/syntax/literals_rdoc.html#label-25r-3A+Regexp+Literals]): (see {%r: Regexp Literals}[rdoc-ref:syntax/literals.rdoc@25r-3A+Regexp+Literals]):
# Same delimiter character at beginning and end; # Same delimiter character at beginning and end;
# useful for avoiding escaping characters # useful for avoiding escaping characters
@ -84,7 +84,7 @@ A regular expression may be created with:
Each of the methods Regexp#match, String#match, and Symbol#match Each of the methods Regexp#match, String#match, and Symbol#match
returns a MatchData object if a match was found, +nil+ otherwise; returns a MatchData object if a match was found, +nil+ otherwise;
each also sets {global variables}[rdoc-ref:regexp.rdoc@Global+Variables]: each also sets {global variables}[rdoc-ref:Regexp@Global+Variables]:
'food'.match(/foo/) # => #<MatchData "foo"> 'food'.match(/foo/) # => #<MatchData "foo">
'food'.match(/bar/) # => nil 'food'.match(/bar/) # => nil
@ -93,7 +93,7 @@ each also sets {global variables}[rdoc-ref:regexp.rdoc@Global+Variables]:
Each of the operators Regexp#=~, String#=~, and Symbol#=~ Each of the operators Regexp#=~, String#=~, and Symbol#=~
returns an integer offset if a match was found, +nil+ otherwise; returns an integer offset if a match was found, +nil+ otherwise;
each also sets {global variables}[rdoc-ref:regexp.rdoc@Global+Variables]: each also sets {global variables}[rdoc-ref:Regexp@Global+Variables]:
/bar/ =~ 'foo bar' # => 4 /bar/ =~ 'foo bar' # => 4
'foo bar' =~ /bar/ # => 4 'foo bar' =~ /bar/ # => 4
@ -103,7 +103,7 @@ each also sets {global variables}[rdoc-ref:regexp.rdoc@Global+Variables]:
Each of the methods Regexp#match?, String#match?, and Symbol#match? Each of the methods Regexp#match?, String#match?, and Symbol#match?
returns +true+ if a match was found, +false+ otherwise; returns +true+ if a match was found, +false+ otherwise;
none sets {global variables}[rdoc-ref:regexp.rdoc@Global+Variables]: none sets {global variables}[rdoc-ref:Regexp@Global+Variables]:
'food'.match?(/foo/) # => true 'food'.match?(/foo/) # => true
'food'.match?(/bar/) # => false 'food'.match?(/bar/) # => false
@ -112,8 +112,8 @@ none sets {global variables}[rdoc-ref:regexp.rdoc@Global+Variables]:
Certain regexp-oriented methods assign values to global variables: Certain regexp-oriented methods assign values to global variables:
- <tt>#match</tt>: see {Method match}[rdoc-ref:regexp.rdoc@Method+match]. - <tt>#match</tt>: see {Method match}[rdoc-ref:Regexp@Method+match].
- <tt>#=~</tt>: see {Operator =~}[rdoc-ref:regexp.rdoc@Operator+-3D~]. - <tt>#=~</tt>: see {Operator =~}[rdoc-ref:Regexp@Operator+-3D~].
The affected global variables are: The affected global variables are:
@ -172,17 +172,17 @@ As seen above, the simplest regexp uses a literal expression as its source:
A rich collection of available _subexpressions_ A rich collection of available _subexpressions_
gives the regexp great power and flexibility: gives the regexp great power and flexibility:
- {Special characters}[rdoc-ref:regexp.rdoc@Special+Characters] - {Special characters}[rdoc-ref:Regexp@Special+Characters]
- {Source literals}[rdoc-ref:regexp.rdoc@Source+Literals] - {Source literals}[rdoc-ref:Regexp@Source+Literals]
- {Character classes}[rdoc-ref:regexp.rdoc@Character+Classes] - {Character classes}[rdoc-ref:Regexp@Character+Classes]
- {Shorthand character classes}[rdoc-ref:regexp.rdoc@Shorthand+Character+Classes] - {Shorthand character classes}[rdoc-ref:Regexp@Shorthand+Character+Classes]
- {Anchors}[rdoc-ref:regexp.rdoc@Anchors] - {Anchors}[rdoc-ref:Regexp@Anchors]
- {Alternation}[rdoc-ref:regexp.rdoc@Alternation] - {Alternation}[rdoc-ref:Regexp@Alternation]
- {Quantifiers}[rdoc-ref:regexp.rdoc@Quantifiers] - {Quantifiers}[rdoc-ref:Regexp@Quantifiers]
- {Groups and captures}[rdoc-ref:regexp.rdoc@Groups+and+Captures] - {Groups and captures}[rdoc-ref:Regexp@Groups+and+Captures]
- {Unicode}[rdoc-ref:regexp.rdoc@Unicode] - {Unicode}[rdoc-ref:Regexp@Unicode]
- {POSIX Bracket Expressions}[rdoc-ref:regexp.rdoc@POSIX+Bracket+Expressions] - {POSIX Bracket Expressions}[rdoc-ref:Regexp@POSIX+Bracket+Expressions]
- {Comments}[rdoc-ref:regexp.rdoc@Comments] - {Comments}[rdoc-ref:Regexp@Comments]
=== Special Characters === Special Characters
@ -222,7 +222,7 @@ In particular, a source literal may contain interpolated expressions:
/#{2 + 2}/ # => /4/ /#{2 + 2}/ # => /4/
There are differences between an ordinary string literal and a source literal; There are differences between an ordinary string literal and a source literal;
see {Shorthand Character Classes}[rdoc-ref:regexp.rdoc@Shorthand+Character+Classes]. see {Shorthand Character Classes}[rdoc-ref:Regexp@Shorthand+Character+Classes].
- <tt>\s</tt> in an ordinary string literal is equivalent to a space character; - <tt>\s</tt> in an ordinary string literal is equivalent to a space character;
in a source literal, it's shorthand for matching a whitespace character. in a source literal, it's shorthand for matching a whitespace character.
@ -279,7 +279,7 @@ for a character class:
/./.match("\n") # => nil /./.match("\n") # => nil
- <tt>/./m</tt>: Matches any character, including a newline; - <tt>/./m</tt>: Matches any character, including a newline;
see {Multiline Mode}[rdoc-ref:regexp.rdoc@Multiline+Mode}: see {Multiline Mode}[rdoc-ref:Regexp@Multiline+Mode]:
/./m.match("\n") # => #<MatchData "\n"> /./m.match("\n") # => #<MatchData "\n">
@ -578,8 +578,7 @@ called _captures_:
The first capture is the entire matched string; The first capture is the entire matched string;
the other captures are the matched substrings from the groups. the other captures are the matched substrings from the groups.
A group may have a A group may have a {quantifier}[rdoc-ref:Regexp@Quantifiers]:
{quantifier}[rdoc-ref:regexp.rdoc@Quantifiers]:
re = /July 4(th)?/ re = /July 4(th)?/
re.match('July 4') # => #<MatchData "July 4" 1:nil> re.match('July 4') # => #<MatchData "July 4" 1:nil>
@ -815,7 +814,7 @@ Or by using <tt>\P</tt> (uppercase +P+):
/\P{Alpha}/.match('1') # => #<MatchData "1"> /\P{Alpha}/.match('1') # => #<MatchData "1">
/\P{Alpha}/.match('a') # => nil /\P{Alpha}/.match('a') # => nil
See {Unicode Properties}[./Regexp/unicode_properties_rdoc.html] See {Unicode Properties}[rdoc-ref:regexp/unicode_properties.rdoc]
for regexps based on the numerous properties. for regexps based on the numerous properties.
Some commonly-used properties correspond to POSIX bracket expressions: Some commonly-used properties correspond to POSIX bracket expressions:
@ -1012,20 +1011,20 @@ arbitrary text ignored by the regexp engine:
The comment may not include an unescaped terminator character. The comment may not include an unescaped terminator character.
See also {Extended Mode}[rdoc-ref:regexp.rdoc@Extended+Mode]. See also {Extended Mode}[rdoc-ref:Regexp@Extended+Mode].
== Modes == Modes
Each of these modifiers sets a mode for the regexp: Each of these modifiers sets a mode for the regexp:
- +i+: <tt>/_pattern_/i</tt> sets - +i+: <tt>/_pattern_/i</tt> sets
{Case-Insensitive Mode}[rdoc-ref:regexp.rdoc@Case-Insensitive+Mode]. {Case-Insensitive Mode}[rdoc-ref:Regexp@Case-Insensitive+Mode].
- +m+: <tt>/_pattern_/m</tt> sets - +m+: <tt>/_pattern_/m</tt> sets
{Multiline Mode}[rdoc-ref:regexp.rdoc@Multiline+Mode]. {Multiline Mode}[rdoc-ref:Regexp@Multiline+Mode].
- +x+: <tt>/_pattern_/x</tt> sets - +x+: <tt>/_pattern_/x</tt> sets
{Extended Mode}[rdoc-ref:regexp.rdoc@Extended+Mode]. {Extended Mode}[rdoc-ref:Regexp@Extended+Mode].
- +o+: <tt>/_pattern_/o</tt> sets - +o+: <tt>/_pattern_/o</tt> sets
{Interpolation Mode}[rdoc-ref:regexp.rdoc@Interpolation+Mode]. {Interpolation Mode}[rdoc-ref:Regexp@Interpolation+Mode].
Any, all, or none of these may be applied. Any, all, or none of these may be applied.

4
re.c
View File

@ -538,7 +538,7 @@ static VALUE rb_reg_str_with_term(VALUE re, int term);
* *
* The returned string may be used as an argument to Regexp.new, * The returned string may be used as an argument to Regexp.new,
* or as interpolated text for a * or as interpolated text for a
* {Regexp interpolation}[rdoc-ref:regexp.rdoc@Interpolation+Mode]: * {Regexp interpolation}[rdoc-ref:Regexp@Interpolation+Mode]:
* *
* r1 = Regexp.new(s0) # => /(?ix-m:ab+c)/ * r1 = Regexp.new(s0) # => /(?ix-m:ab+c)/
* r2 = /#{s0}/ # => /(?ix-m:ab+c)/ * r2 = /#{s0}/ # => /(?ix-m:ab+c)/
@ -4692,7 +4692,7 @@ rb_reg_timeout_get(VALUE re)
/* /*
* Document-class: Regexp * Document-class: Regexp
* *
* :include: doc/regexp.rdoc * :include: doc/_regexp.rdoc
*/ */
void void

View File

@ -76,7 +76,7 @@
# - <tt>\n</tt> (_n_ a non-negative integer) refers to <tt>$n</tt>. # - <tt>\n</tt> (_n_ a non-negative integer) refers to <tt>$n</tt>.
# - <tt>\k<name></tt> refers to the named capture +name+. # - <tt>\k<name></tt> refers to the named capture +name+.
# #
# See rdoc-ref:regexp.rdoc for details. # See Regexp for details.
# #
# Note that within the string +replacement+, a character combination # Note that within the string +replacement+, a character combination
# such as <tt>$&</tt> is treated as ordinary text, and not as # such as <tt>$&</tt> is treated as ordinary text, and not as
@ -93,7 +93,7 @@
# - <tt>\\+</tt> corresponds to <tt>$+</tt>, # - <tt>\\+</tt> corresponds to <tt>$+</tt>,
# which contains last capture group. # which contains last capture group.
# #
# See rdoc-ref:regexp.rdoc for details. # See Regexp for details.
# #
# Note that <tt>\\\\</tt> is interpreted as an escape, i.e., a single backslash. # Note that <tt>\\\\</tt> is interpreted as an escape, i.e., a single backslash.
# #