Skip to content

Commit e2d849f

Browse files
Fix URL paths for RDoc 6.13.0
ruby/rdoc@694987b removed support for `file_dir` and `class_dir`, which we used to prefix URL paths with `files/` or `classes/` (for example, in the URLs for https://api.rubyonrails.org/files/activerecord/lib/active_record/base_rb.html and https://api.rubyonrails.org/classes/ActiveRecord/Base.html). Note that RDoc < 6.13.0 _requires_ these methods when implementing a custom generator. Omitting them will cause RDoc to raise a `NoMethodError`. This commit monkey patches `RDoc::TopLevel` and `RDoc::ClassModule` to restore the behavior in way that is also compatible with RDoc < 6.13.0.
1 parent 805531f commit e2d849f

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/sdoc/generator.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ class RDoc::Generator::SDoc
2525

2626
DESCRIPTION = 'Searchable HTML documentation'
2727

28-
FILE_DIR = 'files'
29-
CLASS_DIR = 'classes'
30-
3128
RESOURCES_DIR = File.join('resources', '.')
3229

3330
attr_reader :options
@@ -94,11 +91,11 @@ def generate
9491
end
9592

9693
def class_dir
97-
CLASS_DIR
94+
nil
9895
end
9996

10097
def file_dir
101-
FILE_DIR
98+
nil
10299
end
103100

104101
### Determines index page based on @options.main_page (or lack thereof)

lib/sdoc/rdoc_monkey_patches.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
require "rdoc"
22

3+
RDoc::TopLevel.prepend(Module.new do
4+
def path
5+
File.join("files", super)
6+
end
7+
end)
8+
9+
10+
RDoc::ClassModule.prepend(Module.new do
11+
def path
12+
File.join("classes", super)
13+
end
14+
end)
15+
16+
317
RDoc::TopLevel.prepend(Module.new do
418
attr_writer :path
519

0 commit comments

Comments
 (0)