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?
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With