yard-activesupport-concern 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +61 -0
- data/Rakefile +2 -0
- data/lib/yard-activesupport-concern.rb +40 -0
- data/lib/yard-activesupport-concern/version.rb +7 -0
- data/yard-activesupport-concern.gemspec +26 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 17cabe4df50f23e68b4d014361ef3fd2e0def52f
|
4
|
+
data.tar.gz: 5f206dfaf1986e8746ecbfbd3a4d4babe129063c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1c7075dcd996f4345299f4e7c1776db7882e4bfc2a4e22d25508b04fab9d98a48549805fd8887c7c520a969d6ff50a713e04c05a7de5c05cf85b36136ed91f97
|
7
|
+
data.tar.gz: 76da86df5d55fdf525431c22eb11c08b0a5c3ae14a4ae026b3cbb82d9548a9e351e052ccbe91435a91fa3b3409099dbd34d6b5a9682ce080728cb511d9b8af8f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 digital cuisine
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# YARD ActiveSupport::Concern Plugin
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/yard-activesupport-concern)
|
4
|
+
[](https://rubygems.org/gems/yard-activesupport-concern)
|
5
|
+
[](https://github.com/digitalcuisine/yard-activesupport-concern/issues)
|
6
|
+
|
7
|
+
This is a [YARD](https://github.com/lsegal/yard) extension that brings support for modules making use of `ActiveSupport::Concern` (very frequent in Rails projects). Here's an example of such module:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
module M
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
|
13
|
+
included do
|
14
|
+
# @!method disabled
|
15
|
+
# @!scope class
|
16
|
+
# @return [Collection<Model>] Return a scope to get all disabled records
|
17
|
+
scope :disabled, -> { where(disabled: true) }
|
18
|
+
end
|
19
|
+
|
20
|
+
class_methods do
|
21
|
+
# A quick way to get all published records
|
22
|
+
# @return [Collection<Model>] Return a scope to get all published records
|
23
|
+
def published
|
24
|
+
where(published: true)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
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.
|
31
|
+
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.
|
32
|
+
|
33
|
+
This plugin is here to set this right and make YARD aware of those nested definitions.
|
34
|
+
|
35
|
+
## Installation
|
36
|
+
|
37
|
+
Add the following line to your Gemfile:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
gem 'yard-activesupport-concern'
|
41
|
+
```
|
42
|
+
|
43
|
+
Or install the gem globally:
|
44
|
+
|
45
|
+
`gem install yard-activesupport-concern`
|
46
|
+
|
47
|
+
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](http://www.rubydoc.info/gems/yard/YARD/Config#load_plugins-class_method))
|
48
|
+
|
49
|
+
If you're using a `.yardopts` file, just add the `--plugin activesupport-concern` option to it.
|
50
|
+
|
51
|
+
That's it!
|
52
|
+
|
53
|
+
|
54
|
+
## License
|
55
|
+
|
56
|
+
This plugin is released under the MIT license. Please refer to the [LICENSE](https://github.com/digitalcuisine/yard-activesupport-concern/blob/master/LICENSE) file.
|
57
|
+
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
Please refer to Github's [guide](https://guides.github.com/activities/contributing-to-open-source/#contributing) to efficiently contribute to this project!
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'yard-activesupport-concern/version'
|
2
|
+
require 'yard'
|
3
|
+
|
4
|
+
module YARD
|
5
|
+
module ActiveSupport
|
6
|
+
module Concern
|
7
|
+
|
8
|
+
class IncludedHandler < YARD::Handlers::Ruby::Base
|
9
|
+
handles method_call(:included)
|
10
|
+
namespace_only
|
11
|
+
|
12
|
+
# Process any found `included` block within a "namespace" scope (class
|
13
|
+
# or module).
|
14
|
+
def process
|
15
|
+
# `statement.last.last` refers to the statements within the block
|
16
|
+
# given to `included`. YARD will parse those and attach any generated
|
17
|
+
# documentation to the current namespace at the instance level (unless
|
18
|
+
# overridden with a @!scope directive)
|
19
|
+
parse_block(statement.last.last, namespace: namespace, scope: :instance)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class ClassMethodsHandler < YARD::Handlers::Ruby::Base
|
24
|
+
handles method_call(:class_methods)
|
25
|
+
namespace_only
|
26
|
+
|
27
|
+
# Process any found `class_methods` block within a "namespace" scope
|
28
|
+
# (class or module).
|
29
|
+
def process
|
30
|
+
# `statement.last.last` refers to the statements within the block
|
31
|
+
# given to `class_methods`. YARD will parse those and attach any
|
32
|
+
# generated documentation to the current namespace at the class
|
33
|
+
# level (unless overridden with a @!scope directive)
|
34
|
+
parse_block(statement.last.last, namespace: namespace, scope: :class)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'yard-activesupport-concern/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'yard-activesupport-concern'
|
8
|
+
spec.version = YARD::ActiveSupport::Concern::VERSION
|
9
|
+
spec.authors = ['Olivier Lance @ Digital cuisine']
|
10
|
+
spec.email = ['olivier@digitalcuisine.fr']
|
11
|
+
spec.summary = %q{A YARD plugin to handle modules using ActiveSupport::Concern}
|
12
|
+
spec.description = %q{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.}
|
13
|
+
spec.homepage = 'https://github.com/digitalcuisine/yard-activesupport-concern'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
|
24
|
+
spec.add_dependency 'yard', '>= 0.8'
|
25
|
+
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yard-activesupport-concern
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Olivier Lance @ Digital cuisine
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: yard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.8'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.8'
|
55
|
+
description: This is a YARD extension that brings support for modules making use of
|
56
|
+
ActiveSupport::Concern. It makes YARD parse docstrings inside included and class_methods
|
57
|
+
blocks and generate the proper documentation for them.
|
58
|
+
email:
|
59
|
+
- olivier@digitalcuisine.fr
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- lib/yard-activesupport-concern.rb
|
70
|
+
- lib/yard-activesupport-concern/version.rb
|
71
|
+
- yard-activesupport-concern.gemspec
|
72
|
+
homepage: https://github.com/digitalcuisine/yard-activesupport-concern
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.4.5
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: A YARD plugin to handle modules using ActiveSupport::Concern
|
96
|
+
test_files: []
|
97
|
+
has_rdoc:
|