shomen-rdoc 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 via rdoc the signatures list
19
+ should have only three entries.
20
+
21
+ example = @shomen['ExampleClass#my_method']
22
+ example['interfaces'].size #=> 3
23
+
24
+ === Literal Interface
25
+
26
+ Lets get a closer look at the last signature, which is always the
27
+ literal interface.
28
+
29
+ signature = example['interfaces'].last
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['interfaces'][0]
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['interfaces'][1]
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 @@
1
+ require 'ae'
@@ -0,0 +1,24 @@
1
+ require 'shomen-rdoc'
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::Rdoc::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,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shomen-rdoc
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: rdoc
16
+ requirement: &24413160 !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: *24413160
25
+ - !ruby/object:Gem::Dependency
26
+ name: shomen-model
27
+ requirement: &24411900 !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: *24411900
36
+ - !ruby/object:Gem::Dependency
37
+ name: detroit
38
+ requirement: &24410840 !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: *24410840
47
+ description: ! 'Shomen RDoc provides a command line utility for generating Shomen
48
+ standard
49
+
50
+ documentation via the RDoc''s `.rdoc` cache. It is an alternative to the
51
+
52
+ `rdoc-shomen` format plugin.'
53
+ email:
54
+ - transfire@gmail.com
55
+ executables:
56
+ - shomen-rdoc
57
+ extensions: []
58
+ extra_rdoc_files:
59
+ - LICENSE.txt
60
+ - HISTORY.rdoc
61
+ - README.rdoc
62
+ files:
63
+ - .ruby
64
+ - bin/shomen-rdoc
65
+ - lib/shomen-rdoc/command.rb
66
+ - lib/shomen-rdoc/generator.rb
67
+ - lib/shomen-rdoc/rdoc_ext.rb
68
+ - lib/shomen-rdoc.rb
69
+ - lib/shomen-rdoc.yml
70
+ - spec/02_class.rdoc
71
+ - spec/03_module.rdoc
72
+ - spec/04_constant.rdoc
73
+ - spec/05_method.rdoc
74
+ - spec/10_interface_overloading.rdoc
75
+ - spec/applique/ae.rb
76
+ - spec/applique/shomen.rb
77
+ - spec/fixture/lib/example.rb
78
+ - HISTORY.rdoc
79
+ - LICENSE.txt
80
+ - README.rdoc
81
+ homepage: http://rubyworks.github.com/shomen-rdoc
82
+ licenses: []
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 1.8.11
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Shomen Documentation via RDoc
105
+ test_files: []