Hiding a method from YARD (the right way)

I use YARD to document one of my Ruby projects. I have certain methods that I don’t want to include in the documentation, things like #inspect and #to_s that you expect to exist, and return a reasonable result.

You can hide these methods using the yardoc --no-private tag and the yardoc --no-private command line yardoc --no-private :

 # @private let not document this def inspect; ...; end 

However, the YARD documentation on @private explicitly states:

Note. This method is not recommended to hide undocumented or "unimportant" methods. This tag should only be used to indicate private objects when Ruby's visibility rules cannot do this.

If I use @api private instead, YARD (beautifully) tags methods with in the documentation, but still shows them.

Is there a β€œlegitimate” way to hide methods from YARD output?

+5
source share
1 answer

From my limited tests, I noticed that the following works well (and does not have an explicit note in the documentation to avoid your use):

 # @!visibility private def inspect; ...; end 

According to the documentation shortcut :

@! public visibility | protected | private

Changes the current parsing visibility (public, secure, or private).

Hope this helps.

+6
source

Source: https://habr.com/ru/post/1207227/


All Articles