Skip to content

Commit d5331d0

Browse files
Support RDoc 8 formatter initialization (#2109)
* Support RDoc 8 formatter initialization Preserve positional options for RDoc 4–7 and use the keyword-based formatter defaults for RDoc 8. Add regression coverage and test RDoc 7.2 and 8.x in CI. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 04620c2c-d05c-4684-9275-33956737b425 * Allow RDoc 8 in runtime dependency Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 93ffdf64-9ffd-47b4-b3d4-96dda4ae722d * Apply suggestions from code review * Replace stubbed RDoc tests with version-gated tests Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 93ffdf64-9ffd-47b4-b3d4-96dda4ae722d * Update test/coverage_test.rb * Use a single RDoc rendering test Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 93ffdf64-9ffd-47b4-b3d4-96dda4ae722d * Test RDoc 8 on a single Ruby version Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 93ffdf64-9ffd-47b4-b3d4-96dda4ae722d * Rely on existing RDoc fixture test Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 93ffdf64-9ffd-47b4-b3d4-96dda4ae722d --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 04620c2c-d05c-4684-9275-33956737b425 Copilot-Session: 93ffdf64-9ffd-47b4-b3d4-96dda4ae722d
1 parent ea5a487 commit d5331d0

8 files changed

Lines changed: 27 additions & 14 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ permissions:
99

1010
jobs:
1111
build:
12-
name: "Test / Ruby ${{ matrix.ruby }}"
12+
name: "Test / Ruby ${{ matrix.ruby }} / RDoc ${{ matrix.rdoc }}"
1313
runs-on: ubuntu-latest
14+
env:
15+
RDOC_VERSION: "~> ${{ matrix.rdoc }}"
1416
strategy:
1517
matrix:
18+
rdoc:
19+
- "7.2.0"
1620
ruby:
1721
- "3.3"
1822
- "3.4"
1923
- "4.0"
24+
include:
25+
- ruby: "4.0"
26+
rdoc: "8.0"
2027
fail-fast: false
2128

2229
steps:
@@ -28,7 +35,11 @@ jobs:
2835
- uses: ruby/setup-ruby@a0102e0972be65f351c307e2d64b9314a57c8073 # v1
2936
with:
3037
ruby-version: ${{ matrix.ruby }}
31-
bundler-cache: true
38+
bundler-cache: ${{ matrix.rdoc == '7.2.0' }}
39+
40+
- name: Install RDoc 8 dependencies
41+
if: matrix.rdoc == '8.0'
42+
run: bundle update rdoc
3243

3344
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
3445
with:

‎CONTRIBUTING.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ To run the tests:
3737

3838
If nothing complains, congratulations!
3939

40+
CI tests RDoc 7.2 and 8.x. To test RDoc 8.x locally:
41+
42+
$ RDOC_VERSION='~> 8.0' bundle update rdoc
43+
$ RDOC_VERSION='~> 8.0' bundle exec rake
44+
4045
## Releasing a new version
4146

4247
If you are the current maintainer of this gem:

‎Gemfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ gem "redcarpet", :platforms => :ruby
55
gem "kramdown", :platforms => :jruby
66
gem "RedCloth"
77
gem "commonmarker", "~> 2.8.2"
8-
gem "rdoc", "~> 7.2.0"
8+
gem "rdoc", ENV.fetch("RDOC_VERSION", "~> 7.2.0")
99
gem "org-ruby", "0.9.12"
1010
gem "creole", "~>0.5.0"
1111
gem "wikicloth", "=0.8.3"

‎Gemfile.lock‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PATH
22
remote: .
33
specs:
44
github-markup (6.0.0)
5-
rdoc (< 8)
5+
rdoc (< 9)
66

77
GEM
88
remote: https://rubygems.org/

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ you wish to run the library. You can also run `script/bootstrap` to fetch them a
2121

2222
* [.markdown, .mdown, .mkdn, .md](http://daringfireball.net/projects/markdown/) -- `gem install commonmarker` (https://github.com/gjtorikian/commonmarker)
2323
* [.textile](https://textile-lang.com/) -- `gem install RedCloth` (https://github.com/jgarber/redcloth)
24-
* [.rdoc](https://ruby.github.io/rdoc/) -- `gem install rdoc -v 3.6.1`
24+
* [.rdoc](https://ruby.github.io/rdoc/) -- `gem install rdoc`
2525
* [.org](http://orgmode.org/) -- `gem install org-ruby` (https://github.com/wallyqs/org-ruby)
2626
* [.creole](http://wikicreole.org/) -- `gem install creole` (https://github.com/larsch/creole)
2727
* [.mediawiki, .wiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth` (https://github.com/nricciar/wikicloth)

‎github-markup.gemspec‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
2323
s.test_files = s.files.grep(%r{^(test|spec|features)/})
2424
s.require_paths = %w[lib]
2525

26-
s.add_dependency 'rdoc', '< 8'
26+
s.add_dependency 'rdoc', '< 9'
2727

2828
s.add_development_dependency 'rake', '~> 13'
2929
s.add_development_dependency 'activesupport', '~> 8.1.3'

‎lib/github/markup/rdoc.rb‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ def initialize
1010
end
1111

1212
def render(filename, content, options: {})
13-
if ::RDoc::VERSION.to_i >= 4
13+
# RDoc 4-7 require positional Options; RDoc 8 uses keyword options.
14+
# Each run covers only the installed RDoc's branch; CI tests both.
15+
# :nocov:
16+
if (4...8).cover?(::RDoc::VERSION.to_i)
1417
h = ::RDoc::Markup::ToHtml.new(::RDoc::Options.new)
1518
else
16-
# :nocov: RDoc < 4 has been unsupported since Ruby 2.4 (2016); modern RDoc requires Options.
1719
h = ::RDoc::Markup::ToHtml.new
18-
# :nocov:
1920
end
21+
# :nocov:
2022
h.convert(content)
2123
end
2224

‎test/coverage_test.rb‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ def test_try_require_returns_false_for_missing_gem
9494
refute md.send(:try_require, "github_markup_definitely_not_a_real_gem_#{Time.now.to_i}")
9595
end
9696

97-
# --- rdoc.rb legacy version branch --------------------------------------
98-
# The `RDoc::VERSION < 4` branch in rdoc.rb is marked :nocov: in source
99-
# because the modern RDoc::Markup::ToHtml constructor requires Options
100-
# and the legacy zero-arg form has been broken since RDoc 4 (2013).
101-
10297
# --- implementation.rb default render and Linguist-less match? ---------
10398

10499
def test_base_implementation_render_raises_not_implemented_error

0 commit comments

Comments
 (0)