Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extra whitespace in method signature params #352

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