Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove rubocop comments from Yardoc documentation

Tags:

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?

like image 359
HMCFletch Avatar asked Mar 05 '18 20:03

HMCFletch


People also ask

How do you ignore RuboCop?

There is a way to ignore cops on a per-line basis. There is also a way to do it via the configuration file. Run rubocop --auto-gen-config and it will generate a file that you can use to disable the offenses. The command also gives a hint on what to do to load those options.

What is RuboCop in Ruby?

RuboCop is a Ruby static code analyzer (a.k.a. linter ) and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide. Apart from reporting the problems discovered in your code, RuboCop can also automatically fix many of them for you.


1 Answers

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
like image 115
sxm1972 Avatar answered Oct 11 '22 15:10

sxm1972