Remove rubocop comments from Yardoc documentation
Asked Answered
W

1

6

We are using Yardoc to create the HTML documentation for a number of gems and my company's apps. We are also using Rubocop to for style guide compliance.

The issue I am running into is that we have to enable/disable some of the method metrics and those comments (# rubocop:disable Metrics/AbcSize, etc...) showing up in our documentation. Is there a plugin that removes these or some guide I can follow on creating my own?

Winer answered 5/3, 2018 at 20:18 Comment(5)
If I understand it right, you want to disable these metrics only for certain methods. you can try to pull out those methods into a separate module/file and then ignore that file through the .rubocop.yml file. That way you don't need to have the # rubocop:disable comment in the code.Forzando
The methods should probably remain where they are. I think it would weird to pull out a single method just to satisfy rubocop.Winer
Assuming you are putting the # rubocop:disable before documentation comments of a method, can you try inserting an extra newline after this line? does that fix your issue?Forzando
@Forzando That did the trick! Thanks!Winer
Great. Please mark my answer as the correct answer in that case. It would help to close out this question as well as help others with a documented answer.Forzando
F
6

To disable rubocop directives in the code from appearing in YARDOC documentation insert a newline after the comment. e.g.

# rubocop:disable Metrics/AbcSize

# Converts the object into textual markup given a specific format.
#
# @param format [Symbol] the format type, `:text` or `:html`
# @return [String] the object converted into the expected format.
def to_format(format = :html)
  # format the object
end
Forzando answered 12/3, 2018 at 4:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.