Skip to content

Commit 7e2364c

Browse files
st0012claude
andauthored
Drop Ripper-based parser (#1690)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2aa8b5e commit 7e2364c

15 files changed

Lines changed: 2290 additions & 9245 deletions

File tree

.github/workflows/ruby-core.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,4 @@ jobs:
6969
- name: Generate Documentation with RDoc
7070
run: make html
7171
working-directory: ruby/ruby
72-
# We need to clear the generated documentation to generate them again
73-
# with the Ripper parser.
74-
- name: Clear Generated Documentation
75-
run: rm -r .ext/html
76-
working-directory: ruby/ruby
77-
- name: Generate Documentation with RDoc (Ripper parser)
78-
run: make html
79-
working-directory: ruby/ruby
80-
env:
81-
RDOC_USE_RIPPER_PARSER: true
8272

.github/workflows/test.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ jobs:
5353
run: bundle exec rake
5454
env:
5555
RUBYOPT: --enable-frozen_string_literal
56-
- name: Run test with Ripper parser
57-
run: bundle exec rake
58-
env:
59-
RUBYOPT: --enable-frozen_string_literal
60-
RDOC_USE_RIPPER_PARSER: true
6156
- if: ${{ matrix.ruby == 'head' && startsWith(matrix.os, 'ubuntu') }}
6257
run: bundle exec rake rdoc
6358
- if: ${{ matrix.ruby == 'head' && startsWith(matrix.os, 'ubuntu') }}

AGENTS.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,8 @@ lib/rdoc/
178178
├── version.rb # Version constant
179179
├── task.rb # Rake task integration
180180
├── parser/ # Source code parsers (Ruby, C, Markdown, RD)
181-
│ ├── ruby.rb # Ruby code parser
181+
│ ├── ruby.rb # Prism-based Ruby parser
182182
│ ├── c.rb # C extension parser
183-
│ ├── prism_ruby.rb # Prism-based Ruby parser
184183
│ └── ...
185184
├── server.rb # Live-reloading preview server (rdoc --server)
186185
├── generator/ # Documentation generators
@@ -236,10 +235,10 @@ exe/
236235

237236
### Parsers and Generators
238237

239-
- **Parsers:** Prism-based Ruby (default, `RDoc::Parser::PrismRuby`), legacy ripper-based Ruby (`RDoc::Parser::RipperRuby`, opt-in via `RDOC_USE_RIPPER_PARSER=1`), C, Markdown, RD
238+
- **Parsers:** Prism-based Ruby (`RDoc::Parser::Ruby`), C, Markdown, RD
240239
- **Generators:** HTML/Aliki (default), HTML/Darkfish (deprecated), RI, POT (gettext), JSON, Markup
241240

242-
Both Ruby parsers must produce equivalent code-object trees, so parser tests live in the `RDocParserPrismTestCases` module (`test/rdoc/parser/prism_ruby_test.rb`) and are included by both `RDocParserPrismRubyTest` and `RDocParserRipperRubyWithPrismRubyTestCasesTest`. The ripper variant is gated on `RDOC_USE_RIPPER_PARSER`, so `bundle exec rake` locally only runs prism; CI exercises ripper in a separate job. Add new parser tests to the mixin, and run `RDOC_USE_RIPPER_PARSER=1 bundle exec rake` locally before declaring a parser change done.
241+
Parser tests live in the `RDocParserRubyTestCases` module (`test/rdoc/parser/ruby_test.rb`) and are included by `RDocParserRubyTest`. Add new parser tests to the mixin.
243242

244243
### Code Object Model and Constant Aliases
245244

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ lib/rdoc/
160160
├── version.rb # Version constant
161161
├── task.rb # Rake task integration
162162
├── parser/ # Source code parsers
163-
│ ├── ruby.rb # Ruby code parser
163+
│ ├── ruby.rb # Prism-based Ruby parser
164164
│ ├── c.rb # C extension parser
165-
│ ├── prism_ruby.rb # Prism-based Ruby parser
166165
│ └── ...
167166
├── generator/ # Documentation generators
168167
│ ├── aliki.rb # HTML generator (default theme)

lib/rdoc/code_object/context.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ def find_constant_named(name)
783783
# Tries to find a module at a higher scope.
784784
# But parent is not always a higher module nesting scope, so the result is not correct.
785785
# Parent chain can only represent last-opened nesting, and may be broken in some cases.
786-
# PrismRuby parser stopped representing module nesting with parent chain at all.
786+
# The Ruby parser does not represent module nesting with the parent chain.
787787

788788
def find_enclosing_module_named(name)
789789
parent && parent.find_module_named(name)

lib/rdoc/code_object/context/section.rb

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ def ==(other)
6363
# Adds +comment+ to this section
6464

6565
def add_comment(comment)
66-
comments = Array(comment)
67-
comments.each do |c|
68-
extracted_comment = extract_comment(c)
69-
@comments << extracted_comment unless extracted_comment.empty?
66+
Array(comment).each do |c|
67+
next if c.nil?
68+
raise TypeError, "unknown comment #{c.inspect}" unless RDoc::Comment === c
69+
@comments << c unless c.empty?
7070
end
7171
end
7272

@@ -98,40 +98,6 @@ def legacy_aref
9898
CGI.escape(title).gsub('%', '-').sub(/^-/, '')
9999
end
100100

101-
##
102-
# Extracts the comment for this section from the original comment block.
103-
# If the first line contains :section:, strip it and use the rest.
104-
# Otherwise remove lines up to the line containing :section:, and look
105-
# for those lines again at the end and remove them. This lets us write
106-
#
107-
# # :section: The title
108-
# # The body
109-
#
110-
#--
111-
# TODO Remove when the ripper parser has been removed
112-
113-
def extract_comment(comment)
114-
case comment
115-
when nil
116-
RDoc::Comment.new ''
117-
when RDoc::Comment then
118-
if comment.text =~ /^#[ \t]*:section:.*\n/ then
119-
start = $`
120-
rest = $'
121-
122-
comment.text = if start.empty? then
123-
rest
124-
else
125-
rest.sub(/#{start.chomp}\Z/, '')
126-
end
127-
end
128-
129-
comment
130-
else
131-
raise TypeError, "unknown comment #{comment.inspect}"
132-
end
133-
end
134-
135101
def inspect # :nodoc:
136102
"#<%s:0x%x %p>" % [self.class, object_id, title]
137103
end

lib/rdoc/code_object/mixin.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ def inspect # :nodoc:
7272
#
7373
# As of the beginning of October, 2011, no gem includes nonexistent modules.
7474
#
75-
# When mixin is created from RDoc::Parser::PrismRuby, module name is already a resolved full-path name.
76-
#
75+
# The Ruby parser passes an already-resolved full-path +name+, so most of this
76+
# logic only runs for the C parser, which passes the unresolved local name.
7777

7878
def module
7979
return @module if @module

lib/rdoc/parser.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ def initialize(top_level, content, options, stats)
266266
@preprocess.options = @options
267267
end
268268

269-
autoload :RubyTools, "#{__dir__}/parser/ruby_tools"
270-
autoload :Text, "#{__dir__}/parser/text"
269+
autoload :Text, "#{__dir__}/parser/text"
271270

272271
##
273272
# Normalizes tabs in +body+
@@ -295,14 +294,4 @@ def handle_tab_width(body)
295294
require_relative 'parser/markdown'
296295
require_relative 'parser/rd'
297296

298-
if ENV['RDOC_USE_RIPPER_PARSER']
299-
puts "========================================================================="
300-
puts "RDoc is using the deprecated Ripper parser to generate the documentation."
301-
puts "This parser will be removed in a future version of RDoc."
302-
puts "========================================================================="
303-
require 'rdoc/parser/ripper_ruby'
304-
RDoc::Parser::Ruby = RDoc::Parser::RipperRuby
305-
else
306-
require 'rdoc/parser/prism_ruby'
307-
RDoc::Parser::Ruby = RDoc::Parser::PrismRuby
308-
end
297+
require_relative 'parser/ruby'

0 commit comments

Comments
 (0)