Fix circular require of RDoc::Parser::RubyColorizer#1709
Merged
Conversation
Collaborator
|
🚀 Preview deployment available at: https://caa4c640.rdoc-6cd.pages.dev (commit: 47f155f) |
There was a problem hiding this comment.
Pull request overview
Fixes a circular require warning triggered when autoloading RDoc::Markup::ToHtml (via require 'rdoc') by removing direct ruby_colorizer requires that caused RDoc::Parser to be autoloaded mid-load.
Changes:
- Removed
ruby_colorizerrequires fromRDoc::Parser::RubyandRDoc::Markup::ToHtmlto break the problematic load chain. - Added
parser/ruby_colorizerloading tolib/rdoc/parser.rbso the colorizer is available when the parser is loaded. - Updated the RubyColorizer test to rely on autoloading instead of directly requiring the colorizer.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/rdoc/parser/ruby_colorizer_test.rb | Stops requiring rdoc/parser/ruby_colorizer directly in tests. |
| lib/rdoc/parser/ruby.rb | Removes require_relative 'ruby_colorizer' to avoid circular require. |
| lib/rdoc/parser.rb | Loads parser/ruby_colorizer from the parser entrypoint. |
| lib/rdoc/markup/to_html.rb | Removes direct require of rdoc/parser/ruby_colorizer to avoid triggering circular require during autoload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
293
to
+297
| require_relative 'parser/changelog' | ||
| require_relative 'parser/markdown' | ||
| require_relative 'parser/rd' | ||
|
|
||
| require_relative 'parser/ruby' | ||
| require_relative 'parser/ruby_colorizer' |
Comment on lines
1
to
5
| # frozen_string_literal: true | ||
| require 'cgi/escape' | ||
| require 'cgi/util' unless defined?(CGI::EscapeExt) | ||
| require 'prism' | ||
| require 'rdoc/parser/ruby_colorizer' | ||
|
|
Loading RubyColorizer will trigger autoload of RDoc::Parser, and `require_relative 'parser/ruby'`. `parser/ruby.rb` shouldn't require `ruby_colorizer.rb` to avoid circular require.
82fff09 to
47f155f
Compare
st0012
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Loading
RubyColorizerwill trigger autoload ofRDoc::Parser, andrequire_relative 'parser/ruby'.parser/ruby.rbshouldn't requireruby_colorizer.rbto avoid circular require.Originally found in
rake testlog, but can be reproduced with: