No commit activity in last 3 years
No release in over 3 years
This is a YARD extension that brings support for modules making use of ActiveSupport::Concern. It makes YARD parse docstrings inside included and class_methods blocks and generate the proper documentation for them.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0

Runtime

>= 0.8
 Project Readme

YARD ActiveSupport::Concern Plugin

Version Dependencies Downloads Open Github issues

This is a YARD extension that brings support for modules making use of ActiveSupport::Concern (very frequent in Rails projects). Here's an example of such module:

module M
  extend ActiveSupport::Concern

  included do
    # @!method disabled
    # @!scope class
    # @return [Collection<Model>] Return a scope to get all disabled records
    scope :disabled, -> { where(disabled: true) }
  end

  class_methods do
    # A quick way to get all published records
    # @return [Collection<Model>] Return a scope to get all published records
    def published
      where(published: true)
    end
  end
end

Because ActiveSupport::Concern moves method/attributes/... definitions inside included or class_methods blocks, YARD cannot document them out of the box. As a result, the docstrings in the above example won't show in the generated documentation.
For many, one workaround has been to move all comments above the included or class_methods blocks. But this decouples the comments from the actual method definitions and hence defeats the purpose of commenting your code.

This plugin is here to set this right and make YARD aware of those nested definitions.

Installation

Add the following line to your Gemfile:

gem 'yard-activesupport-concern'

Or install the gem globally:

gem install yard-activesupport-concern

You can then use the plugin using the --plugin activesupport-concern command-line option or by instructing YARD to always load all available plugins: yard config load_plugins true (see the docs)

If you're using a .yardopts file, just add the --plugin activesupport-concern option to it.

That's it!

License

This plugin is released under the MIT license. Please refer to the LICENSE file.

Contributing

Please refer to Github's guide to efficiently contribute to this project!