Skip to content

Commit

Permalink
Merge pull request #352 from jonathanhefner/method-signature-remove-e…
Browse files Browse the repository at this point in the history
…xtra-whitespace

Remove extra whitespace in method signature params
  • Loading branch information
jonathanhefner authored Dec 24, 2023
2 parents b1153b4 + 43384df commit 9443521
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/sdoc/rdoc_monkey_patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ def path
end)


RDoc::AnyMethod.prepend(Module.new do
def params
super&.sub(/\A\(\s+/, "(")&.sub(/\s+\)\z/, ")")
end
end)


RDoc::Markup::ToHtmlCrossref.prepend(Module.new do
def cross_reference(name, text = nil, code = true)
if text
Expand Down
17 changes: 17 additions & 0 deletions spec/rdoc_monkey_patches_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@
end
end

describe RDoc::AnyMethod do
it "omits extra whitespace in #params" do
rdoc_method = rdoc_top_level_for(<<~RUBY).find_module_named("Foo").find_method("bar", false)
module Foo
def bar(
x,
y,
z
)
end
end
RUBY

_(rdoc_method.params).must_equal "(x, y, z)"
end
end

describe RDoc::Markup::ToHtmlCrossref do
it "prevents unintentional ref links" do
description = rdoc_top_level_for(<<~RUBY).find_module_named("CoolApp").description
Expand Down

0 comments on commit 9443521

Please sign in to comment.