yard-thor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,65 @@
1
+ class YARD::Handlers::Processor
2
+ attr_accessor :extra_state
3
+ end
4
+
5
+ class ThorHandler < YARD::Handlers::Ruby::Base
6
+ namespace_only
7
+ handles method_call(:desc)
8
+
9
+ process do
10
+ parser.extra_state ||= {}
11
+ parser.extra_state[:thor_desc] = statement.parameters(false).map do |param|
12
+ param.jump(:string_content).source
13
+ end
14
+ end
15
+ end
16
+
17
+ class LegacyThorHandler < YARD::Handlers::Ruby::Legacy::Base
18
+ namespace_only
19
+ handles /\Adesc(\s|\()/
20
+
21
+ process do
22
+ parser.extra_state ||= {}
23
+ parser.extra_state[:thor_desc] = tokval_list(statement.tokens[1..-1], :attr)
24
+ end
25
+ end
26
+
27
+ module ThorMethodHandlerMixin
28
+ def register(*objs)
29
+ @registered_object = objs.first
30
+ super(*objs)
31
+ end
32
+
33
+ def process
34
+ super
35
+ return if parser.extra_state[:thor_desc].nil?
36
+ params, desc = *parser.extra_state[:thor_desc]
37
+ @registered_object.docstring = desc
38
+ @registered_object.signature = params
39
+ @registered_object.namespace.groups = ["Thor Commands"]
40
+ @registered_object.group = "Thor Commands"
41
+ @registered_object.docstring.add_tag YARD::Tags::Tag.new(:thor_command, '')
42
+ parser.extra_state.delete(:thor_desc)
43
+ end
44
+ end
45
+
46
+ class YARD::Handlers::Ruby::MethodHandler
47
+ include ThorMethodHandlerMixin
48
+ end
49
+
50
+ class YARD::Handlers::Ruby::Legacy::MethodHandler
51
+ include ThorMethodHandlerMixin
52
+ end
53
+
54
+ module YARD::Templates::Helpers::HtmlHelper
55
+ def signature_for_thor_command(meth, link = true, *args)
56
+ if meth.has_tag?(:thor_command)
57
+ sig = link ? link_object(meth, meth.signature) : meth.signature
58
+ "$ " + sig
59
+ else
60
+ old_signature(meth, link, *args)
61
+ end
62
+ end
63
+ alias old_signature signature
64
+ alias signature signature_for_thor_command
65
+ end
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'yard-thor'
3
+ s.version = '0.0.1'
4
+
5
+ s.summary = "Thor plugin for YARD."
6
+
7
+ s.authors = ["lsegal", "tutuMatilda"]
8
+ s.email = ["lsegal@soen.ca", "tutuMatilda@me.com"]
9
+
10
+ s.files = %w[
11
+ lib/yard-thor.rb
12
+ yard-thor.gemspec
13
+ README.markdown
14
+ ]
15
+
16
+ s.add_dependency 'yard'
17
+ s.add_dependency 'thor'
18
+
19
+ s.homepage = "http://github.com/tutuMatilda/yard-thor"
20
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-thor
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - lsegal
14
+ - tutuMatilda
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-06-28 00:00:00 -05:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: yard
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: thor
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ description:
51
+ email:
52
+ - lsegal@soen.ca
53
+ - tutuMatilda@me.com
54
+ executables: []
55
+
56
+ extensions: []
57
+
58
+ extra_rdoc_files: []
59
+
60
+ files:
61
+ - lib/yard-thor.rb
62
+ - yard-thor.gemspec
63
+ - README.markdown
64
+ has_rdoc: true
65
+ homepage: http://github.com/tutuMatilda/yard-thor
66
+ licenses: []
67
+
68
+ post_install_message:
69
+ rdoc_options: []
70
+
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ requirements: []
92
+
93
+ rubyforge_project:
94
+ rubygems_version: 1.6.2
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Thor plugin for YARD.
98
+ test_files: []
99
+