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

Conversation

jonathanhefner
Copy link
Member

RDoc includes extra whitespace in a method's parameter list when the the method's def statement is spread across multiple lines. For example, a def like:

def define_attribute(
  name,
  cast_type,
  default: NO_DEFAULT_PROVIDED,
  user_provided_default: true
)
  # ...
end

Would produce a parameter list like:

( name, cast_type, default: NO_DEFAULT_PROVIDED, user_provided_default: true )

This commit monkey-patches RDoc::AnyMethod#params to remove the extra whitespace within the parentheses:

(name, cast_type, default: NO_DEFAULT_PROVIDED, user_provided_default: true)

This is implemented as a monkey patch so that it fixes params for rendered method docs as well as search index entries.

Before After
before after

RDoc includes extra whitespace in a method's parameter list when the
the method's `def` statement is spread across multiple lines.  For
example, a `def` like:

  ```ruby
  def define_attribute(
    name,
    cast_type,
    default: NO_DEFAULT_PROVIDED,
    user_provided_default: true
  )
    # ...
  end
  ```

Would produce a parameter list like:

  ```
  ( name, cast_type, default: NO_DEFAULT_PROVIDED, user_provided_default: true )
  ```

This commit monkey-patches `RDoc::AnyMethod#params` to remove the extra
whitespace within the parentheses:

  ```
  (name, cast_type, default: NO_DEFAULT_PROVIDED, user_provided_default: true)
  ```

This is implemented as a monkey patch so that it fixes `params` for
rendered method docs as well as search index entries.
@jonathanhefner jonathanhefner merged commit 9443521 into rails:main Dec 24, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant