shomen 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby +43 -0
- data/.yardopts +7 -0
- data/HISTORY.rdoc +10 -0
- data/NOTES.rdoc +5 -0
- data/README.rdoc +68 -0
- data/bin/shomen +4 -0
- data/lib/shomen.yml +43 -0
- data/lib/shomen/cli.rb +22 -0
- data/lib/shomen/cli/abstract.rb +120 -0
- data/lib/shomen/cli/rdoc.rb +122 -0
- data/lib/shomen/cli/tomdoc.rb +119 -0
- data/lib/shomen/cli/yard.rb +118 -0
- data/lib/shomen/core_ext/hash.rb +3 -0
- data/lib/shomen/metadata.rb +81 -0
- data/lib/shomen/model.rb +21 -0
- data/lib/shomen/model/abstract.rb +84 -0
- data/lib/shomen/model/attribute.rb +25 -0
- data/lib/shomen/model/class.rb +19 -0
- data/lib/shomen/model/constant.rb +34 -0
- data/lib/shomen/model/document.rb +36 -0
- data/lib/shomen/model/interface.rb +35 -0
- data/lib/shomen/model/method.rb +104 -0
- data/lib/shomen/model/module.rb +56 -0
- data/lib/shomen/model/script.rb +49 -0
- data/lib/shomen/rdoc.rb +598 -0
- data/lib/shomen/rdoc/extensions.rb +145 -0
- data/lib/shomen/server.rb +10 -0
- data/lib/shomen/tomdoc.rb +151 -0
- data/lib/shomen/yard.rb +471 -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/08_rdoc/01_interface_overloading.rdoc +94 -0
- data/spec/09_yard/01_interface_overloading.rdoc +93 -0
- data/spec/applique/shomen.rb +26 -0
- data/spec/fixture/lib/example.rb +52 -0
- metadata +122 -0
@@ -0,0 +1,94 @@
|
|
1
|
+
== RDoc Method Interface Overloading
|
2
|
+
|
3
|
+
RDoc supports the `:call-seq:` directive for defining "virtual"
|
4
|
+
method interfaces. Given a file +lib/example.rb+ containing a class
|
5
|
+
with a documented method using the directive:
|
6
|
+
|
7
|
+
class ExampleClass
|
8
|
+
# Example method using call-seq directive.
|
9
|
+
#
|
10
|
+
# :call-seq:
|
11
|
+
# my_method(flazm, saszm) -> nil
|
12
|
+
# my_method(bunny) { |ears| ... } -> true or false
|
13
|
+
#
|
14
|
+
def my_method(a1,a2=nil,&b)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Running the script through shomen command line interface the signatures list
|
19
|
+
should have only three entries.
|
20
|
+
|
21
|
+
example = @shomen['ExampleClass#my_method']
|
22
|
+
|
23
|
+
example['signatures'].size #=> 3
|
24
|
+
|
25
|
+
=== Literal Interface
|
26
|
+
|
27
|
+
Lets get a closer look at the first signature.
|
28
|
+
|
29
|
+
signature = example['signatures'].first
|
30
|
+
|
31
|
+
The first signature should match the literal definition.
|
32
|
+
|
33
|
+
signature['signature'] #=> 'my_method(a1,a2=nil,&b)'
|
34
|
+
|
35
|
+
And the arguments should be detailed as expected.
|
36
|
+
|
37
|
+
signature['arguments'][0]['name'] #=> 'a1'
|
38
|
+
signature['arguments'][0]['default'] #=> nil
|
39
|
+
|
40
|
+
signature['arguments'][1]['name'] #=> 'a2'
|
41
|
+
signature['arguments'][1]['default'] #=> 'nil'
|
42
|
+
|
43
|
+
As should the block argument.
|
44
|
+
|
45
|
+
signature['block']['name'] #=> '&b'
|
46
|
+
|
47
|
+
=== Virtual Interface
|
48
|
+
|
49
|
+
The second and third signatures should conform to those given in
|
50
|
+
under the `:call-seq:` directive.
|
51
|
+
|
52
|
+
Lets get a closer look at the first of these.
|
53
|
+
|
54
|
+
signature = example['signatures'][1]
|
55
|
+
|
56
|
+
The signature should match the provided image.
|
57
|
+
|
58
|
+
signature['signature'] #=> 'my_method(flazm, saszm)'
|
59
|
+
|
60
|
+
And the arguments should be detailed as expected.
|
61
|
+
|
62
|
+
signature['arguments'][0]['name'] #=> 'flazm'
|
63
|
+
signature['arguments'][0]['default'] #=> nil
|
64
|
+
|
65
|
+
signature['arguments'][1]['name'] #=> 'saszm'
|
66
|
+
signature['arguments'][1]['default'] #=> nil
|
67
|
+
|
68
|
+
This virtual signature does not specify a block so the block argument
|
69
|
+
should return `nil`.
|
70
|
+
|
71
|
+
signature['block'] #=> nil
|
72
|
+
|
73
|
+
Now lets' look at the second virtual signature.
|
74
|
+
|
75
|
+
signature = example['signatures'][2]
|
76
|
+
|
77
|
+
The signature should match the provided image.
|
78
|
+
|
79
|
+
signature['signature'] #=> 'my_method(bunny)'
|
80
|
+
|
81
|
+
And the arguments should be detailed as expected.
|
82
|
+
|
83
|
+
signature['arguments'][0]['name'] #=> 'bunny'
|
84
|
+
signature['arguments'][0]['default'] #=> nil
|
85
|
+
|
86
|
+
This virtual signature does specify a block, but not as an argument, but rather
|
87
|
+
as a representation the call arguments.
|
88
|
+
|
89
|
+
signature['block']['image'] #=> '{ |ears| ... }'
|
90
|
+
|
91
|
+
This last signature also give a returns description.
|
92
|
+
|
93
|
+
signature['returns'] #=> 'true or false'
|
94
|
+
|
@@ -0,0 +1,93 @@
|
|
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 call-seq directive.
|
9
|
+
#
|
10
|
+
# @overload my_method(flazm, saszm) -> nil
|
11
|
+
# @overload my_method(bunny) { |ears| ... } -> true or false
|
12
|
+
#
|
13
|
+
def my_method(a1,a2=nil,&b)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Running the script through shomen command line interface the signatures list
|
18
|
+
should have three entries, the literal interface and the two virtual interfaces.
|
19
|
+
|
20
|
+
example = @shomen['ExampleClass#my_method']
|
21
|
+
|
22
|
+
example['signatures'].size #=> 3
|
23
|
+
|
24
|
+
=== Literal Interface
|
25
|
+
|
26
|
+
Lets get a closer look at the first signature.
|
27
|
+
|
28
|
+
signature = example['signatures'].first
|
29
|
+
|
30
|
+
The first signature should match the literal definition.
|
31
|
+
|
32
|
+
signature['signature'] #=> 'my_method(a1,a2=nil,&b)'
|
33
|
+
|
34
|
+
And the arguments should be detailed as expected.
|
35
|
+
|
36
|
+
signature['arguments'][0]['name'] #=> 'a1'
|
37
|
+
signature['arguments'][0]['default'] #=> nil
|
38
|
+
|
39
|
+
signature['arguments'][1]['name'] #=> 'a2'
|
40
|
+
signature['arguments'][1]['default'] #=> 'nil'
|
41
|
+
|
42
|
+
As should the block argument.
|
43
|
+
|
44
|
+
signature['block']['name'] #=> '&b'
|
45
|
+
|
46
|
+
=== Virtual Interface
|
47
|
+
|
48
|
+
The second and third signatures should conform to those given in
|
49
|
+
under the `:call-seq:` directive.
|
50
|
+
|
51
|
+
Lets get a closer look at the first of these.
|
52
|
+
|
53
|
+
signature = example['signatures'][1]
|
54
|
+
|
55
|
+
The signature should match the provided image.
|
56
|
+
|
57
|
+
signature['signature'] #=> 'my_method(flazm, saszm)'
|
58
|
+
|
59
|
+
And the arguments should be detailed as expected.
|
60
|
+
|
61
|
+
signature['arguments'][0]['name'] #=> 'flazm'
|
62
|
+
signature['arguments'][0]['default'] #=> nil
|
63
|
+
|
64
|
+
signature['arguments'][1]['name'] #=> 'saszm'
|
65
|
+
signature['arguments'][1]['default'] #=> nil
|
66
|
+
|
67
|
+
This virtual signature does not specify a block so the block argument
|
68
|
+
should return `nil`.
|
69
|
+
|
70
|
+
signature['block'] #=> nil
|
71
|
+
|
72
|
+
Now lets' look at the second virtual signature.
|
73
|
+
|
74
|
+
signature = example['signatures'][2]
|
75
|
+
|
76
|
+
The signature should match the provided image.
|
77
|
+
|
78
|
+
signature['signature'] #=> 'my_method(bunny)'
|
79
|
+
|
80
|
+
And the arguments should be detailed as expected.
|
81
|
+
|
82
|
+
signature['arguments'][0]['name'] #=> 'bunny'
|
83
|
+
signature['arguments'][0]['default'] #=> nil
|
84
|
+
|
85
|
+
This virtual signature does specify a block, but not as an argument, but rather
|
86
|
+
as a representation the call arguments.
|
87
|
+
|
88
|
+
signature['block']['image'] #=> '{ |ears| ... }'
|
89
|
+
|
90
|
+
This last signature also give a returns description.
|
91
|
+
|
92
|
+
signature['returns'] #=> 'true or false'
|
93
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'shomen/cli'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
parser = ENV['parser'] || 'rdoc'
|
5
|
+
|
6
|
+
#Before :all do
|
7
|
+
if not File.exist?('.ruby')
|
8
|
+
dotruby = "---\nname: example\n"
|
9
|
+
File.open('.ruby', 'w'){ |f| f << dotruby }
|
10
|
+
end
|
11
|
+
#end
|
12
|
+
|
13
|
+
When 'Given a file +(((.*?)))+' do |file, text|
|
14
|
+
@file = file
|
15
|
+
FileUtils.mkdir_p(File.dirname(file))
|
16
|
+
File.open(file, 'w'){ |f| f << text }
|
17
|
+
end
|
18
|
+
|
19
|
+
When 'Running the script through shomen' do
|
20
|
+
output = ''
|
21
|
+
$stdout = StringIO.new(output,'w+')
|
22
|
+
Shomen.cli(parser, '--format', 'yaml', @file)
|
23
|
+
$stdout.close
|
24
|
+
@shomen = YAML.load(output)
|
25
|
+
end
|
26
|
+
|
@@ -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,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shomen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Thomas Sawyer
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rdoc
|
16
|
+
requirement: &16179380 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *16179380
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: detroit
|
27
|
+
requirement: &16178720 !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: *16178720
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: reap
|
38
|
+
requirement: &16178040 !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: *16178040
|
47
|
+
description: Shomen defines a standard API documentaiton format for object-oriented
|
48
|
+
software (Ruby programs in particular) which can be used by documentation interfaces,
|
49
|
+
e.g. Hypervisor, to render API documentation
|
50
|
+
email:
|
51
|
+
- transfire@gmail.com
|
52
|
+
executables:
|
53
|
+
- shomen
|
54
|
+
extensions: []
|
55
|
+
extra_rdoc_files:
|
56
|
+
- HISTORY.rdoc
|
57
|
+
- README.rdoc
|
58
|
+
- NOTES.rdoc
|
59
|
+
files:
|
60
|
+
- .ruby
|
61
|
+
- .yardopts
|
62
|
+
- bin/shomen
|
63
|
+
- lib/shomen/cli/abstract.rb
|
64
|
+
- lib/shomen/cli/rdoc.rb
|
65
|
+
- lib/shomen/cli/tomdoc.rb
|
66
|
+
- lib/shomen/cli/yard.rb
|
67
|
+
- lib/shomen/cli.rb
|
68
|
+
- lib/shomen/core_ext/hash.rb
|
69
|
+
- lib/shomen/metadata.rb
|
70
|
+
- lib/shomen/model/abstract.rb
|
71
|
+
- lib/shomen/model/attribute.rb
|
72
|
+
- lib/shomen/model/class.rb
|
73
|
+
- lib/shomen/model/constant.rb
|
74
|
+
- lib/shomen/model/document.rb
|
75
|
+
- lib/shomen/model/interface.rb
|
76
|
+
- lib/shomen/model/method.rb
|
77
|
+
- lib/shomen/model/module.rb
|
78
|
+
- lib/shomen/model/script.rb
|
79
|
+
- lib/shomen/model.rb
|
80
|
+
- lib/shomen/rdoc/extensions.rb
|
81
|
+
- lib/shomen/rdoc.rb
|
82
|
+
- lib/shomen/server.rb
|
83
|
+
- lib/shomen/tomdoc.rb
|
84
|
+
- lib/shomen/yard.rb
|
85
|
+
- lib/shomen.yml
|
86
|
+
- spec/01_metadata.rdoc
|
87
|
+
- spec/02_class.rdoc
|
88
|
+
- spec/03_module.rdoc
|
89
|
+
- spec/04_constant.rdoc
|
90
|
+
- spec/05_method.rdoc
|
91
|
+
- spec/08_rdoc/01_interface_overloading.rdoc
|
92
|
+
- spec/09_yard/01_interface_overloading.rdoc
|
93
|
+
- spec/applique/shomen.rb
|
94
|
+
- spec/fixture/lib/example.rb
|
95
|
+
- HISTORY.rdoc
|
96
|
+
- README.rdoc
|
97
|
+
- NOTES.rdoc
|
98
|
+
homepage: http://rubyworks.github.com/shomen
|
99
|
+
licenses: []
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 1.8.5
|
119
|
+
signing_key:
|
120
|
+
specification_version: 3
|
121
|
+
summary: Standardized Object-Oriented Documentation Model
|
122
|
+
test_files: []
|