shomen-yard 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby +54 -0
- data/.yardopts +7 -0
- data/HISTORY.md +11 -0
- data/LICENSE.txt +28 -0
- data/README.md +7 -0
- data/bin/shomen-yard +3 -0
- data/lib/shomen-yard.rb +32 -0
- data/lib/shomen-yard/command.rb +160 -0
- data/lib/shomen-yard/generator.rb +586 -0
- data/spec/01_metadata.rdoc +24 -0
- data/spec/02_class.rdoc +63 -0
- data/spec/03_module.rdoc +59 -0
- data/spec/04_constant.rdoc +59 -0
- data/spec/05_method.rdoc +286 -0
- data/spec/10_interface_overloading.rdoc +97 -0
- data/spec/applique/ae.rb +1 -0
- data/spec/applique/shomen.rb +24 -0
- data/spec/fixture/lib/example.rb +52 -0
- metadata +102 -0
@@ -0,0 +1,97 @@
|
|
1
|
+
== YARD Method Signature Overloading
|
2
|
+
|
3
|
+
YARD supports the `@overload` tag for defining "virtual" method interfaces.
|
4
|
+
Given a file +lib/example.rb+ containing a class with a documented method
|
5
|
+
using the overload tag:
|
6
|
+
|
7
|
+
class ExampleClass
|
8
|
+
# Example method using overload directive.
|
9
|
+
#
|
10
|
+
# @overload my_method(flazm, saszm)
|
11
|
+
# @param [String] flazm
|
12
|
+
# @param [String] saszm
|
13
|
+
#
|
14
|
+
# @overload my_method(bunny){ |ears| ... } -> true or false
|
15
|
+
# @param [String] bunny
|
16
|
+
#
|
17
|
+
def my_method(a1,a2=nil,&b)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Running the script through shomen via yard the signatures list should have
|
22
|
+
three entries, the literal interface and the two virtual interfaces.
|
23
|
+
|
24
|
+
example = @shomen['ExampleClass#my_method']
|
25
|
+
example['interfaces'].size #=> 3
|
26
|
+
|
27
|
+
=== Literal Interface
|
28
|
+
|
29
|
+
Lets get a closer look at the last signature, which is alway the literal
|
30
|
+
interface.
|
31
|
+
|
32
|
+
signature = example['interfaces'].last
|
33
|
+
|
34
|
+
The first signature should match the literal definition.
|
35
|
+
|
36
|
+
signature['signature'] #=> 'my_method(a1,a2=nil,&b)'
|
37
|
+
|
38
|
+
And the arguments should be detailed as expected.
|
39
|
+
|
40
|
+
signature['arguments'][0]['name'] #=> 'a1'
|
41
|
+
signature['arguments'][0]['default'] #=> nil
|
42
|
+
|
43
|
+
signature['arguments'][1]['name'] #=> 'a2'
|
44
|
+
signature['arguments'][1]['default'] #=> 'nil'
|
45
|
+
|
46
|
+
As should the block argument.
|
47
|
+
|
48
|
+
signature['block']['name'] #=> '&b'
|
49
|
+
|
50
|
+
=== Virtual Interface
|
51
|
+
|
52
|
+
The second and third signatures should conform to those given in
|
53
|
+
under the `:call-seq:` directive.
|
54
|
+
|
55
|
+
Lets get a closer look at the first of these.
|
56
|
+
|
57
|
+
signature = example['interfaces'][0]
|
58
|
+
|
59
|
+
The signature should match the provided image.
|
60
|
+
|
61
|
+
signature['signature'] #=> 'my_method(flazm, saszm)'
|
62
|
+
|
63
|
+
And the arguments should be detailed as expected.
|
64
|
+
|
65
|
+
signature['arguments'][0]['name'] #=> 'flazm'
|
66
|
+
signature['arguments'][0]['default'] #=> nil
|
67
|
+
|
68
|
+
signature['arguments'][1]['name'] #=> 'saszm'
|
69
|
+
signature['arguments'][1]['default'] #=> nil
|
70
|
+
|
71
|
+
This virtual signature does not specify a block so the block argument
|
72
|
+
should return `nil`.
|
73
|
+
|
74
|
+
signature['block'] #=> nil
|
75
|
+
|
76
|
+
Now lets' look at the second virtual signature.
|
77
|
+
|
78
|
+
signature = example['interfaces'][1]
|
79
|
+
|
80
|
+
The signature should match the provided image.
|
81
|
+
|
82
|
+
signature['signature'] #=> 'my_method(bunny)'
|
83
|
+
|
84
|
+
And the arguments should be detailed as expected.
|
85
|
+
|
86
|
+
signature['arguments'][0]['name'] #=> 'bunny'
|
87
|
+
signature['arguments'][0]['default'] #=> nil
|
88
|
+
|
89
|
+
This virtual signature does specify a block, but not as an argument, but rather
|
90
|
+
as a representation the call arguments.
|
91
|
+
|
92
|
+
signature['block']['image'] #=> '{ |ears| ... }'
|
93
|
+
|
94
|
+
This signature also give a returns description.
|
95
|
+
|
96
|
+
signature['returns'] #=> 'true or false'
|
97
|
+
|
data/spec/applique/ae.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ae'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'shomen-yard'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
#Before :all do
|
5
|
+
if not File.exist?('.ruby')
|
6
|
+
dotruby = "---\nname: example\n"
|
7
|
+
File.open('.ruby', 'w'){ |f| f << dotruby }
|
8
|
+
end
|
9
|
+
#end
|
10
|
+
|
11
|
+
When 'Given a file +(((.*?)))+' do |file, text|
|
12
|
+
@file = file
|
13
|
+
FileUtils.mkdir_p(File.dirname(file))
|
14
|
+
File.open(file, 'w'){ |f| f << text }
|
15
|
+
end
|
16
|
+
|
17
|
+
When 'Running the script through shomen' do
|
18
|
+
output = ''
|
19
|
+
$stdout = StringIO.new(output,'w+')
|
20
|
+
Shomen::Yard::Command.run('--yaml', @file)
|
21
|
+
$stdout.close
|
22
|
+
@shomen = YAML.load(output)
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# This is an example toplevel class method.
|
2
|
+
def self.example_toplevel_method_class_method
|
3
|
+
end
|
4
|
+
|
5
|
+
# This is an example toplevel instance method.
|
6
|
+
def example_toplevel_method
|
7
|
+
end
|
8
|
+
|
9
|
+
# This is an example module.
|
10
|
+
module ExampleModule
|
11
|
+
|
12
|
+
# This is an example constant in a module.
|
13
|
+
EXAMPLE_CONSTANT = "example constant in a module"
|
14
|
+
|
15
|
+
# This is an example class method in a module.
|
16
|
+
def self.example_class_method
|
17
|
+
end
|
18
|
+
|
19
|
+
# This is an example instance method in a module.
|
20
|
+
def example_method
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
# This is an example class.
|
26
|
+
class ExampleClass
|
27
|
+
|
28
|
+
# This is an example constant in a class.
|
29
|
+
EXAMPLE_CONSTANT = "example constant in a class"
|
30
|
+
|
31
|
+
# This is an example class method in a class.
|
32
|
+
def self.example_class_method
|
33
|
+
end
|
34
|
+
|
35
|
+
# This is an example attribute.
|
36
|
+
attr :example_attribute
|
37
|
+
|
38
|
+
# This is an example attribute reader.
|
39
|
+
attr_reader :example_attribute_reader
|
40
|
+
|
41
|
+
# This is an example attribute writer.
|
42
|
+
attr_writer :example_attribute_writer
|
43
|
+
|
44
|
+
# This is an example attribute accessor.
|
45
|
+
attr_accessor :example_attribute_accessor
|
46
|
+
|
47
|
+
# This is an example instance method in a class.
|
48
|
+
def example_method
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shomen-yard
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- trans
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: yard
|
16
|
+
requirement: &17741400 !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: *17741400
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: shomen-model
|
27
|
+
requirement: &17740140 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *17740140
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: detroit
|
38
|
+
requirement: &17738980 !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: *17738980
|
47
|
+
description: ! 'Shomen YARD is a utiliity for generating Shomen documentation file
|
48
|
+
|
49
|
+
using YARD as a backend parser.'
|
50
|
+
email:
|
51
|
+
- transfire@gmail.com
|
52
|
+
executables:
|
53
|
+
- shomen-yard
|
54
|
+
extensions: []
|
55
|
+
extra_rdoc_files:
|
56
|
+
- LICENSE.txt
|
57
|
+
- HISTORY.md
|
58
|
+
- README.md
|
59
|
+
files:
|
60
|
+
- .ruby
|
61
|
+
- .yardopts
|
62
|
+
- bin/shomen-yard
|
63
|
+
- lib/shomen-yard/command.rb
|
64
|
+
- lib/shomen-yard/generator.rb
|
65
|
+
- lib/shomen-yard.rb
|
66
|
+
- spec/01_metadata.rdoc
|
67
|
+
- spec/02_class.rdoc
|
68
|
+
- spec/03_module.rdoc
|
69
|
+
- spec/04_constant.rdoc
|
70
|
+
- spec/05_method.rdoc
|
71
|
+
- spec/10_interface_overloading.rdoc
|
72
|
+
- spec/applique/ae.rb
|
73
|
+
- spec/applique/shomen.rb
|
74
|
+
- spec/fixture/lib/example.rb
|
75
|
+
- LICENSE.txt
|
76
|
+
- HISTORY.md
|
77
|
+
- README.md
|
78
|
+
homepage: http://rubyworks.github.com/shomen-yard
|
79
|
+
licenses: []
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 1.8.11
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Shomen via YARD command line utility
|
102
|
+
test_files: []
|