Skip to content

Commit a0155c8

Browse files
authored
Merge branch 'master' into type_parameters
2 parents 4eafdd2 + e8f22ce commit a0155c8

File tree

151 files changed

+1982
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+1982
-388
lines changed

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'github-actions'
4+
directory: '/'
5+
schedule:
6+
interval: 'weekly'

.github/workflows/gh-pages.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy RDoc site to Pages
2+
3+
on:
4+
push:
5+
branches: [ 'master' ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
if: ${{ github.repository == 'ruby/rdoc' && !startsWith(github.event_name, 'pull') }}
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
- name: Setup Ruby
25+
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
26+
with:
27+
ruby-version: '3.2'
28+
bundler-cache: true
29+
- name: Setup Pages
30+
id: pages
31+
uses: actions/configure-pages@v3
32+
- name: Build with RDoc
33+
# Outputs to the './_site' directory by default
34+
run: bundle exec rake rdoc
35+
- name: Upload artifact
36+
uses: actions/upload-pages-artifact@v1
37+
38+
deploy:
39+
environment:
40+
name: github-pages
41+
url: ${{ steps.deployment.outputs.page_url }}
42+
runs-on: ubuntu-latest
43+
needs: build
44+
steps:
45+
- name: Deploy to GitHub Pages
46+
id: deployment
47+
uses: actions/deploy-pages@v2

.github/workflows/test.yml

+28-10
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,36 @@ name: Test
22

33
on: [push, pull_request]
44

5+
permissions: # added using https://github.com/step-security/secure-workflows
6+
contents: read
7+
58
jobs:
6-
build:
9+
ruby-versions:
10+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
11+
12+
test:
13+
needs: ruby-versions
714
strategy:
815
matrix:
9-
ruby: [ 'head', '3.1', '3.0', '2.7' ]
10-
os:
11-
- windows-latest
12-
- ubuntu-latest
13-
include:
14-
- { ruby: '3.1', os: 'macos-latest' }
15-
- { ruby: 'jruby-9.2.19.0', os: 'ubuntu-latest' }
16+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
exclude:
19+
- os: windows-latest
20+
ruby: truffleruby
21+
- os: windows-latest
22+
ruby: truffleruby-head
23+
- os: windows-latest
24+
ruby: jruby
25+
- os: windows-latest
26+
ruby: jruby-head
1627
runs-on: ${{ matrix.os }}
1728
steps:
18-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
30+
# libyaml-dev is needed for psych, see https://github.com/ruby/setup-ruby/issues/409
31+
- if: ${{ matrix.os == 'ubuntu-latest' }}
32+
run: sudo apt install libyaml-dev
1933
- name: Set up Ruby
20-
uses: ruby/setup-ruby@v1
34+
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
2135
with:
2236
ruby-version: ${{ matrix.ruby }}
2337
bundler-cache: true # 'bundle install' and cache
@@ -28,4 +42,8 @@ jobs:
2842
run: bundle exec rake
2943
env:
3044
RUBYOPT: --enable-frozen_string_literal
45+
- if: ${{ matrix.ruby == 'head' && startsWith(matrix.os, 'ubuntu') }}
46+
run: bundle exec rake rdoc
47+
- if: ${{ matrix.ruby == 'head' && startsWith(matrix.os, 'ubuntu') }}
48+
run: bundle exec rake rubocop
3149

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
.DS_Store
55
/.rdoc
66
/.rvmrc
7+
/.ruby-version
78
/TAGS
89
/html
10+
/_site
911
/lib/rdoc/rd/block_parser.rb
1012
/lib/rdoc/rd/inline_parser.rb
1113
/lib/rdoc/markdown.rb

.rubocop.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
AllCops:
2-
TargetRubyVersion: 2.5
2+
TargetRubyVersion: 2.6
33
DisabledByDefault: true
44
Exclude:
55
- rdoc.gemspec
66

77
Layout/TrailingWhitespace:
88
Enabled: true
9+
Layout/TrailingEmptyLines:
10+
Enabled: true

CONTRIBUTING.rdoc

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ RDoc uses bundler for development. To get ready to work on RDoc run:
3434
This will install all the necessary dependencies for development with rake,
3535
generate documentation and run the tests for the first time.
3636

37-
If the tests don't pass on the first run check the {Travis CI page for
38-
RDoc}[https://travis-ci.org/ruby/rdoc] to see if there are any known failures
37+
If the tests don't pass on the first run check the {GitHub Actions page}[https://github.com/ruby/rdoc/actions] to see if there are any known failures
3938
(there shouldn't be).
4039

4140
You can now use `rake` and `autotest` to run the tests.

Gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ gemspec
55
group :development do
66
gem 'rake'
77
gem 'racc', '> 1.4.10'
8-
gem 'kpeg', github: 'evanphx/kpeg'
8+
gem 'kpeg', '>= 1.3.3'
99
gem 'test-unit'
10-
gem 'rubocop'
10+
gem 'rubocop', '>= 1.31.0'
1111
gem 'gettext'
1212
end

README.rdoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
home :: https://github.com/ruby/rdoc
44
rdoc :: https://ruby.github.io/rdoc
55
bugs :: https://github.com/ruby/rdoc/issues
6-
code quality :: {<img src="https://codeclimate.com/github/ruby/rdoc/badges/gpa.svg" alt="Code Climate">}[https://codeclimate.com/github/ruby/rdoc]
6+
code quality :: https://codeclimate.com/github/ruby/rdoc
77

88
== Description
99

@@ -46,7 +46,7 @@ contain just Markup-style markup (with or without leading '#' comment
4646
markers). If directory names are passed to RDoc, they are scanned
4747
recursively for C and Ruby source files only.
4848

49-
To generate documentation using +rake+ see RDoc::Task[https://ruby.github.io/rdoc/RDocTask.html].
49+
To generate documentation using +rake+ see RDoc::Task[https://ruby.github.io/rdoc/RDoc/Task.html].
5050

5151
To generate documentation programmatically:
5252

Rakefile

+7-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ require_relative 'lib/rdoc/task'
66
require 'bundler/gem_tasks'
77
require 'rake/testtask'
88

9-
task :docs => :generate
109
task :test => [:normal_test, :rubygems_test]
1110

1211
PARSER_FILES = %w[
@@ -20,31 +19,23 @@ $rdoc_rakefile = true
2019

2120
task :default => :test
2221

22+
task rdoc: :generate
2323
RDoc::Task.new do |doc|
2424
doc.main = 'README.rdoc'
2525
doc.title = "rdoc #{RDoc::VERSION} Documentation"
26-
doc.rdoc_dir = 'html'
26+
doc.rdoc_dir = '_site' # for github pages
2727
doc.rdoc_files = FileList.new %w[lib/**/*.rb *.rdoc doc/rdoc/markup_reference.rb] - PARSER_FILES
2828
end
2929

30-
task ghpages: :rdoc do
31-
`git checkout gh-pages`
32-
require "fileutils"
33-
FileUtils.rm_rf "/tmp/html"
34-
FileUtils.mv "html", "/tmp"
35-
FileUtils.rm_rf "*"
36-
FileUtils.cp_r Dir.glob("/tmp/html/*"), "."
37-
end
38-
3930
Rake::TestTask.new(:normal_test) do |t|
40-
t.libs = []
4131
t.verbose = true
4232
t.deps = :generate
33+
t.libs << "test/lib"
34+
t.ruby_opts << "-rhelper"
4335
t.test_files = FileList["test/**/test_*.rb"].exclude("test/rdoc/test_rdoc_rubygems_hook.rb")
4436
end
4537

4638
Rake::TestTask.new(:rubygems_test) do |t|
47-
t.libs = []
4839
t.verbose = true
4940
t.deps = :generate
5041
t.pattern = "test/rdoc/test_rdoc_rubygems_hook.rb"
@@ -73,7 +64,7 @@ parsed_files = PARSER_FILES.map do |parser_file|
7364
when '.ry' # need racc
7465
racc = Gem.bin_path 'racc', 'racc'
7566
rb_file = parser_file.gsub(/\.ry\z/, ".rb")
76-
ruby "#{racc} -l -o #{rb_file} #{parser_file}"
67+
ruby "#{racc} -l -E -o #{rb_file} #{parser_file}"
7768
open(rb_file, 'r+') do |f|
7869
newtext = "# frozen_string_literal: true\n#{f.read}"
7970
f.rewind
@@ -83,6 +74,7 @@ parsed_files = PARSER_FILES.map do |parser_file|
8374
kpeg = Gem.bin_path 'kpeg', 'kpeg'
8475
rb_file = parser_file.gsub(/\.kpeg\z/, ".rb")
8576
ruby "#{kpeg} -fsv -o #{rb_file} #{parser_file}"
77+
File.write(rb_file, File.read(rb_file).gsub(/ +$/, '')) # remove trailing spaces
8678
end
8779
end
8880

@@ -106,5 +98,5 @@ else
10698
RuboCop::RakeTask.new(:rubocop) do |t|
10799
t.options = [*parsed_files]
108100
end
109-
task :build => [:generate, "rubocop:auto_correct"]
101+
task :build => [:generate, "rubocop:autocorrect"]
110102
end

TODO.rdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Nice to have:
2626
* Global variable support
2727
* Provide the code_object to directive handlers
2828

29-
=== 4
29+
=== More Future
3030

3131
API changes to RDoc
3232

doc/rdoc/markup_reference.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# - Single-line or multi-line comments that precede certain definitions;
2727
# see {Markup in Comments}[rdoc-ref:RDoc::MarkupReference@Markup+in+Comments].
2828
# - \RDoc directives in trailing comments (on the same line as code);
29-
# see <tt>:nodoc:</tt>, <tt>:doc:</tt>, and <tt>:notnew</tt>.
29+
# see <tt>:nodoc:</tt>, <tt>:doc:</tt>, and <tt>:notnew:</tt>.
3030
# - \RDoc directives in single-line comments;
3131
# see other {Directives}[rdoc-ref:RDoc::MarkupReference@Directives].
3232
# - The Ruby code itself (but not from C code);
@@ -66,7 +66,7 @@
6666
# In a multi-line comment,
6767
# \RDoc looks for the comment's natural left margin,
6868
# which becomes the <em>base margin</em> for the comment
69-
# and is the initial <em>current margin</em> for for the comment.
69+
# and is the initial <em>current margin</em> for the comment.
7070
#
7171
# The current margin can change, and does so, for example in a list.
7272
#
@@ -346,7 +346,7 @@
346346
#
347347
# ===== Lettered Lists
348348
#
349-
# A numbered list item begins with a letters and a period.
349+
# A lettered list item begins with letters and a period.
350350
#
351351
# The items are automatically "re-lettered."
352352
#

lib/rdoc/alias.rb

-1
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,3 @@ def to_s # :nodoc:
109109
end
110110

111111
end
112-

lib/rdoc/anon_class.rb

-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88

99
class RDoc::AnonClass < RDoc::ClassModule
1010
end
11-

lib/rdoc/attr.rb

-1
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,3 @@ def token_stream # :nodoc:
173173
end
174174

175175
end
176-

lib/rdoc/class_module.rb

-1
Original file line numberDiff line numberDiff line change
@@ -809,4 +809,3 @@ def update_extends
809809
end
810810

811811
end
812-

lib/rdoc/comment.rb

+17-33
Original file line numberDiff line numberDiff line change
@@ -97,42 +97,26 @@ def extract_call_seq method
9797
# comment. The difficulty is to make sure not to match lines starting
9898
# with ARGF at the same indent, but that are after the first description
9999
# paragraph.
100-
if @text =~ /^\s*:?call-seq:(.*?(?:\S).*?)^\s*$/m then
100+
if /^(?<S> ((?!\n)\s)*+ (?# whitespaces except newline))
101+
:?call-seq:
102+
(?<B> \g<S>(?<N>\n|\z) (?# trailing spaces))?
103+
(?<seq>
104+
(\g<S>(?!\w)\S.*\g<N>)*
105+
(?>
106+
(?<H> \g<S>\w+ (?# ' # ARGF' in the example above))
107+
.*\g<N>)?
108+
(\g<S>\S.*\g<N> (?# other non-blank line))*+
109+
(\g<B>+(\k<H>.*\g<N> (?# ARGF.to_a lines))++)*+
110+
)
111+
(?m:^\s*$|\z)
112+
/x =~ @text
113+
seq = $~[:seq]
114+
101115
all_start, all_stop = $~.offset(0)
102-
seq_start, seq_stop = $~.offset(1)
103-
104-
# we get the following lines that start with the leading word at the
105-
# same indent, even if they have blank lines before
106-
if $1 =~ /(^\s*\n)+^(\s*\w+)/m then
107-
leading = $2 # ' * ARGF' in the example above
108-
re = %r%
109-
\A(
110-
(^\s*\n)+
111-
(^#{Regexp.escape leading}.*?\n)+
112-
)+
113-
^\s*$
114-
%xm
115-
116-
if @text[seq_stop..-1] =~ re then
117-
all_stop = seq_stop + $~.offset(0).last
118-
seq_stop = seq_stop + $~.offset(1).last
119-
end
120-
end
121-
122-
seq = @text[seq_start..seq_stop]
123-
seq.gsub!(/^\s*(\S|\n)/m, '\1')
124116
@text.slice! all_start...all_stop
125117

126-
method.call_seq = seq.chomp
127-
128-
else
129-
regexp = /^\s*:?call-seq:(.*?)(^\s*$|\z)/m
130-
if regexp =~ @text then
131-
@text = @text.sub(regexp, '')
132-
seq = $1
133-
seq.gsub!(/^\s*/, '')
134-
method.call_seq = seq
135-
end
118+
seq.gsub!(/^\s*/, '')
119+
method.call_seq = seq
136120
end
137121

138122
method

lib/rdoc/constant.rb

-1
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,3 @@ def to_s # :nodoc:
184184
end
185185

186186
end
187-

lib/rdoc/context/section.rb

-1
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,3 @@ def remove_comment comment
231231
end
232232

233233
end
234-

lib/rdoc/cross_reference.rb

-1
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,3 @@ def resolve name, text
223223
end
224224

225225
end
226-

lib/rdoc/erb_partial.rb

-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ def set_eoutvar compiler, eoutvar = '_erbout'
1616
end
1717

1818
end
19-

lib/rdoc/erbio.rb

-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,3 @@ def set_eoutvar compiler, io_variable
3939
end
4040

4141
end
42-

lib/rdoc/extend.rb

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
class RDoc::Extend < RDoc::Mixin
88

99
end
10-

lib/rdoc/generator/darkfish.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ def setup
610610

611611
@classes = @store.all_classes_and_modules.sort
612612
@files = @store.all_files.sort
613-
@methods = @classes.map { |m| m.method_list }.flatten.sort
613+
@methods = @classes.flat_map { |m| m.method_list }.sort
614614
@modsort = get_sorted_module_list @classes
615615
end
616616

0 commit comments

Comments
 (0)