Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai Weibull committed Apr 6, 2012
0 parents commit 1bc9beb
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
*.gem
7 changes: 7 additions & 0 deletions README
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
YARD Method Overrides

A YARD plugin that adds tags for specifying method overrides. The tags added
are @extension and @override, which allow you to tag a method as either an
extension of a superclass’ definition or a complete override of a superclass’
definition. This makes it easy for the reader to see what’s going on may
read up on what may be going on in the superclass.
15 changes: 15 additions & 0 deletions Rakefile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-

require 'inventory/rake/tasks'

$:.unshift File.expand_path('../lib', __FILE__)
require 'yard-method-overrides/version'

Inventory::Rake::Tasks.define YardMethodOverrides::Version, :gem => proc{ |_, s|
s.author = 'Nikolai Weibull'
s.email = 'now@bitwi.se'
s.homepage = 'https://github.com/now/yard-method-overrides'

s.add_runtime_dependency 'inventory', '~> 0.2.0'
s.add_runtime_dependency 'yard', '~> 0.7.0'
}
5 changes: 5 additions & 0 deletions lib/yard-method-overrides.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-

YARD::Templates::Engine.register_template_path File.expand_path('../../templates', __FILE__)
YARD::Tags::Library.define_tag 'Extending Method', :extension
YARD::Tags::Library.define_tag 'Overriding Method', :override
19 changes: 19 additions & 0 deletions lib/yard-method-overrides/version.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-

require 'inventory'

module YardMethodOverrides
Version = Inventory.new(0, 1, 0){
def additional_files
%w'
templates/default/tags/html/extension.erb
templates/default/tags/html/override.erb
templates/default/tags/setup.rb
'
end

def unit_tests
[]
end
}
end
1 change: 1 addition & 0 deletions templates/default/tags/html/extension.erb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
<p>This method is an extension of <%= linkify(object.overridden_method) %>.</p>
1 change: 1 addition & 0 deletions templates/default/tags/html/override.erb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
<p>This method overrides <%= linkify(object.overridden_method) %>.</p>
13 changes: 13 additions & 0 deletions templates/default/tags/setup.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-

def init
sections.push :extension, :override
end

def extension
erb(:extension) if object.has_tag? :extension and object.respond_to? :overridden_method and object.overridden_method
end

def override
erb(:override) if object.has_tag? :override and object.respond_to? :overridden_method and object.overridden_method
end

0 comments on commit 1bc9beb

Please sign in to comment.