yard-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1 @@
1
+ --color --format documentation
@@ -0,0 +1,5 @@
1
+ --markup markdown
2
+ --title 'yard-rails Documentation'
3
+ --protected
4
+ --files ChangeLog.md,LICENSE.txt
5
+
@@ -0,0 +1,5 @@
1
+ ### 0.1.0 / 2011-10-02
2
+
3
+ * Initial release:
4
+ * Parse `{c,m}attr_*` Rails constructs as class attributes
5
+
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'yard', :group => [:development, :runtime]
4
+
5
+ group(:development) do
6
+ gem 'rake'
7
+ gem 'jeweler'
8
+ gem 'gemcutter'
9
+ end
10
+
11
+ group(:doc) do
12
+ case RUBY_PLATFORM
13
+ when 'java'
14
+ gem 'maruku'
15
+ else
16
+ gem 'rdiscount'
17
+ end
18
+ end
19
+
20
+ gem 'rspec', :group => [:development, :test]
21
+
22
+
@@ -0,0 +1,32 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ gemcutter (0.7.0)
6
+ git (1.2.5)
7
+ jeweler (1.6.4)
8
+ bundler (~> 1.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ rake (0.9.2)
12
+ rdiscount (1.6.8)
13
+ rspec (2.6.0)
14
+ rspec-core (~> 2.6.0)
15
+ rspec-expectations (~> 2.6.0)
16
+ rspec-mocks (~> 2.6.0)
17
+ rspec-core (2.6.4)
18
+ rspec-expectations (2.6.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.6.0)
21
+ yard (0.7.2)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ gemcutter
28
+ jeweler
29
+ rake
30
+ rdiscount
31
+ rspec
32
+ yard
@@ -0,0 +1,24 @@
1
+
2
+ Copyright (c) 2011 Charles H. Pence
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ 'Software'), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+
24
+
@@ -0,0 +1,49 @@
1
+ # yard-rails
2
+
3
+ * [github.com/cpence/yard-rails](http://github.com/cpence/yard-rails/)
4
+ * [github.com/cpence/yard-rails/issues](http://github.com/cpence/yard-rails/issues)
5
+ * Charles Pence (charles at charlespence.net)
6
+
7
+ ## Description
8
+
9
+ A YARD plugin for parsing the custom Ruby syntax added by Rails.
10
+
11
+ If you are using YARD >= 0.6, you will need to enable the plugin manually. Add
12
+ the following line to your `.yardopts` file:
13
+
14
+ --plugin yard-rails
15
+
16
+ For older versions of YARD, all plugins are loaded automatically.
17
+
18
+ ## Features
19
+
20
+ Parses the following statements:
21
+
22
+ cattr_reader :attr
23
+
24
+ cattr_writer :attr
25
+
26
+ cattr_accessor :attr
27
+
28
+ mattr_reader :attr
29
+
30
+ mattr_writer :attr
31
+
32
+ mattr_accessor :attr
33
+
34
+ ## Requirements
35
+
36
+ * [yard](http://yardoc.org) >= 0.4.0
37
+
38
+ ## Install
39
+
40
+ $ sudo gem install yard-rails
41
+
42
+ ## License
43
+
44
+ See LICENSE.txt for license information.
45
+
46
+ ## Thanks
47
+
48
+ Thanks to Postmodern's `yard-dm` gem, which provided much of the framework
49
+ I've used to package `yard-rails`.
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ begin
5
+ Bundler.setup(:development, :doc)
6
+ rescue Bundler::BundlerError => e
7
+ STDERR.puts e.message
8
+ STDERR.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+
12
+ require 'rake'
13
+ require 'jeweler'
14
+
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = 'yard-rails'
17
+ gem.license = 'MIT'
18
+ gem.summary = %Q{A YARD plugin for parsing custom Rails syntax.}
19
+ gem.description = %Q{Rails includes several bits of custom markup (such as the new "cattr_*" methods). This plugin for YARD adds support for this custom markup, which otherwise is parsed incorrectly.}
20
+ gem.email = 'charles@charlespence.net'
21
+ gem.homepage = 'http://github.com/cpence/yard-rails'
22
+ gem.authors = ['Charles H. Pence']
23
+ gem.has_rdoc = 'yard'
24
+ end
25
+
26
+ require 'rspec/core/rake_task'
27
+ RSpec::Core::RakeTask.new(:rspec) do |spec|
28
+ # The automatic bundler detecton causes trouble on my
29
+ # development machine.
30
+ spec.skip_bundler = true
31
+ spec.rspec_opts = ['--options', '.specopts']
32
+ end
33
+
34
+ task :test => :rspec
35
+ task :default => :rspec
36
+
37
+ require 'yard'
38
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1,2 @@
1
+ 0.1.0
2
+
@@ -0,0 +1,2 @@
1
+ require 'yard-rails/class_attribute_handler'
2
+ require 'yard-rails/legacy/class_attribute_handler'
@@ -0,0 +1,25 @@
1
+ require 'yard/parser/ruby/ast_node'
2
+
3
+ module YARD
4
+ module Rails
5
+ class ClassAttributeHandler < YARD::Handlers::Ruby::AttributeHandler
6
+ handles method_call(:cattr_accessor)
7
+ handles method_call(:cattr_reader)
8
+ handles method_call(:cattr_writer)
9
+ handles method_call(:mattr_accessor)
10
+ handles method_call(:mattr_reader)
11
+ handles method_call(:mattr_writer)
12
+ namespace_only
13
+
14
+ def process
15
+ # HACK: Strip the [c,m] off of the front of the method, so that
16
+ # AttributeHandler will be able to correctly detect the resulting
17
+ # method as read/write.
18
+ name = statement[0].source[1..-1]
19
+ statement[0] = YARD::Parser::Ruby::AstNode.node_class_for(:ident).new(:ident, [name])
20
+
21
+ push_state(:scope => :class) { super }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+
2
+ module YARD
3
+ module Rails
4
+ module Legacy
5
+ class ClassAttributeHandler < YARD::Handlers::Ruby::Legacy::AttributeHandler
6
+ handles /\A[cm]attr_(reader|writer|accessor)(?:\s|\()/
7
+ namespace_only
8
+
9
+ def process
10
+ # HACK: Strip the [c,m] off of the front of the method, so that
11
+ # AttributeHandler will be able to correctly detect the resulting
12
+ # method as read/write.
13
+ new_text = statement.tokens.first.text.to_s[1..-1]
14
+ statement.tokens.first.set_text(new_text)
15
+
16
+ push_state(:scope => :class) { super }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+ require 'helpers/examples'
3
+
4
+ require 'yard-rails/class_attribute_handler'
5
+ require 'yard-rails/legacy/class_attribute_handler'
6
+
7
+ describe "ClassAttributeHandler" do
8
+ include Helpers::Examples
9
+
10
+ describe "valid" do
11
+ before(:all) do
12
+ parse_file :simple_cattrs
13
+ end
14
+
15
+ it "should define a class method for the cattr_reader method" do
16
+ yard('SimpleCattrs.num_widgets').should be_instance_of(CodeObjects::MethodObject)
17
+ end
18
+
19
+ it "should define a class method for the cattr_writer method" do
20
+ yard('SimpleCattrs.widget_destination=').should be_instance_of(CodeObjects::MethodObject)
21
+ end
22
+
23
+ it "should define reader class method for the cattr_accessor method" do
24
+ yard('SimpleCattrs.widget_type').should be_instance_of(CodeObjects::MethodObject)
25
+ end
26
+
27
+ it "should define writer class method for the cattr_accessor method" do
28
+ yard('SimpleCattrs.widget_type=').should be_instance_of(CodeObjects::MethodObject)
29
+ end
30
+
31
+ it "should define a class method for the mattr_reader method" do
32
+ yard('SimpleCattrs.num_sprockets').should be_instance_of(CodeObjects::MethodObject)
33
+ end
34
+
35
+ it "should define a class method for the mattr_writer method" do
36
+ yard('SimpleCattrs.sprocket_destination=').should be_instance_of(CodeObjects::MethodObject)
37
+ end
38
+
39
+ it "should define reader class method for the mattr_accessor method" do
40
+ yard('SimpleCattrs.sprocket_type').should be_instance_of(CodeObjects::MethodObject)
41
+ end
42
+
43
+ it "should define writer class method for the mattr_accessor method" do
44
+ yard('SimpleCattrs.sprocket_type=').should be_instance_of(CodeObjects::MethodObject)
45
+ end
46
+ end
47
+
48
+ describe "legacy" do
49
+ before(:all) do
50
+ parse_file :simple_cattrs, true
51
+ end
52
+
53
+ it "should define a class method for the cattr_reader method" do
54
+ yard('SimpleCattrs.num_widgets').should be_instance_of(CodeObjects::MethodObject)
55
+ end
56
+
57
+ it "should define a class method for the cattr_writer method" do
58
+ yard('SimpleCattrs.widget_destination=').should be_instance_of(CodeObjects::MethodObject)
59
+ end
60
+
61
+ it "should define reader class method for the cattr_accessor method" do
62
+ yard('SimpleCattrs.widget_type').should be_instance_of(CodeObjects::MethodObject)
63
+ end
64
+
65
+ it "should define writer class method for the cattr_accessor method" do
66
+ yard('SimpleCattrs.widget_type=').should be_instance_of(CodeObjects::MethodObject)
67
+ end
68
+
69
+ it "should define a class method for the mattr_reader method" do
70
+ yard('SimpleCattrs.num_sprockets').should be_instance_of(CodeObjects::MethodObject)
71
+ end
72
+
73
+ it "should define a class method for the mattr_writer method" do
74
+ yard('SimpleCattrs.sprocket_destination=').should be_instance_of(CodeObjects::MethodObject)
75
+ end
76
+
77
+ it "should define reader class method for the mattr_accessor method" do
78
+ yard('SimpleCattrs.sprocket_type').should be_instance_of(CodeObjects::MethodObject)
79
+ end
80
+
81
+ it "should define writer class method for the mattr_accessor method" do
82
+ yard('SimpleCattrs.sprocket_type=').should be_instance_of(CodeObjects::MethodObject)
83
+ end
84
+ end
85
+ end
86
+
@@ -0,0 +1,24 @@
1
+ require 'yard'
2
+
3
+ module Helpers
4
+ module Examples
5
+ EXAMPLES_DIR = File.expand_path(File.join(File.dirname(__FILE__),'examples'))
6
+
7
+ def parse_file(file, legacy = false, thisfile = __FILE__)
8
+ YARD::Registry.clear
9
+
10
+ if legacy
11
+ YARD::Parser::SourceParser.parser_type = :ruby18
12
+ else
13
+ YARD::Parser::SourceParser.parser_type = :ruby
14
+ end
15
+
16
+ path = File.join(Helpers::Examples::EXAMPLES_DIR, "#{file}.rb.txt")
17
+ YARD::Parser::SourceParser.parse(path)
18
+ end
19
+
20
+ def yard(name)
21
+ YARD::Registry.at(name)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ class SimpleCattrs
2
+ cattr_reader :num_widgets
3
+ cattr_writer :widget_destination
4
+ cattr_accessor :widget_type
5
+
6
+ mattr_reader :num_sprockets
7
+ mattr_writer :sprocket_destination
8
+ mattr_accessor :sprocket_type
9
+ end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ begin
5
+ Bundler.setup(:runtime, :test)
6
+ rescue Bundler::BundlerError => e
7
+ STDERR.puts e.message
8
+ STDERR.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+
12
+ require 'rspec'
13
+ require 'yard'
14
+
15
+ include YARD
@@ -0,0 +1,7 @@
1
+ require 'yard'
2
+
3
+ YARD::Rake::YardocTask.new do |t|
4
+ t.files = ['lib/**/*.rb']
5
+ end
6
+
7
+ task :docs => :yard
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "yard-rails"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Charles H. Pence"]
12
+ s.date = "2011-10-02"
13
+ s.description = "Rails includes several bits of custom markup (such as the new \"cattr_*\" methods). This plugin for YARD adds support for this custom markup, which otherwise is parsed incorrectly."
14
+ s.email = "charles@charlespence.net"
15
+ s.extra_rdoc_files = [
16
+ "ChangeLog.md",
17
+ "LICENSE.txt",
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ ".gemtest",
22
+ ".specopts",
23
+ ".yardopts",
24
+ "ChangeLog.md",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE.txt",
28
+ "README.md",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "lib/yard-rails.rb",
32
+ "lib/yard-rails/class_attribute_handler.rb",
33
+ "lib/yard-rails/legacy/class_attribute_handler.rb",
34
+ "spec/class_attribute_handler_spec.rb",
35
+ "spec/helpers/examples.rb",
36
+ "spec/helpers/examples/simple_cattrs.rb.txt",
37
+ "spec/spec_helper.rb",
38
+ "tasks/yard.rb",
39
+ "yard-rails.gemspec"
40
+ ]
41
+ s.homepage = "http://github.com/cpence/yard-rails"
42
+ s.licenses = ["MIT"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = "1.8.10"
45
+ s.summary = "A YARD plugin for parsing custom Rails syntax."
46
+
47
+ if s.respond_to? :specification_version then
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_runtime_dependency(%q<yard>, [">= 0"])
52
+ s.add_development_dependency(%q<yard>, [">= 0"])
53
+ s.add_development_dependency(%q<rake>, [">= 0"])
54
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
55
+ s.add_development_dependency(%q<rspec>, [">= 0"])
56
+ else
57
+ s.add_dependency(%q<yard>, [">= 0"])
58
+ s.add_dependency(%q<yard>, [">= 0"])
59
+ s.add_dependency(%q<rake>, [">= 0"])
60
+ s.add_dependency(%q<jeweler>, [">= 0"])
61
+ s.add_dependency(%q<rspec>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<yard>, [">= 0"])
65
+ s.add_dependency(%q<yard>, [">= 0"])
66
+ s.add_dependency(%q<rake>, [">= 0"])
67
+ s.add_dependency(%q<jeweler>, [">= 0"])
68
+ s.add_dependency(%q<rspec>, [">= 0"])
69
+ end
70
+ end
71
+
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Charles H. Pence
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-02 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: yard
16
+ requirement: &2157121280 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2157121280
25
+ - !ruby/object:Gem::Dependency
26
+ name: yard
27
+ requirement: &2157120780 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2157120780
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &2157120280 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2157120280
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &2157119740 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2157119740
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &2157119220 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2157119220
69
+ description: Rails includes several bits of custom markup (such as the new "cattr_*"
70
+ methods). This plugin for YARD adds support for this custom markup, which otherwise
71
+ is parsed incorrectly.
72
+ email: charles@charlespence.net
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files:
76
+ - ChangeLog.md
77
+ - LICENSE.txt
78
+ - README.md
79
+ files:
80
+ - .gemtest
81
+ - .specopts
82
+ - .yardopts
83
+ - ChangeLog.md
84
+ - Gemfile
85
+ - Gemfile.lock
86
+ - LICENSE.txt
87
+ - README.md
88
+ - Rakefile
89
+ - VERSION
90
+ - lib/yard-rails.rb
91
+ - lib/yard-rails/class_attribute_handler.rb
92
+ - lib/yard-rails/legacy/class_attribute_handler.rb
93
+ - spec/class_attribute_handler_spec.rb
94
+ - spec/helpers/examples.rb
95
+ - spec/helpers/examples/simple_cattrs.rb.txt
96
+ - spec/spec_helper.rb
97
+ - tasks/yard.rb
98
+ - yard-rails.gemspec
99
+ homepage: http://github.com/cpence/yard-rails
100
+ licenses:
101
+ - MIT
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.10
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: A YARD plugin for parsing custom Rails syntax.
124
+ test_files: []