5

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?

Joe
  • 41,484
  • 20
  • 104
  • 125
HMCFletch
  • 1,046
  • 1
  • 10
  • 19
  • 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. – sxm1972 Mar 06 '18 at 13:06
  • The methods should probably remain where they are. I think it would weird to pull out a single method just to satisfy rubocop. – HMCFletch Mar 06 '18 at 19:27
  • 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? – sxm1972 Mar 08 '18 at 06:03
  • @sxm1972 That did the trick! Thanks! – HMCFletch Mar 09 '18 at 15:35
  • 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. – sxm1972 Mar 12 '18 at 04:02

1 Answers1

5

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
sxm1972
  • 722
  • 8
  • 15