inch 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +113 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +5 -2
- data/README.md +2 -2
- data/Rakefile +2 -2
- data/bin/inch +3 -2
- data/config/defaults.rb +7 -0
- data/inch.gemspec +7 -7
- data/lib/inch.rb +9 -10
- data/lib/inch/api.rb +10 -10
- data/lib/inch/api/compare.rb +2 -2
- data/lib/inch/api/compare/code_objects.rb +2 -3
- data/lib/inch/api/compare/codebases.rb +1 -1
- data/lib/inch/api/diff.rb +6 -9
- data/lib/inch/api/options/base.rb +4 -4
- data/lib/inch/api/options/suggest.rb +1 -1
- data/lib/inch/api/stats.rb +0 -1
- data/lib/inch/api/suggest.rb +8 -9
- data/lib/inch/cli.rb +6 -6
- data/lib/inch/cli/command.rb +15 -15
- data/lib/inch/cli/command/base.rb +2 -2
- data/lib/inch/cli/command/console.rb +5 -5
- data/lib/inch/cli/command/diff.rb +7 -8
- data/lib/inch/cli/command/inspect.rb +5 -4
- data/lib/inch/cli/command/list.rb +4 -4
- data/lib/inch/cli/command/options/base.rb +8 -8
- data/lib/inch/cli/command/options/base_list.rb +9 -5
- data/lib/inch/cli/command/options/console.rb +4 -3
- data/lib/inch/cli/command/options/diff.rb +6 -4
- data/lib/inch/cli/command/options/inspect.rb +2 -2
- data/lib/inch/cli/command/options/list.rb +4 -3
- data/lib/inch/cli/command/options/show.rb +2 -2
- data/lib/inch/cli/command/options/stats.rb +2 -1
- data/lib/inch/cli/command/options/suggest.rb +6 -3
- data/lib/inch/cli/command/output/base.rb +2 -4
- data/lib/inch/cli/command/output/console.rb +4 -5
- data/lib/inch/cli/command/output/diff.rb +6 -6
- data/lib/inch/cli/command/output/inspect.rb +6 -8
- data/lib/inch/cli/command/output/list.rb +0 -1
- data/lib/inch/cli/command/output/show.rb +4 -5
- data/lib/inch/cli/command/output/stats.rb +21 -21
- data/lib/inch/cli/command/output/suggest.rb +28 -26
- data/lib/inch/cli/command/show.rb +4 -4
- data/lib/inch/cli/command/stats.rb +4 -4
- data/lib/inch/cli/command/suggest.rb +6 -6
- data/lib/inch/cli/command_parser.rb +6 -5
- data/lib/inch/cli/sparkline_helper.rb +2 -2
- data/lib/inch/cli/trace_helper.rb +1 -1
- data/lib/inch/cli/yardopts_helper.rb +4 -3
- data/lib/inch/code_object.rb +3 -3
- data/lib/inch/code_object/converter.rb +6 -8
- data/lib/inch/code_object/provider.rb +1 -1
- data/lib/inch/code_object/provider/yard.rb +10 -12
- data/lib/inch/code_object/provider/yard/docstring.rb +53 -21
- data/lib/inch/code_object/provider/yard/nodoc_helper.rb +3 -3
- data/lib/inch/code_object/provider/yard/object.rb +11 -9
- data/lib/inch/code_object/provider/yard/object/base.rb +33 -9
- data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +12 -0
- data/lib/inch/code_object/provider/yard/object/method_object.rb +36 -11
- data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +2 -2
- data/lib/inch/code_object/provider/yard/object/method_signature.rb +11 -8
- data/lib/inch/code_object/provider/yard/object/namespace_object.rb +1 -4
- data/lib/inch/code_object/provider/yard/parser.rb +2 -2
- data/lib/inch/code_object/proxy.rb +10 -9
- data/lib/inch/code_object/proxy/base.rb +8 -8
- data/lib/inch/code_object/proxy/class_variable_object.rb +8 -0
- data/lib/inch/code_object/proxy/method_object.rb +3 -2
- data/lib/inch/code_object/proxy/method_parameter_object.rb +1 -1
- data/lib/inch/codebase.rb +4 -5
- data/lib/inch/codebase/objects_filter.rb +2 -4
- data/lib/inch/codebase/serializer.rb +3 -3
- data/lib/inch/config.rb +2 -2
- data/lib/inch/config/base.rb +0 -1
- data/lib/inch/config/codebase.rb +3 -3
- data/lib/inch/core_ext.rb +1 -1
- data/lib/inch/core_ext/string.rb +1 -1
- data/lib/inch/evaluation.rb +16 -15
- data/lib/inch/evaluation/grade_list.rb +2 -2
- data/lib/inch/evaluation/object_schema.rb +1 -1
- data/lib/inch/evaluation/proxy.rb +8 -7
- data/lib/inch/evaluation/proxy/base.rb +12 -7
- data/lib/inch/evaluation/proxy/class_variable_object.rb +19 -0
- data/lib/inch/evaluation/proxy/constant_object.rb +1 -1
- data/lib/inch/evaluation/proxy/method_object.rb +12 -5
- data/lib/inch/evaluation/proxy/module_object.rb +1 -1
- data/lib/inch/evaluation/proxy/namespace_object.rb +1 -1
- data/lib/inch/evaluation/role/base.rb +1 -1
- data/lib/inch/evaluation/role/class_variable.rb +55 -0
- data/lib/inch/evaluation/role/method.rb +0 -1
- data/lib/inch/evaluation/role/method_parameter.rb +2 -1
- data/lib/inch/evaluation/role/object.rb +2 -2
- data/lib/inch/rake.rb +2 -2
- data/lib/inch/rake/suggest.rb +2 -2
- data/lib/inch/utils/shell_helper.rb +1 -1
- data/lib/inch/utils/ui.rb +5 -5
- data/lib/inch/utils/weighted_list.rb +2 -3
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/simple/lib/broken.rb +35 -7
- data/test/fixtures/simple/lib/broken_ruby_2_0_features.rb +7 -0
- data/test/fixtures/simple/lib/directives.rb +8 -0
- data/test/fixtures/simple/lib/foo.rb +17 -0
- data/test/integration/api/compare/codebases.rb +1 -1
- data/test/integration/cli/command/console_test.rb +5 -5
- data/test/integration/cli/command/inspect_test.rb +4 -5
- data/test/integration/cli/command/list_test.rb +3 -4
- data/test/integration/cli/command/show_test.rb +4 -4
- data/test/integration/cli/command/stats_test.rb +2 -2
- data/test/integration/cli/command/suggest_test.rb +7 -7
- data/test/integration/stats_options_test.rb +3 -3
- data/test/integration/visibility_options_test.rb +13 -13
- data/test/shared/base_list.rb +4 -3
- data/test/test_helper.rb +16 -5
- data/test/unit/api/filter_test.rb +7 -7
- data/test/unit/api/get_test.rb +1 -1
- data/test/unit/api/list_test.rb +1 -1
- data/test/unit/api/options/base_test.rb +3 -3
- data/test/unit/api/stats_test.rb +1 -1
- data/test/unit/api/suggest_test.rb +3 -3
- data/test/unit/cli/arguments_test.rb +1 -1
- data/test/unit/cli/command/base_test.rb +1 -1
- data/test/unit/cli/command/options/base_list_test.rb +2 -2
- data/test/unit/cli/command/options/base_object_test.rb +1 -1
- data/test/unit/cli/command/options/base_test.rb +1 -1
- data/test/unit/cli/command_parser_test.rb +2 -2
- data/test/unit/cli/trace_helper_test.rb +1 -1
- data/test/unit/cli/yardopts_helper_test.rb +4 -3
- data/test/unit/code_object/converter_test.rb +1 -1
- data/test/unit/code_object/provider/yard/docstring_test.rb +105 -28
- data/test/unit/code_object/provider/yard/nodoc_helper_test.rb +5 -5
- data/test/unit/code_object/provider/yard/object/method_object_test.rb +20 -10
- data/test/unit/code_object/provider/yard_test.rb +4 -4
- data/test/unit/code_object/provider_test.rb +1 -1
- data/test/unit/code_object/proxy/method_object_test.rb +366 -262
- data/test/unit/code_object/proxy_test.rb +1 -1
- data/test/unit/codebase/objects_test.rb +2 -2
- data/test/unit/codebase/proxy_test.rb +1 -1
- data/test/unit/config/codebase_test.rb +1 -1
- data/test/unit/evaluation/role/base_test.rb +1 -1
- data/test/unit/utils/ui_test.rb +4 -4
- data/test/unit/utils/weighted_list_test.rb +7 -4
- metadata +12 -2
@@ -21,9 +21,9 @@ module Inch
|
|
21
21
|
|
22
22
|
def __sparkline(list, grade_lists)
|
23
23
|
sparkline = Sparkr::Sparkline.new(list)
|
24
|
-
sparkline.format do |tick,
|
24
|
+
sparkline.format do |tick, _count, index|
|
25
25
|
t = tick.color(grade_lists[index].color)
|
26
|
-
index == 0 ? t +
|
26
|
+
index == 0 ? t + " " : t
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -8,7 +8,8 @@ module Inch
|
|
8
8
|
attr_accessor :excluded
|
9
9
|
|
10
10
|
VALID_YARD_SWITCHES = %w(--private --no-private --protected --no-public
|
11
|
-
|
11
|
+
--plugin --load --safe --yardopts --no-yardopts
|
12
|
+
--document --no-document)
|
12
13
|
|
13
14
|
# Parses the option and gracefully handles invalid switches
|
14
15
|
#
|
@@ -17,7 +18,7 @@ module Inch
|
|
17
18
|
# array will be modified.
|
18
19
|
# @return [void]
|
19
20
|
def parse_yardopts_options(opts, args)
|
20
|
-
wrapper = YardoptsWrapper.new
|
21
|
+
wrapper = YardoptsWrapper.new
|
21
22
|
|
22
23
|
dupped_args = args.dup
|
23
24
|
dupped_args.delete("--help")
|
@@ -35,7 +36,7 @@ module Inch
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def yardopts_options(opts)
|
38
|
-
wrapper = YardoptsWrapper.new
|
39
|
+
wrapper = YardoptsWrapper.new
|
39
40
|
wrapper.add_yardoc_options(opts)
|
40
41
|
end
|
41
42
|
|
data/lib/inch/code_object.rb
CHANGED
@@ -52,7 +52,7 @@ module Inch
|
|
52
52
|
unconsidered_tag_count
|
53
53
|
undocumented?
|
54
54
|
visibility
|
55
|
-
|
55
|
+
).map(&:to_sym)
|
56
56
|
|
57
57
|
PARAMETER_ATTRIBUTES = %w(
|
58
58
|
name
|
@@ -62,7 +62,7 @@ module Inch
|
|
62
62
|
splat?
|
63
63
|
typed?
|
64
64
|
wrongly_mentioned?
|
65
|
-
|
65
|
+
).map(&:to_sym)
|
66
66
|
|
67
67
|
# Returns an attributes Hash for a given code object
|
68
68
|
#
|
@@ -71,16 +71,14 @@ module Inch
|
|
71
71
|
def self.to_hash(o)
|
72
72
|
attributes = {}
|
73
73
|
OBJECT_ATTRIBUTES.each do |name|
|
74
|
-
|
75
|
-
|
76
|
-
end
|
74
|
+
next unless o.respond_to?(name)
|
75
|
+
attributes[name] = o.public_send(name)
|
77
76
|
end
|
78
77
|
attributes[:parameters] = o.parameters.map do |parameter|
|
79
78
|
hash = {}
|
80
79
|
PARAMETER_ATTRIBUTES.each do |pname|
|
81
|
-
|
82
|
-
|
83
|
-
end
|
80
|
+
next unless parameter.respond_to?(pname)
|
81
|
+
hash[pname] = parameter.public_send(pname)
|
84
82
|
end
|
85
83
|
hash
|
86
84
|
end
|
@@ -3,7 +3,6 @@ module Inch
|
|
3
3
|
module Provider
|
4
4
|
# Parses the source tree (using YARD)
|
5
5
|
module YARD
|
6
|
-
|
7
6
|
# Returns +true+ if the docstring was generated by YARD
|
8
7
|
#
|
9
8
|
# @param docstring [Docstring,String]
|
@@ -13,7 +12,7 @@ module Inch
|
|
13
12
|
if method.getter?
|
14
13
|
docstring.to_s == "Returns the value of attribute #{name}"
|
15
14
|
elsif method.setter?
|
16
|
-
basename = name.to_s.gsub(/(\=)$/,
|
15
|
+
basename = name.to_s.gsub(/(\=)$/, "")
|
17
16
|
docstring.to_s == "Sets the attribute #{basename}"
|
18
17
|
else
|
19
18
|
false
|
@@ -27,11 +26,11 @@ module Inch
|
|
27
26
|
def self.implicit_tag?(tag, method)
|
28
27
|
name = method.name
|
29
28
|
if method.getter?
|
30
|
-
tag.tag_name ==
|
29
|
+
tag.tag_name == "return" &&
|
31
30
|
tag.text == "the current value of #{name}"
|
32
31
|
elsif method.setter?
|
33
|
-
tag.tag_name ==
|
34
|
-
tag.text ==
|
32
|
+
tag.tag_name == "return" &&
|
33
|
+
tag.text == "the newly set value"
|
35
34
|
else
|
36
35
|
false
|
37
36
|
end
|
@@ -40,18 +39,17 @@ module Inch
|
|
40
39
|
def self.parse(dir, config = Inch::Config.codebase)
|
41
40
|
Parser.parse(dir, config)
|
42
41
|
end
|
43
|
-
|
44
42
|
end
|
45
43
|
end
|
46
44
|
end
|
47
45
|
end
|
48
46
|
|
49
|
-
require
|
50
|
-
require
|
47
|
+
require "logger"
|
48
|
+
require "yard"
|
51
49
|
|
52
50
|
log.level = ::Logger::UNKNOWN # basically disable YARD's logging
|
53
51
|
|
54
|
-
require
|
55
|
-
require
|
56
|
-
require
|
57
|
-
require
|
52
|
+
require "inch/code_object/provider/yard/parser"
|
53
|
+
require "inch/code_object/provider/yard/docstring"
|
54
|
+
require "inch/code_object/provider/yard/nodoc_helper"
|
55
|
+
require "inch/code_object/provider/yard/object"
|
@@ -42,11 +42,16 @@ module Inch
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def mentions_return?
|
45
|
-
|
45
|
+
last_lines.any? do |line|
|
46
|
+
line =~ /^#{tomdoc_modifiers}Returns\ /
|
47
|
+
end
|
46
48
|
end
|
47
49
|
|
48
50
|
def describes_return?
|
49
|
-
|
51
|
+
last_lines.any? do |line|
|
52
|
+
line =~ /^#{tomdoc_modifiers}Returns\ (\w+\s){2,}/i ||
|
53
|
+
line =~ /^#{tomdoc_modifiers}Returns\ (nil|nothing)\.*/i
|
54
|
+
end
|
50
55
|
end
|
51
56
|
|
52
57
|
def to_s
|
@@ -59,18 +64,28 @@ module Inch
|
|
59
64
|
@first_line ||= @text.lines.to_a.first
|
60
65
|
end
|
61
66
|
|
62
|
-
|
63
|
-
|
67
|
+
# Returns the last lines of the docstring.
|
68
|
+
# @return [Array<String>] the last line and, if the last line(s) is indented,
|
69
|
+
# the last unindented line
|
70
|
+
def last_lines
|
71
|
+
@last_lines ||= begin
|
72
|
+
list = []
|
73
|
+
@text.lines.to_a.reverse.each do |line|
|
74
|
+
list << line
|
75
|
+
break if line =~ /^\S/
|
76
|
+
end
|
77
|
+
list.reverse
|
78
|
+
end
|
64
79
|
end
|
65
80
|
|
66
81
|
def parse_code_examples
|
67
82
|
code_examples = []
|
68
83
|
example = nil
|
69
|
-
@text.lines.
|
70
|
-
if line
|
84
|
+
@text.lines.each do |line|
|
85
|
+
if line =~ /^\s*+$/
|
71
86
|
code_examples << example if example
|
72
87
|
example = []
|
73
|
-
elsif line
|
88
|
+
elsif line =~ /^\ {2,}\S+/
|
74
89
|
example << line if example
|
75
90
|
else
|
76
91
|
code_examples << example if example
|
@@ -81,22 +96,34 @@ module Inch
|
|
81
96
|
code_examples.delete_if(&:empty?).map(&:join)
|
82
97
|
end
|
83
98
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
99
|
+
# Returns patterns in which method parameters are mentioned
|
100
|
+
# in inline docs.
|
101
|
+
#
|
102
|
+
# @param _name [String] the name of the method parameter
|
103
|
+
# @return [Array<Regexp>]
|
104
|
+
def mention_parameter_patterns(_name)
|
105
|
+
name = Regexp.escape(_name)
|
106
|
+
type = /<[^>]+>/
|
107
|
+
arr = [
|
108
|
+
name,
|
109
|
+
/#{name}#{type}/ # matches "param1<String,nil>"
|
110
|
+
].map do |expr|
|
111
|
+
[
|
112
|
+
/#{expr}\:\:/, # param1::
|
113
|
+
/\+#{expr}\+/, # +param1+
|
114
|
+
/\+#{expr}\+\:\:/, # +param1+::
|
115
|
+
/<tt>#{expr}<\/tt>/, # <tt>param1</tt>
|
116
|
+
/<tt>#{expr}<\/tt>\:\:/, # <tt>param1</tt>::
|
117
|
+
/^#{expr}\ \-\ / # param1 -
|
118
|
+
]
|
119
|
+
end.flatten
|
93
120
|
end
|
94
121
|
|
95
122
|
def describe_parameter_extra_regexps(name)
|
96
123
|
[
|
97
124
|
"#{name}::",
|
98
125
|
"+#{name}+::",
|
99
|
-
"<tt>#{name}</tt>::"
|
126
|
+
"<tt>#{name}</tt>::"
|
100
127
|
].map do |pattern|
|
101
128
|
r = pattern.is_a?(Regexp) ? pattern : Regexp.escape(pattern)
|
102
129
|
/#{r}\n\ {2,}.+/m
|
@@ -104,10 +131,11 @@ module Inch
|
|
104
131
|
end
|
105
132
|
|
106
133
|
def describe_parameter_regexps(name)
|
107
|
-
same_line_regexps =
|
108
|
-
|
109
|
-
|
110
|
-
|
134
|
+
same_line_regexps =
|
135
|
+
mention_parameter_patterns(name).map do |pattern|
|
136
|
+
r = pattern.is_a?(Regexp) ? pattern : Regexp.escape(pattern)
|
137
|
+
/^#{r}\s?\S+/
|
138
|
+
end
|
111
139
|
same_line_regexps + describe_parameter_extra_regexps(name)
|
112
140
|
end
|
113
141
|
|
@@ -121,6 +149,10 @@ module Inch
|
|
121
149
|
end
|
122
150
|
end
|
123
151
|
end
|
152
|
+
|
153
|
+
def tomdoc_modifiers
|
154
|
+
/((Public|Private|Internal)\:\ )*/
|
155
|
+
end
|
124
156
|
end
|
125
157
|
end
|
126
158
|
end
|
@@ -3,7 +3,6 @@ module Inch
|
|
3
3
|
module Provider
|
4
4
|
module YARD
|
5
5
|
module NodocHelper
|
6
|
-
|
7
6
|
# Returns true if the code object is somehow marked not to be
|
8
7
|
# documented.
|
9
8
|
#
|
@@ -81,10 +80,11 @@ module Inch
|
|
81
80
|
# @return [String]
|
82
81
|
def get_line_no(filename, line_number)
|
83
82
|
f = File.open(filename)
|
84
|
-
line_number.times{f.gets}
|
83
|
+
line_number.times { f.gets }
|
85
84
|
result = $_
|
86
85
|
f.close
|
87
|
-
result
|
86
|
+
result.encode("UTF-8", "binary",
|
87
|
+
invalid: :replace, undef: :replace, replace: "")
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -19,7 +19,8 @@ module Inch
|
|
19
19
|
if proxy_object = @cache[cache_key(yard_object)]
|
20
20
|
proxy_object
|
21
21
|
else
|
22
|
-
@cache[cache_key(yard_object)] =
|
22
|
+
@cache[cache_key(yard_object)] =
|
23
|
+
class_for(yard_object).new(yard_object)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -30,7 +31,7 @@ module Inch
|
|
30
31
|
# @param yard_object [YARD::CodeObject]
|
31
32
|
# @return [Class]
|
32
33
|
def class_for(yard_object)
|
33
|
-
class_name = yard_object.class.to_s.split(
|
34
|
+
class_name = yard_object.class.to_s.split("::").last
|
34
35
|
const_get(class_name)
|
35
36
|
rescue NameError
|
36
37
|
Base
|
@@ -50,10 +51,11 @@ module Inch
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
|
-
require
|
54
|
-
require
|
55
|
-
require
|
56
|
-
require
|
57
|
-
require
|
58
|
-
require
|
59
|
-
require
|
54
|
+
require "inch/code_object/provider/yard/object/base"
|
55
|
+
require "inch/code_object/provider/yard/object/namespace_object"
|
56
|
+
require "inch/code_object/provider/yard/object/class_object"
|
57
|
+
require "inch/code_object/provider/yard/object/class_variable_object"
|
58
|
+
require "inch/code_object/provider/yard/object/constant_object"
|
59
|
+
require "inch/code_object/provider/yard/object/method_object"
|
60
|
+
require "inch/code_object/provider/yard/object/method_parameter_object"
|
61
|
+
require "inch/code_object/provider/yard/object/module_object"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "forwardable"
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module CodeObject
|
@@ -21,7 +21,9 @@ module Inch
|
|
21
21
|
AUTO_GENERATED_TAG_NAMES = %w(raise yield)
|
22
22
|
|
23
23
|
# convenient shortcuts to (YARD) code object
|
24
|
-
def_delegators :object,
|
24
|
+
def_delegators :object,
|
25
|
+
:type, :namespace, :source, :source_type, :group,
|
26
|
+
:dynamic, :visibility
|
25
27
|
|
26
28
|
# @param object [YARD::CodeObjects::Base] the actual (YARD) code object
|
27
29
|
def initialize(object)
|
@@ -67,8 +69,29 @@ module Inch
|
|
67
69
|
[]
|
68
70
|
end
|
69
71
|
|
70
|
-
RUBY_CORE = %w(
|
71
|
-
|
72
|
+
RUBY_CORE = %w(
|
73
|
+
Array Bignum BasicObject Object Module Class Complex NilClass
|
74
|
+
Numeric String Float Fiber FiberError Continuation Dir File
|
75
|
+
Encoding Enumerator StopIteration Enumerator::Generator
|
76
|
+
Enumerator::Yielder Exception SystemExit SignalException Interrupt
|
77
|
+
StandardError TypeError ArgumentError IndexError KeyError
|
78
|
+
RangeError ScriptError SyntaxError LoadError NotImplementedError
|
79
|
+
NameError NoMethodError RuntimeError SecurityError NoMemoryError
|
80
|
+
EncodingError SystemCallError Encoding::CompatibilityError
|
81
|
+
File::Stat IO Hash ENV IOError EOFError ARGF RubyVM
|
82
|
+
RubyVM::InstructionSequence Math::DomainError ZeroDivisionError
|
83
|
+
FloatDomainError Integer Fixnum Data TrueClass FalseClass Mutex
|
84
|
+
Thread Proc LocalJumpError SystemStackError Method UnboundMethod
|
85
|
+
Binding Process::Status Random Range Rational RegexpError Regexp
|
86
|
+
MatchData Symbol Struct ThreadGroup ThreadError Time
|
87
|
+
Encoding::UndefinedConversionError
|
88
|
+
Encoding::InvalidByteSequenceError
|
89
|
+
Encoding::ConverterNotFoundError Encoding::Converter RubyVM::Env
|
90
|
+
|
91
|
+
Comparable Kernel File::Constants Enumerable Errno FileTest GC
|
92
|
+
ObjectSpace GC::Profiler IO::WaitReadable IO::WaitWritable Marshal
|
93
|
+
Math Process Process::UID Process::GID Process::Sys Signal
|
94
|
+
)
|
72
95
|
def core?
|
73
96
|
RUBY_CORE.include?(name.to_s)
|
74
97
|
end
|
@@ -92,7 +115,8 @@ module Inch
|
|
92
115
|
[]
|
93
116
|
end
|
94
117
|
|
95
|
-
# CodeLocation is a utility class to find declarations of objects in
|
118
|
+
# CodeLocation is a utility class to find declarations of objects in
|
119
|
+
# files
|
96
120
|
class CodeLocation < Struct.new(:base_dir, :relative_path, :line_no)
|
97
121
|
def filename
|
98
122
|
File.join(base_dir, relative_path)
|
@@ -228,7 +252,7 @@ module Inch
|
|
228
252
|
end
|
229
253
|
|
230
254
|
def inspect
|
231
|
-
"#<#{self.class
|
255
|
+
"#<#{self.class}: #{fullname}>"
|
232
256
|
end
|
233
257
|
|
234
258
|
protected
|
@@ -248,7 +272,7 @@ module Inch
|
|
248
272
|
end
|
249
273
|
|
250
274
|
def private_api_tag?
|
251
|
-
api_tag && api_tag.text ==
|
275
|
+
api_tag && api_tag.text == "private"
|
252
276
|
end
|
253
277
|
|
254
278
|
def tag(name)
|
@@ -269,12 +293,12 @@ module Inch
|
|
269
293
|
@unconsidered_tags ||= tags.reject do |tag|
|
270
294
|
auto_generated_tag?(tag) ||
|
271
295
|
CONSIDERED_YARD_TAGS.include?(tag.tag_name)
|
272
|
-
|
296
|
+
end
|
273
297
|
end
|
274
298
|
|
275
299
|
def __depth(i = 0)
|
276
300
|
if parent
|
277
|
-
parent.__depth(i+1)
|
301
|
+
parent.__depth(i + 1)
|
278
302
|
else
|
279
303
|
i
|
280
304
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "inch/code_object/provider/yard/object/method_signature"
|
2
2
|
|
3
3
|
module Inch
|
4
4
|
module CodeObject
|
@@ -46,7 +46,7 @@ module Inch
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def parameter(name)
|
49
|
-
parameters.
|
49
|
+
parameters.find { |p| p.name == name.to_s }
|
50
50
|
end
|
51
51
|
|
52
52
|
def overridden?
|
@@ -66,14 +66,16 @@ module Inch
|
|
66
66
|
# Returns +true+ if a return value is described by it's type or
|
67
67
|
# mentioned in the docstring (e.g. "Returns a String").
|
68
68
|
def return_mentioned?
|
69
|
-
return_tags.any?
|
70
|
-
|
69
|
+
return_tags.any? do |t|
|
70
|
+
!t.types.nil? && !t.types.empty? && !YARD.implicit_tag?(t, self)
|
71
|
+
end || docstring.mentions_return? && !implicit_docstring?
|
71
72
|
end
|
72
73
|
|
73
74
|
# Returns +true+ if a return value is described by words.
|
74
75
|
def return_described?
|
75
|
-
return_tags.any?
|
76
|
-
|
76
|
+
return_tags.any? do |t|
|
77
|
+
!t.text.empty? && !YARD.implicit_tag?(t, self)
|
78
|
+
end || docstring.describes_return? && !implicit_docstring?
|
77
79
|
end
|
78
80
|
|
79
81
|
def return_typed?
|
@@ -102,24 +104,47 @@ module Inch
|
|
102
104
|
|
103
105
|
private
|
104
106
|
|
105
|
-
# Returns
|
107
|
+
# Returns @return tags that are assigned to the getter
|
108
|
+
# corresponding to this setter.
|
109
|
+
#
|
110
|
+
# @return [Array<::YARD::Tag>]
|
111
|
+
def attributed_return_tags
|
112
|
+
if setter? && object.tags(:return).empty?
|
113
|
+
method = corresponding_getter
|
114
|
+
return method.object.tags(:return) if method
|
115
|
+
end
|
116
|
+
[]
|
117
|
+
end
|
118
|
+
|
119
|
+
# @return [MethodObject,nil]
|
120
|
+
def corresponding_getter
|
121
|
+
clean_name = name.to_s.gsub(/(\=)$/, "")
|
122
|
+
parent.child(clean_name.to_sym)
|
123
|
+
end
|
124
|
+
|
125
|
+
# Returns +true+ if the docstring was generated by YARD.
|
106
126
|
def implicit_docstring?
|
107
127
|
YARD.implicit_docstring?(docstring, self)
|
108
128
|
end
|
109
129
|
|
130
|
+
# @return [Array<::YARD::Tag>]
|
110
131
|
def overload_tags
|
111
132
|
object.tags(:overload)
|
112
133
|
end
|
113
134
|
|
114
|
-
|
115
|
-
object.tags(:return) + overloaded_return_tags
|
116
|
-
end
|
117
|
-
|
135
|
+
# @return [Array<::YARD::Tag>]
|
118
136
|
def overloaded_return_tags
|
119
137
|
overload_tags.map do |overload_tag|
|
120
138
|
overload_tag.tag(:return)
|
121
139
|
end.compact
|
122
140
|
end
|
141
|
+
|
142
|
+
# @return [Array<::YARD::Tag>]
|
143
|
+
def return_tags
|
144
|
+
object.tags(:return) +
|
145
|
+
overloaded_return_tags +
|
146
|
+
attributed_return_tags
|
147
|
+
end
|
123
148
|
end
|
124
149
|
end
|
125
150
|
end
|