yard-heuristics 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +4 -0
- data/Rakefile +17 -0
- data/lib/yard-heuristics-1.0.rb +28 -0
- data/lib/yard-heuristics/version.rb +16 -0
- data/test/unit/yard-heuristics-1.0.rb +15 -0
- data/test/unit/yard-heuristics/version.rb +4 -0
- metadata +106 -0
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'inventory/rake-1.0'
|
4
|
+
|
5
|
+
load File.expand_path('../lib/yard-heuristics/version.rb', __FILE__)
|
6
|
+
|
7
|
+
Inventory::Rake::Tasks.define YARDHeuristics::Version, :gem => proc{ |_, s|
|
8
|
+
s.author = 'Nikolai Weibull'
|
9
|
+
s.email = 'now@bitwi.se'
|
10
|
+
s.homepage = 'https://github.com/now/yard-heuristics'
|
11
|
+
}
|
12
|
+
|
13
|
+
Inventory::Rake::Tasks.unless_installing_dependencies do
|
14
|
+
require 'lookout/rake-3.0'
|
15
|
+
# TODO: Silence warnings generated from YARD (remove this once we plug them)
|
16
|
+
Lookout::Rake::Tasks::Test.new :options => []
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Namespace for YARD heuristics.
|
4
|
+
module YARDHeuristics
|
5
|
+
load File.expand_path('../yard-heuristics/version.rb', __FILE__)
|
6
|
+
Version.load
|
7
|
+
end
|
8
|
+
|
9
|
+
YARD::DocstringParser.after_parse do |parser|
|
10
|
+
next unless YARD::CodeObjects::MethodObject === parser.object
|
11
|
+
if parser.object.parameters.assoc('other') and not parser.tags.select{ |e| e.tag_name == 'param' }.find{ |e| e.name == 'other' }
|
12
|
+
parser.tags <<
|
13
|
+
YARD::Tags::Tag.new(:param,
|
14
|
+
'',
|
15
|
+
parser.object.namespace.namespace ?
|
16
|
+
parser.object.namespace.relative_path(parser.object.namespace) :
|
17
|
+
parser.object.namespace,
|
18
|
+
'other')
|
19
|
+
end
|
20
|
+
returns = parser.tags.select{ |e| e.tag_name == 'return' }
|
21
|
+
if [:===, :==, :=~].include? parser.object.name and returns.size < 2
|
22
|
+
if returns.empty?
|
23
|
+
parser.tags << YARD::Tags::Tag.new(:return, '', %w'Boolean')
|
24
|
+
elsif not returns.first.types
|
25
|
+
returns.first.types = %w'Boolean'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'inventory-1.0'
|
4
|
+
|
5
|
+
module YARDHeuristics
|
6
|
+
Version = Inventory.new(1, 0, 0){
|
7
|
+
def dependencies
|
8
|
+
super + Inventory::Dependencies.new{
|
9
|
+
development 'inventory-rake', 1, 3, 0
|
10
|
+
development 'lookout', 3, 0, 0
|
11
|
+
development 'lookout-rake', 3, 0, 0
|
12
|
+
runtime 'yard', 0, 8, 0, :feature => 'yard'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
}
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
expect [['other', %w'A']] do
|
5
|
+
YARD::Registry.clear
|
6
|
+
YARD::Parser::SourceParser.parse_string(<<EOS)
|
7
|
+
class A
|
8
|
+
# Placeholder
|
9
|
+
def a(other)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
EOS
|
13
|
+
YARD::Registry.at('A#a').docstring.tags(:param).map{ |e| [e.name, e.types] }
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yard-heuristics
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nikolai Weibull
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: inventory
|
16
|
+
requirement: &2152773000 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2152773000
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: inventory-rake
|
27
|
+
requirement: &2152772300 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.3'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2152772300
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: lookout
|
38
|
+
requirement: &2152771700 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2152771700
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: lookout-rake
|
49
|
+
requirement: &2152771080 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2152771080
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: yard
|
60
|
+
requirement: &2152770340 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.8.0
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2152770340
|
69
|
+
description: ! " YARD-Heuristics\n\n YARD-Heuristics
|
70
|
+
heuristically determines types of parameters and return\n values to YARD.\n"
|
71
|
+
email: now@bitwi.se
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- lib/yard-heuristics-1.0.rb
|
77
|
+
- lib/yard-heuristics/version.rb
|
78
|
+
- test/unit/yard-heuristics-1.0.rb
|
79
|
+
- test/unit/yard-heuristics/version.rb
|
80
|
+
- README
|
81
|
+
- Rakefile
|
82
|
+
homepage: https://github.com/now/yard-heuristics
|
83
|
+
licenses: []
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 1.8.11
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: values to YARD.
|
106
|
+
test_files: []
|