inch 0.5.0.rc3 → 0.5.0.rc4
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 +94 -0
- data/CHANGELOG.md +26 -2
- data/Gemfile +5 -2
- data/README.md +3 -3
- data/Rakefile +6 -2
- data/bin/inch +3 -3
- data/config/{example.yml → .inch.yml.sample} +1 -0
- data/config/base.rb +53 -0
- data/config/elixir.rb +43 -0
- data/config/nodejs.rb +10 -0
- data/config/{defaults.rb → ruby.rb} +5 -54
- data/inch.gemspec +7 -7
- data/lib/inch.rb +14 -9
- 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 +13 -16
- data/lib/inch/api/filter.rb +1 -1
- data/lib/inch/api/get.rb +2 -2
- data/lib/inch/api/options/base.rb +4 -4
- data/lib/inch/api/options/filter.rb +0 -4
- data/lib/inch/api/options/suggest.rb +2 -6
- data/lib/inch/api/stats.rb +0 -1
- data/lib/inch/api/suggest.rb +9 -10
- data/lib/inch/cli.rb +6 -6
- data/lib/inch/cli/arguments.rb +2 -2
- data/lib/inch/cli/command.rb +15 -15
- data/lib/inch/cli/command/base.rb +30 -9
- data/lib/inch/cli/command/base_list.rb +2 -2
- data/lib/inch/cli/command/console.rb +5 -5
- data/lib/inch/cli/command/diff.rb +9 -9
- 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 +17 -16
- 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 +8 -6
- data/lib/inch/cli/command/options/inspect.rb +2 -2
- data/lib/inch/cli/command/options/list.rb +3 -2
- 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 +4 -6
- data/lib/inch/cli/command/output/console.rb +6 -7
- 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 +31 -28
- 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 +6 -6
- 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 +11 -11
- data/lib/inch/code_object/proxy.rb +61 -30
- data/lib/inch/codebase.rb +7 -8
- data/lib/inch/codebase/object.rb +60 -0
- data/lib/inch/codebase/objects.rb +8 -10
- data/lib/inch/codebase/objects_filter.rb +7 -5
- data/lib/inch/codebase/proxy.rb +4 -4
- data/lib/inch/codebase/serializer.rb +3 -3
- data/lib/inch/config.rb +42 -11
- data/lib/inch/config/base.rb +8 -29
- data/lib/inch/config/codebase.rb +32 -7
- data/lib/inch/config/evaluation.rb +61 -0
- data/lib/inch/core_ext.rb +1 -1
- data/lib/inch/core_ext/string.rb +1 -1
- data/lib/inch/evaluation.rb +13 -21
- data/lib/inch/evaluation/file.rb +4 -2
- data/lib/inch/evaluation/grade_list.rb +4 -4
- data/lib/inch/evaluation/priority_range.rb +3 -0
- data/lib/inch/evaluation/proxy.rb +139 -14
- data/lib/inch/evaluation/role.rb +99 -0
- data/lib/inch/language.rb +3 -0
- data/lib/inch/language/elixir/code_object/base.rb +197 -0
- data/lib/inch/language/elixir/code_object/function_object.rb +74 -0
- data/lib/inch/language/elixir/code_object/module_object.rb +23 -0
- data/lib/inch/language/elixir/code_object/type_object.rb +11 -0
- data/lib/inch/language/elixir/evaluation/base.rb +28 -0
- data/lib/inch/language/elixir/evaluation/function_object.rb +31 -0
- data/lib/inch/language/elixir/evaluation/module_object.rb +27 -0
- data/lib/inch/language/elixir/evaluation/type_object.rb +11 -0
- data/lib/inch/language/elixir/import.rb +24 -0
- data/lib/inch/language/elixir/provider/reader.rb +19 -0
- data/lib/inch/language/elixir/provider/reader/object.rb +63 -0
- data/lib/inch/language/elixir/provider/reader/object/base.rb +191 -0
- data/lib/inch/language/elixir/provider/reader/object/function_object.rb +26 -0
- data/lib/inch/language/elixir/provider/reader/object/module_object.rb +22 -0
- data/lib/inch/language/elixir/provider/reader/object/type_object.rb +15 -0
- data/lib/inch/language/elixir/provider/reader/parser.rb +55 -0
- data/lib/inch/language/elixir/roles/base.rb +32 -0
- data/lib/inch/language/elixir/roles/function.rb +112 -0
- data/lib/inch/language/elixir/roles/module.rb +64 -0
- data/lib/inch/language/elixir/roles/object.rb +76 -0
- data/lib/inch/language/elixir/roles/type.rb +13 -0
- data/lib/inch/language/nodejs/import.rb +8 -0
- data/lib/inch/language/nodejs/provider/jsdoc.rb +19 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object.rb +55 -0
- data/lib/inch/language/nodejs/provider/jsdoc/object/base.rb +191 -0
- data/lib/inch/language/nodejs/provider/jsdoc/parser.rb +59 -0
- data/lib/inch/language/ruby/code_object/base.rb +197 -0
- data/lib/inch/language/ruby/code_object/class_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/class_variable_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/constant_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/method_object.rb +85 -0
- data/lib/inch/language/ruby/code_object/method_parameter_object.rb +64 -0
- data/lib/inch/language/ruby/code_object/module_object.rb +10 -0
- data/lib/inch/language/ruby/code_object/namespace_object.rb +35 -0
- data/lib/inch/language/ruby/evaluation/base.rb +45 -0
- data/lib/inch/language/ruby/evaluation/class_object.rb +10 -0
- data/lib/inch/language/ruby/evaluation/class_variable_object.rb +21 -0
- data/lib/inch/language/ruby/evaluation/constant_object.rb +21 -0
- data/lib/inch/language/ruby/evaluation/method_object.rb +74 -0
- data/lib/inch/language/ruby/evaluation/module_object.rb +10 -0
- data/lib/inch/language/ruby/evaluation/namespace_object.rb +30 -0
- data/lib/inch/language/ruby/import.rb +34 -0
- data/lib/inch/language/ruby/provider/yard.rb +58 -0
- data/lib/inch/language/ruby/provider/yard/docstring.rb +162 -0
- data/lib/inch/language/ruby/provider/yard/nodoc_helper.rb +97 -0
- data/lib/inch/language/ruby/provider/yard/object.rb +63 -0
- data/lib/inch/language/ruby/provider/yard/object/base.rb +325 -0
- data/lib/inch/language/ruby/provider/yard/object/class_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/class_variable_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/constant_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/method_object.rb +170 -0
- data/lib/inch/language/ruby/provider/yard/object/method_parameter_object.rb +94 -0
- data/lib/inch/language/ruby/provider/yard/object/method_signature.rb +120 -0
- data/lib/inch/language/ruby/provider/yard/object/module_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/object/namespace_object.rb +46 -0
- data/lib/inch/language/ruby/provider/yard/object/root_object.rb +14 -0
- data/lib/inch/language/ruby/provider/yard/parser.rb +71 -0
- data/lib/inch/language/ruby/roles/base.rb +17 -0
- data/lib/inch/language/ruby/roles/class_variable.rb +53 -0
- data/lib/inch/language/ruby/roles/constant.rb +53 -0
- data/lib/inch/language/ruby/roles/method.rb +112 -0
- data/lib/inch/language/ruby/roles/method_parameter.rb +84 -0
- data/lib/inch/language/ruby/roles/missing.rb +24 -0
- data/lib/inch/language/ruby/roles/namespace.rb +89 -0
- data/lib/inch/language/ruby/roles/object.rb +120 -0
- data/lib/inch/rake.rb +2 -2
- data/lib/inch/rake/suggest.rb +7 -2
- data/lib/inch/utils/buffered_ui.rb +16 -0
- 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/{code_examples → ruby/code_examples}/lib/foo.rb +0 -0
- data/test/fixtures/{diff1 → ruby/diff1}/lib/diff1.rb +0 -0
- data/test/fixtures/{diff2 → ruby/diff2}/lib/diff2.rb +0 -0
- data/test/fixtures/{inch-yml → ruby/inch-yml}/.inch.yml +0 -0
- data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/bar.rb +0 -0
- data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/vendor/base.rb +0 -0
- data/test/fixtures/{parameters → ruby/parameters}/lib/foo.rb +0 -0
- data/test/fixtures/{readme → ruby/readme}/lib/foo.rb +0 -0
- data/test/fixtures/{really_good → ruby/really_good}/lib/foo.rb +0 -0
- data/test/fixtures/{really_good_pedantic → ruby/really_good_pedantic}/lib/foo.rb +0 -0
- data/test/fixtures/{simple → ruby/simple}/README +0 -0
- data/test/fixtures/{simple → ruby/simple}/lib/broken.rb +11 -19
- data/test/fixtures/ruby/simple/lib/broken_ruby_2_0_features.rb +7 -0
- data/test/fixtures/ruby/simple/lib/directives.rb +8 -0
- data/test/fixtures/{simple → ruby/simple}/lib/foo.rb +22 -1
- data/test/fixtures/{simple → ruby/simple}/lib/nodoc.rb +0 -0
- data/test/fixtures/{simple → ruby/simple}/lib/role_methods.rb +0 -0
- data/test/fixtures/{simple → ruby/simple}/lib/role_namespaces.rb +0 -0
- data/test/fixtures/{visibility → ruby/visibility}/lib/foo.rb +0 -0
- data/test/fixtures/{yardopts → ruby/yardopts}/.yardopts +0 -0
- data/test/fixtures/{yardopts → ruby/yardopts}/foo/bar.rb +0 -0
- data/test/integration/api/compare/codebases.rb +3 -3
- data/test/integration/cli/command/console_test.rb +6 -6
- data/test/integration/cli/command/diff_test.rb +62 -0
- data/test/integration/cli/command/inspect_test.rb +5 -6
- data/test/integration/cli/command/list_test.rb +4 -5
- data/test/integration/cli/command/show_test.rb +5 -5
- data/test/integration/cli/command/stats_test.rb +3 -3
- data/test/integration/cli/command/suggest_test.rb +13 -13
- data/test/integration/stats_options_test.rb +4 -4
- data/test/integration/visibility_options_test.rb +14 -14
- data/test/shared/base_list.rb +4 -3
- data/test/test_helper.rb +13 -13
- 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 +2 -2
- 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 +3 -3
- data/test/unit/cli/trace_helper_test.rb +1 -1
- data/test/unit/cli/yardopts_helper_test.rb +6 -5
- data/test/unit/code_object/converter_test.rb +1 -1
- data/test/unit/code_object/provider_test.rb +2 -2
- data/test/unit/code_object/proxy_test.rb +2 -2
- data/test/unit/codebase/objects_test.rb +2 -2
- data/test/unit/codebase/proxy_test.rb +7 -5
- data/test/unit/config/codebase_test.rb +4 -4
- data/test/unit/config_test.rb +28 -0
- data/test/unit/evaluation/{role/base_test.rb → role_test.rb} +7 -7
- data/test/unit/{code_object/proxy → language/ruby/code_object}/method_object_test.rb +66 -21
- data/test/unit/{code_object → language/ruby}/provider/yard/docstring_test.rb +74 -38
- data/test/unit/{code_object → language/ruby}/provider/yard/nodoc_helper_test.rb +9 -7
- data/test/unit/{code_object → language/ruby}/provider/yard/object/method_object_test.rb +21 -11
- data/test/unit/language/ruby/provider/yard_test.rb +25 -0
- data/test/unit/utils/buffered_ui_test.rb +48 -0
- data/test/unit/utils/ui_test.rb +7 -7
- data/test/unit/utils/weighted_list_test.rb +7 -4
- metadata +139 -93
- data/lib/inch/code_object/provider/yard.rb +0 -57
- data/lib/inch/code_object/provider/yard/docstring.rb +0 -133
- data/lib/inch/code_object/provider/yard/nodoc_helper.rb +0 -93
- data/lib/inch/code_object/provider/yard/object.rb +0 -60
- data/lib/inch/code_object/provider/yard/object/base.rb +0 -302
- data/lib/inch/code_object/provider/yard/object/class_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/constant_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/method_object.rb +0 -153
- data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +0 -88
- data/lib/inch/code_object/provider/yard/object/method_signature.rb +0 -114
- data/lib/inch/code_object/provider/yard/object/module_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/object/namespace_object.rb +0 -47
- data/lib/inch/code_object/provider/yard/object/root_object.rb +0 -12
- data/lib/inch/code_object/provider/yard/parser.rb +0 -62
- data/lib/inch/code_object/proxy/base.rb +0 -241
- data/lib/inch/code_object/proxy/class_object.rb +0 -8
- data/lib/inch/code_object/proxy/class_variable_object.rb +0 -8
- data/lib/inch/code_object/proxy/constant_object.rb +0 -8
- data/lib/inch/code_object/proxy/method_object.rb +0 -82
- data/lib/inch/code_object/proxy/method_parameter_object.rb +0 -60
- data/lib/inch/code_object/proxy/module_object.rb +0 -8
- data/lib/inch/code_object/proxy/namespace_object.rb +0 -33
- data/lib/inch/evaluation/object_schema.rb +0 -30
- data/lib/inch/evaluation/proxy/base.rb +0 -164
- data/lib/inch/evaluation/proxy/class_object.rb +0 -8
- data/lib/inch/evaluation/proxy/class_variable_object.rb +0 -19
- data/lib/inch/evaluation/proxy/constant_object.rb +0 -19
- data/lib/inch/evaluation/proxy/method_object.rb +0 -65
- data/lib/inch/evaluation/proxy/module_object.rb +0 -8
- data/lib/inch/evaluation/proxy/namespace_object.rb +0 -27
- data/lib/inch/evaluation/role/base.rb +0 -92
- data/lib/inch/evaluation/role/class_variable.rb +0 -55
- data/lib/inch/evaluation/role/constant.rb +0 -55
- data/lib/inch/evaluation/role/method.rb +0 -126
- data/lib/inch/evaluation/role/method_parameter.rb +0 -91
- data/lib/inch/evaluation/role/missing.rb +0 -20
- data/lib/inch/evaluation/role/namespace.rb +0 -85
- data/lib/inch/evaluation/role/object.rb +0 -143
- data/test/unit/code_object/provider/yard_test.rb +0 -25
@@ -1,15 +1,14 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../../test_helper")
|
2
2
|
|
3
|
-
describe ::Inch::
|
4
|
-
let(:described_class) { ::Inch::
|
3
|
+
describe ::Inch::Language::Ruby::Provider::YARD::Docstring do
|
4
|
+
let(:described_class) { ::Inch::Language::Ruby::Provider::YARD::Docstring }
|
5
5
|
|
6
6
|
#
|
7
7
|
# loose TomDoc compatibility
|
8
8
|
#
|
9
9
|
|
10
|
-
|
11
10
|
it "should notice things in tomdoc style docs" do
|
12
|
-
text = <<-DOC
|
11
|
+
text = <<-DOC
|
13
12
|
Internal: Detects the Language of the blob.
|
14
13
|
|
15
14
|
param1 - String filename
|
@@ -19,7 +18,7 @@ param2 - String blob data. A block also maybe passed in for lazy
|
|
19
18
|
param3 - Optional String mode (defaults to nil)
|
20
19
|
|
21
20
|
Returns Language or nil.
|
22
|
-
DOC
|
21
|
+
DOC
|
23
22
|
docstring = described_class.new(text)
|
24
23
|
assert docstring.describes_internal_api?
|
25
24
|
assert docstring.mentions_parameter?(:param1)
|
@@ -34,7 +33,7 @@ DOC
|
|
34
33
|
end
|
35
34
|
|
36
35
|
it "should notice things in tomdoc style docs 2" do
|
37
|
-
text = <<-DOC
|
36
|
+
text = <<-DOC
|
38
37
|
Public: Look up Language by one of its aliases.
|
39
38
|
|
40
39
|
param1 - A String alias of the Language
|
@@ -45,7 +44,7 @@ Examples
|
|
45
44
|
# => #<Language name="C++">
|
46
45
|
|
47
46
|
Returns the Lexer or nil if none was found.
|
48
|
-
DOC
|
47
|
+
DOC
|
49
48
|
docstring = described_class.new(text)
|
50
49
|
assert docstring.mentions_parameter?(:param1)
|
51
50
|
assert docstring.describes_parameter?(:param1)
|
@@ -56,8 +55,33 @@ DOC
|
|
56
55
|
assert docstring.describes_return?
|
57
56
|
end
|
58
57
|
|
58
|
+
it "should notice multi-line returns in tomdoc style docs" do
|
59
|
+
text = <<-DOC
|
60
|
+
Public: Look up Language by one of its aliases.
|
61
|
+
|
62
|
+
Returns the Lexer or nil
|
63
|
+
if none was found.
|
64
|
+
DOC
|
65
|
+
docstring = described_class.new(text)
|
66
|
+
assert docstring.mentions_return?
|
67
|
+
assert docstring.describes_return?
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should notice multi-line returns in tomdoc style docs 2" do
|
71
|
+
text = <<-DOC
|
72
|
+
Public: Look up Language by one of its aliases.
|
73
|
+
|
74
|
+
Returns the Lexer or nil
|
75
|
+
if none
|
76
|
+
was found.
|
77
|
+
DOC
|
78
|
+
docstring = described_class.new(text)
|
79
|
+
assert docstring.mentions_return?
|
80
|
+
assert docstring.describes_return?
|
81
|
+
end
|
82
|
+
|
59
83
|
it "should notice things in tomdoc style docs 3" do
|
60
|
-
text = <<-DOC
|
84
|
+
text = <<-DOC
|
61
85
|
Public: Look up Language by one of its aliases.
|
62
86
|
|
63
87
|
param1 - A String alias of the Language
|
@@ -68,7 +92,7 @@ Examples
|
|
68
92
|
# => #<Language name="C++">
|
69
93
|
|
70
94
|
Returns the Lexer or nil if none was found.
|
71
|
-
DOC
|
95
|
+
DOC
|
72
96
|
docstring = described_class.new(text)
|
73
97
|
assert docstring.mentions_parameter?(:param1)
|
74
98
|
assert docstring.describes_parameter?(:param1)
|
@@ -80,42 +104,43 @@ DOC
|
|
80
104
|
end
|
81
105
|
|
82
106
|
it "should understand 'Returns nil.'" do
|
83
|
-
text = <<-DOC
|
107
|
+
text = <<-DOC
|
84
108
|
[...]
|
85
109
|
Returns nil.
|
86
|
-
DOC
|
110
|
+
DOC
|
87
111
|
docstring = described_class.new(text)
|
88
112
|
assert docstring.describes_return?
|
89
113
|
end
|
90
114
|
|
91
115
|
it "should understand 'Returns nil.' without fullstop and in lowercase" do
|
92
|
-
text = <<-DOC
|
116
|
+
text = <<-DOC
|
93
117
|
[...]
|
94
118
|
returns nil
|
95
|
-
DOC
|
119
|
+
DOC
|
96
120
|
docstring = described_class.new(text)
|
97
121
|
assert docstring.describes_return?
|
98
122
|
end
|
99
123
|
|
100
124
|
it "should understand 'Returns nothing.'" do
|
101
|
-
text = <<-DOC
|
125
|
+
text = <<-DOC
|
102
126
|
[...]
|
103
127
|
Returns nothing.
|
104
|
-
DOC
|
128
|
+
DOC
|
105
129
|
docstring = described_class.new(text)
|
106
130
|
assert docstring.describes_return?
|
107
131
|
end
|
108
132
|
|
109
133
|
it "should understand 'Returns nothing.' without fullstop and in lowercase" do
|
110
|
-
text = <<-DOC
|
134
|
+
text = <<-DOC
|
111
135
|
[...]
|
112
136
|
returns nothing
|
113
|
-
DOC
|
137
|
+
DOC
|
114
138
|
docstring = described_class.new(text)
|
115
139
|
assert docstring.describes_return?
|
116
140
|
end
|
117
141
|
|
118
|
-
it "should understand 'Returns ...' with a visibility modifier in front of
|
142
|
+
it "should understand 'Returns ...' with a visibility modifier in front of" \
|
143
|
+
" it" do
|
119
144
|
text = "Public: Returns the Integer color."
|
120
145
|
docstring = described_class.new(text)
|
121
146
|
assert docstring.mentions_return?
|
@@ -126,37 +151,32 @@ DOC
|
|
126
151
|
# PARAMETER MENTIONS
|
127
152
|
#
|
128
153
|
|
129
|
-
|
130
154
|
it "should work 2" do
|
131
|
-
text = <<-DOC
|
155
|
+
text = <<-DOC
|
132
156
|
Just because format_html is mentioned here, does not mean
|
133
157
|
the first parameter is mentioned.
|
134
|
-
DOC
|
158
|
+
DOC
|
135
159
|
docstring = described_class.new(text)
|
136
160
|
refute docstring.mentions_parameter?(:format)
|
137
161
|
refute docstring.contains_code_example?
|
138
162
|
end
|
139
163
|
|
140
|
-
|
141
164
|
it "should work 2 if correct" do
|
142
|
-
text = <<-DOC
|
165
|
+
text = <<-DOC
|
143
166
|
Just because format is mentioned here, does not mean
|
144
167
|
the first parameter is meant.
|
145
|
-
DOC
|
168
|
+
DOC
|
146
169
|
docstring = described_class.new(text)
|
147
170
|
refute docstring.mentions_parameter?(:format)
|
148
171
|
refute docstring.contains_code_example?
|
149
172
|
end
|
150
173
|
|
151
|
-
|
152
|
-
|
153
174
|
#
|
154
175
|
# CODE EXAMPLES
|
155
176
|
#
|
156
177
|
|
157
|
-
|
158
178
|
it "should work 3" do
|
159
|
-
text = <<-DOC
|
179
|
+
text = <<-DOC
|
160
180
|
An example of a method using RDoc rather than YARD.
|
161
181
|
|
162
182
|
== Parameters:
|
@@ -165,13 +185,13 @@ param1::
|
|
165
185
|
|
166
186
|
== Returns:
|
167
187
|
A string in the specified format.
|
168
|
-
DOC
|
188
|
+
DOC
|
169
189
|
docstring = described_class.new(text)
|
170
190
|
refute docstring.contains_code_example?
|
171
191
|
end
|
172
192
|
|
173
193
|
it "should work with code example" do
|
174
|
-
text = <<-DOC
|
194
|
+
text = <<-DOC
|
175
195
|
Another example.
|
176
196
|
|
177
197
|
method_with_code_example() # => some value
|
@@ -180,7 +200,7 @@ Params:
|
|
180
200
|
+param1+:: param1 line string to be executed by the system
|
181
201
|
+param2+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
182
202
|
+param3+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
183
|
-
DOC
|
203
|
+
DOC
|
184
204
|
docstring = described_class.new(text)
|
185
205
|
assert docstring.contains_code_example?
|
186
206
|
assert docstring.mentions_parameter?(:param1)
|
@@ -191,21 +211,37 @@ DOC
|
|
191
211
|
assert docstring.describes_parameter?(:param3)
|
192
212
|
end
|
193
213
|
|
214
|
+
it "should recognize several parameter notations" do
|
215
|
+
text = <<-DOC
|
216
|
+
Params:
|
217
|
+
+param1<String>+:: param1 line string to be executed by the system
|
218
|
+
+param2<String,nil>+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
219
|
+
+param3<String|Class>+:: +Proc+ object that takes a pipe object as first and only param (may be nil)
|
220
|
+
DOC
|
221
|
+
docstring = described_class.new(text)
|
222
|
+
assert docstring.mentions_parameter?(:param1), "should mention param1"
|
223
|
+
assert docstring.mentions_parameter?(:param2), "should mention param2"
|
224
|
+
assert docstring.mentions_parameter?(:param3), "should mention param3"
|
225
|
+
assert docstring.describes_parameter?(:param1), "should describe param1"
|
226
|
+
assert docstring.describes_parameter?(:param2), "should describe param2"
|
227
|
+
assert docstring.describes_parameter?(:param3), "should describe param3"
|
228
|
+
end
|
229
|
+
|
194
230
|
it "should work with code example 2" do
|
195
|
-
text = <<-DOC
|
231
|
+
text = <<-DOC
|
196
232
|
Just because format_html is mentioned here, does not mean
|
197
233
|
the first parameter is mentioned.
|
198
234
|
|
199
235
|
method_with_code_example() # => some value
|
200
236
|
method_with_missing_param_doc(param1, param2, param3)
|
201
|
-
DOC
|
237
|
+
DOC
|
202
238
|
docstring = described_class.new(text)
|
203
239
|
assert docstring.contains_code_example?
|
204
240
|
assert_equal 1, docstring.code_examples.size
|
205
241
|
end
|
206
242
|
|
207
243
|
it "should work with code example 3" do
|
208
|
-
text = <<-DOC
|
244
|
+
text = <<-DOC
|
209
245
|
An example of a method using RDoc rather than YARD.
|
210
246
|
|
211
247
|
method_with_code_example() # => some value
|
@@ -216,7 +252,7 @@ param1::
|
|
216
252
|
|
217
253
|
== Returns:
|
218
254
|
A string in the specified format.
|
219
|
-
DOC
|
255
|
+
DOC
|
220
256
|
docstring = described_class.new(text)
|
221
257
|
assert docstring.contains_code_example?
|
222
258
|
assert_equal 1, docstring.code_examples.size
|
@@ -225,7 +261,7 @@ DOC
|
|
225
261
|
end
|
226
262
|
|
227
263
|
it "should work with multiple code examples" do
|
228
|
-
text = <<-DOC
|
264
|
+
text = <<-DOC
|
229
265
|
An example of a method using RDoc rather than YARD.
|
230
266
|
|
231
267
|
method_with_code_example() # => some value
|
@@ -241,7 +277,7 @@ param1::
|
|
241
277
|
|
242
278
|
== Returns:
|
243
279
|
A string in the specified format.
|
244
|
-
DOC
|
280
|
+
DOC
|
245
281
|
docstring = described_class.new(text)
|
246
282
|
assert docstring.contains_code_example?
|
247
283
|
assert_equal 2, docstring.code_examples.size
|
@@ -1,8 +1,9 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../../test_helper")
|
2
2
|
|
3
|
-
describe ::Inch::
|
3
|
+
describe ::Inch::Language::Ruby::Provider::YARD::NodocHelper do
|
4
4
|
before do
|
5
|
-
@
|
5
|
+
@config = Inch::Config.codebase
|
6
|
+
@provider = ::Inch::Language::Ruby::Provider::YARD.parse(fixture_path(:ruby, :simple), @config)
|
6
7
|
@objects = @provider.objects
|
7
8
|
end
|
8
9
|
|
@@ -17,9 +18,9 @@ describe ::Inch::CodeObject::Provider::YARD::NodocHelper do
|
|
17
18
|
"Foo::HiddenClass::EvenMoreHiddenClass",
|
18
19
|
"Foo::HiddenClass::EvenMoreHiddenClass#method_with_implicit_nodoc",
|
19
20
|
"Foo::HiddenClassViaTag",
|
20
|
-
"Foo::HiddenClassViaTag#some_value"
|
21
|
+
"Foo::HiddenClassViaTag#some_value"
|
21
22
|
].each do |query|
|
22
|
-
m = @objects.
|
23
|
+
m = @objects.find { |o| o.fullname == query }
|
23
24
|
assert m.nodoc?, "nodoc? should return true for #{query}"
|
24
25
|
end
|
25
26
|
end
|
@@ -30,9 +31,10 @@ describe ::Inch::CodeObject::Provider::YARD::NodocHelper do
|
|
30
31
|
"Foo::Qux::Quux::PUBLIC_VALUE",
|
31
32
|
"Foo::Qux::DOCCED_VALUE",
|
32
33
|
"Foo::HiddenClass::EvenMoreHiddenClass::SuddenlyVisibleClass",
|
33
|
-
"Foo::HiddenClass::EvenMoreHiddenClass::SuddenlyVisibleClass
|
34
|
+
"Foo::HiddenClass::EvenMoreHiddenClass::SuddenlyVisibleClass" \
|
35
|
+
"#method_with_implicit_doc"
|
34
36
|
].each do |query|
|
35
|
-
m = @objects.
|
37
|
+
m = @objects.find { |o| o.fullname == query }
|
36
38
|
refute m.nodoc?, "nodoc? should return false for #{query}"
|
37
39
|
end
|
38
40
|
end
|
@@ -1,14 +1,17 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) +
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../../../test_helper")
|
2
2
|
|
3
|
-
describe ::Inch::
|
3
|
+
describe ::Inch::Language::Ruby::Provider::YARD::Parser do
|
4
4
|
before do
|
5
5
|
@config = Inch::Config.codebase
|
6
|
-
@parser = ::Inch::
|
6
|
+
@parser = ::Inch::Language::Ruby::Provider::YARD::Parser.parse(
|
7
|
+
fixture_path(:ruby, :simple), @config)
|
7
8
|
@objects = @parser.objects
|
8
9
|
end
|
9
10
|
|
10
11
|
it "should work for Overloading#params_also_in_overloads" do
|
11
|
-
m = @objects.
|
12
|
+
m = @objects.find do |o|
|
13
|
+
o.fullname == "Overloading#params_also_in_overloads"
|
14
|
+
end
|
12
15
|
|
13
16
|
assert m.has_code_example?
|
14
17
|
|
@@ -16,7 +19,8 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
16
19
|
assert_equal 2, m.parameters.size # at this moment, this counts all parameters in all overloaded signatures
|
17
20
|
|
18
21
|
signature = m.signatures[0]
|
19
|
-
assert_equal "params_also_in_overloads(user_options = {})",
|
22
|
+
assert_equal "params_also_in_overloads(user_options = {})",
|
23
|
+
signature.signature
|
20
24
|
assert_equal 1, signature.parameters.size
|
21
25
|
refute signature.parameter(:user_options).nil?
|
22
26
|
assert signature.has_code_example?
|
@@ -24,7 +28,8 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
24
28
|
|
25
29
|
signature = m.signatures[1]
|
26
30
|
assert_equal "params_also_in_overloads()", signature.signature
|
27
|
-
assert signature.parameters.empty?,
|
31
|
+
assert signature.parameters.empty?,
|
32
|
+
"Should have been empty: #{signature.parameters.inspect}"
|
28
33
|
assert signature.has_code_example?
|
29
34
|
refute signature.has_doc?
|
30
35
|
|
@@ -37,7 +42,9 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
37
42
|
end
|
38
43
|
|
39
44
|
it "should work for Overloading#params_only_in_overloads" do
|
40
|
-
m = @objects.
|
45
|
+
m = @objects.find do |o|
|
46
|
+
o.fullname == "Overloading#params_only_in_overloads"
|
47
|
+
end
|
41
48
|
|
42
49
|
assert m.has_code_example?
|
43
50
|
|
@@ -46,7 +53,8 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
46
53
|
|
47
54
|
signature = m.signatures[0]
|
48
55
|
assert_equal "params_only_in_overloads()", signature.signature
|
49
|
-
assert signature.parameters.empty?,
|
56
|
+
assert signature.parameters.empty?,
|
57
|
+
"Should have been empty: #{signature.parameters.inspect}"
|
50
58
|
assert signature.has_code_example?
|
51
59
|
refute signature.has_doc?
|
52
60
|
|
@@ -62,17 +70,19 @@ describe ::Inch::CodeObject::Provider::YARD::Parser do
|
|
62
70
|
assert_equal 1, signature.parameters.size
|
63
71
|
refute signature.parameter(:user_options).nil?
|
64
72
|
assert signature.has_code_example?
|
65
|
-
#assert signature.has_doc?
|
73
|
+
# assert signature.has_doc?
|
66
74
|
end
|
67
75
|
|
68
76
|
it "should work" do
|
69
|
-
m = @objects.
|
77
|
+
m = @objects.find do |o|
|
78
|
+
o.fullname == "Foo::Bar#method_with_unstructured_doc"
|
79
|
+
end
|
70
80
|
assert_equal 1, m.signatures.size
|
71
81
|
assert_equal 1, m.parameters.size
|
72
82
|
end
|
73
83
|
|
74
84
|
it "should work 2" do
|
75
|
-
m = @objects.
|
85
|
+
m = @objects.find { |o| o.fullname == "Foo#method_with_splat_parameter" }
|
76
86
|
assert_equal 1, m.signatures.size
|
77
87
|
assert_equal 1, m.parameters.size
|
78
88
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../test_helper")
|
2
|
+
|
3
|
+
describe ::Inch::Language::Ruby::Provider::YARD do
|
4
|
+
let(:described_class) { ::Inch::Language::Ruby::Provider::YARD }
|
5
|
+
let(:config) { ::Inch::Config.codebase }
|
6
|
+
|
7
|
+
it "should parse" do
|
8
|
+
provider = described_class.parse(fixture_path(:ruby, :simple), config)
|
9
|
+
assert !provider.objects.empty?
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should parse too different codebases" do
|
13
|
+
fullname = "Foo#b"
|
14
|
+
|
15
|
+
provider1 = described_class.parse(fixture_path(:ruby, :diff1), config)
|
16
|
+
object1 = provider1.objects.find { |o| o.fullname == fullname }
|
17
|
+
|
18
|
+
provider2 = described_class.parse(fixture_path(:ruby, :diff2), config)
|
19
|
+
object2 = provider2.objects.find { |o| o.fullname == fullname }
|
20
|
+
|
21
|
+
refute object1.nil?
|
22
|
+
refute object2.nil?
|
23
|
+
assert object1.object_id != object2.object_id
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
|
2
|
+
require 'inch/utils/buffered_ui'
|
3
|
+
|
4
|
+
describe ::Inch::Utils::BufferedUI do
|
5
|
+
let(:described_class) { ::Inch::Utils::BufferedUI }
|
6
|
+
it "should trace" do
|
7
|
+
out, err = capture_io do
|
8
|
+
@instance = described_class.new
|
9
|
+
@instance.trace("Test")
|
10
|
+
end
|
11
|
+
assert out.empty?, "there should be output"
|
12
|
+
assert err.empty?, "there should be no errors"
|
13
|
+
refute @instance.buffer.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should trace header" do
|
17
|
+
out, err = capture_io do
|
18
|
+
@instance = described_class.new
|
19
|
+
@instance.header("Test", :red)
|
20
|
+
end
|
21
|
+
assert out.empty?, "there should be output"
|
22
|
+
assert err.empty?, "there should be no errors"
|
23
|
+
refute @instance.buffer.empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should trace debug if ENV variable is set" do
|
27
|
+
ENV["DEBUG"] = "1"
|
28
|
+
out, err = capture_io do
|
29
|
+
@instance = described_class.new
|
30
|
+
@instance.debug("Test")
|
31
|
+
end
|
32
|
+
ENV["DEBUG"] = nil
|
33
|
+
assert out.empty?, "there should be output"
|
34
|
+
assert err.empty?, "there should be no errors"
|
35
|
+
refute @instance.buffer.empty?
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should not trace debug if ENV variable is set" do
|
39
|
+
refute ENV["DEBUG"]
|
40
|
+
out, err = capture_io do
|
41
|
+
@instance = described_class.new
|
42
|
+
@instance.debug("Test")
|
43
|
+
end
|
44
|
+
assert out.empty?, "there should be no output"
|
45
|
+
assert err.empty?, "there should be no errors"
|
46
|
+
assert @instance.buffer.empty?
|
47
|
+
end
|
48
|
+
end
|