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
10 changes: 0 additions & 10 deletions .github/workflows/ruby-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,4 @@ jobs:
- name: Generate Documentation with RDoc
run: make html
working-directory: ruby/ruby
# We need to clear the generated documentation to generate them again
# with the Ripper parser.
- name: Clear Generated Documentation
run: rm -r .ext/html
working-directory: ruby/ruby
- name: Generate Documentation with RDoc (Ripper parser)
run: make html
working-directory: ruby/ruby
env:
RDOC_USE_RIPPER_PARSER: true

5 changes: 0 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ jobs:
run: bundle exec rake
env:
RUBYOPT: --enable-frozen_string_literal
- name: Run test with Ripper parser
run: bundle exec rake
env:
RUBYOPT: --enable-frozen_string_literal
RDOC_USE_RIPPER_PARSER: true
- if: ${{ matrix.ruby == 'head' && startsWith(matrix.os, 'ubuntu') }}
run: bundle exec rake rdoc
- if: ${{ matrix.ruby == 'head' && startsWith(matrix.os, 'ubuntu') }}
Expand Down
7 changes: 3 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,8 @@ lib/rdoc/
├── version.rb # Version constant
├── task.rb # Rake task integration
├── parser/ # Source code parsers (Ruby, C, Markdown, RD)
│ ├── ruby.rb # Ruby code parser
│ ├── ruby.rb # Prism-based Ruby parser
│ ├── c.rb # C extension parser
│ ├── prism_ruby.rb # Prism-based Ruby parser
│ └── ...
├── server.rb # Live-reloading preview server (rdoc --server)
├── generator/ # Documentation generators
Expand Down Expand Up @@ -236,10 +235,10 @@ exe/

### Parsers and Generators

- **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
- **Parsers:** Prism-based Ruby (`RDoc::Parser::Ruby`), C, Markdown, RD
- **Generators:** HTML/Aliki (default), HTML/Darkfish (deprecated), RI, POT (gettext), JSON, Markup

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.
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.

### Code Object Model and Constant Aliases

Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ lib/rdoc/
├── version.rb # Version constant
├── task.rb # Rake task integration
├── parser/ # Source code parsers
│ ├── ruby.rb # Ruby code parser
│ ├── ruby.rb # Prism-based Ruby parser
│ ├── c.rb # C extension parser
│ ├── prism_ruby.rb # Prism-based Ruby parser
│ └── ...
├── generator/ # Documentation generators
│ ├── aliki.rb # HTML generator (default theme)
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoc/code_object/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ def find_constant_named(name)
# Tries to find a module at a higher scope.
# But parent is not always a higher module nesting scope, so the result is not correct.
# Parent chain can only represent last-opened nesting, and may be broken in some cases.
# PrismRuby parser stopped representing module nesting with parent chain at all.
# The Ruby parser does not represent module nesting with the parent chain.

def find_enclosing_module_named(name)
parent && parent.find_module_named(name)
Expand Down
42 changes: 4 additions & 38 deletions lib/rdoc/code_object/context/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def ==(other)
# Adds +comment+ to this section

def add_comment(comment)
comments = Array(comment)
comments.each do |c|
extracted_comment = extract_comment(c)
@comments << extracted_comment unless extracted_comment.empty?
Array(comment).each do |c|
next if c.nil?
raise TypeError, "unknown comment #{c.inspect}" unless RDoc::Comment === c
@comments << c unless c.empty?
end
end

Expand Down Expand Up @@ -98,40 +98,6 @@ def legacy_aref
CGI.escape(title).gsub('%', '-').sub(/^-/, '')
end

##
# Extracts the comment for this section from the original comment block.
# If the first line contains :section:, strip it and use the rest.
# Otherwise remove lines up to the line containing :section:, and look
# for those lines again at the end and remove them. This lets us write
#
# # :section: The title
# # The body
#
#--
# TODO Remove when the ripper parser has been removed

def extract_comment(comment)
case comment
when nil
RDoc::Comment.new ''
when RDoc::Comment then
if comment.text =~ /^#[ \t]*:section:.*\n/ then
start = $`
rest = $'

comment.text = if start.empty? then
rest
else
rest.sub(/#{start.chomp}\Z/, '')
end
end

comment
else
raise TypeError, "unknown comment #{comment.inspect}"
end
end

def inspect # :nodoc:
"#<%s:0x%x %p>" % [self.class, object_id, title]
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rdoc/code_object/mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def inspect # :nodoc:
#
# As of the beginning of October, 2011, no gem includes nonexistent modules.
#
# When mixin is created from RDoc::Parser::PrismRuby, module name is already a resolved full-path name.
#
# The Ruby parser passes an already-resolved full-path +name+, so most of this
# logic only runs for the C parser, which passes the unresolved local name.

def module
return @module if @module
Expand Down
15 changes: 2 additions & 13 deletions lib/rdoc/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ def initialize(top_level, content, options, stats)
@preprocess.options = @options
end

autoload :RubyTools, "#{__dir__}/parser/ruby_tools"
autoload :Text, "#{__dir__}/parser/text"
autoload :Text, "#{__dir__}/parser/text"

##
# Normalizes tabs in +body+
Expand Down Expand Up @@ -295,14 +294,4 @@ def handle_tab_width(body)
require_relative 'parser/markdown'
require_relative 'parser/rd'

if ENV['RDOC_USE_RIPPER_PARSER']
puts "========================================================================="
puts "RDoc is using the deprecated Ripper parser to generate the documentation."
puts "This parser will be removed in a future version of RDoc."
puts "========================================================================="
require 'rdoc/parser/ripper_ruby'
RDoc::Parser::Ruby = RDoc::Parser::RipperRuby
else
require 'rdoc/parser/prism_ruby'
RDoc::Parser::Ruby = RDoc::Parser::PrismRuby
end
require_relative 'parser/ruby'
Loading