inch 0.5.9 → 0.5.10
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/lib/inch/cli.rb +6 -1
- data/lib/inch/language/nodejs/provider/jsdoc/docstring.rb +25 -15
- data/lib/inch/language/nodejs/provider/jsdoc/object/base.rb +19 -15
- data/lib/inch/language/nodejs/provider/jsdoc/object/function_parameter_object.rb +1 -1
- data/lib/inch/language/nodejs/provider/jsdoc/object/module_object.rb +0 -4
- data/lib/inch/language/nodejs/provider/jsdoc/parser.rb +1 -1
- data/lib/inch/version.rb +1 -1
- data/test/fixtures/nodejs/inch_test/all.json +253 -0
- data/test/unit/language/nodejs/code_object/function_object_test.rb +59 -0
- data/test/unit/language/nodejs/provider/jsdoc/docstring_test.rb +27 -5
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72f3a96a1d7027c5f7e4f02377a3d2c7e6ab0483
|
4
|
+
data.tar.gz: 9d37e5e3c38c2cd9e2e73a8d4346bc14056b9d01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1c444e52a2a5c52b488fda70e7fe7d2997fdee57e23003964134f4d32c4e700e2ad711a9ae4ffb4fc028b266f82635a13f72039d0a0ad5114166f38e30d1aa8
|
7
|
+
data.tar.gz: b634cae70beb91a1c6675d0cdac62bf6011a0b756476a04eee564808e32c5662a7403264ad6ceeb39c4b50e273d3a7b159187be00ce80c675b688794c61d10b9
|
data/lib/inch/cli.rb
CHANGED
@@ -7,16 +7,8 @@ module Inch
|
|
7
7
|
class Docstring < Ruby::Provider::YARD::Docstring
|
8
8
|
VISIBILITIES = %w(public protected private)
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
# Docstring.new("// test").without_comment_markers
|
13
|
-
# # => "test"
|
14
|
-
#
|
15
|
-
# @return [String]
|
16
|
-
def without_comment_markers
|
17
|
-
@text.lines.map do |line|
|
18
|
-
line.strip.gsub(/^(\s*(\/\*+|\/\/|\*+\/|\*)+\s?)/m, '')
|
19
|
-
end.join("\n").strip
|
10
|
+
def initialize(text)
|
11
|
+
@text = without_comment_markers(text)
|
20
12
|
end
|
21
13
|
|
22
14
|
def describes_internal_api?
|
@@ -26,7 +18,8 @@ module Inch
|
|
26
18
|
def describes_parameter?(name)
|
27
19
|
return false if name.nil?
|
28
20
|
parameter = parameter_notations(name)
|
29
|
-
|
21
|
+
type_notation = /(\{[^\}]+\}|\[[^\]]+\])/
|
22
|
+
tag?(:param, /#{type_notation}\s+#{parameter}\s+\S+/)
|
30
23
|
end
|
31
24
|
|
32
25
|
def mentions_parameter?(name)
|
@@ -44,22 +37,39 @@ module Inch
|
|
44
37
|
tag?(:return, /#{type_notation}*(\s\w+)/) || super
|
45
38
|
end
|
46
39
|
|
47
|
-
|
40
|
+
# @param access_value [nil,String] visibility in JSDoc output
|
41
|
+
def visibility(access_value = nil)
|
48
42
|
tagged_value = VISIBILITIES.detect do |v|
|
49
43
|
tag?(v)
|
50
44
|
end
|
51
|
-
(tagged_value || 'public').to_sym
|
45
|
+
(tagged_value || access_value || 'public').to_sym
|
52
46
|
end
|
53
47
|
|
54
48
|
def tag?(tagname, regex = nil)
|
55
|
-
|
49
|
+
tag_regex = /^\s*\@#{tagname}([^\n]*)$/m
|
50
|
+
matches = @text.scan(tag_regex).flatten
|
51
|
+
if !matches.empty?
|
56
52
|
if regex.nil?
|
57
53
|
true
|
58
54
|
else
|
59
|
-
|
55
|
+
matches.any? do |matched|
|
56
|
+
matched =~ /#{regex}/
|
57
|
+
end
|
60
58
|
end
|
61
59
|
end
|
62
60
|
end
|
61
|
+
|
62
|
+
# Removes the comment markers // /* */ from the given +text+.
|
63
|
+
#
|
64
|
+
# Docstring.new("// test").without_comment_markers
|
65
|
+
# # => "test"
|
66
|
+
#
|
67
|
+
# @return [String]
|
68
|
+
def without_comment_markers(text)
|
69
|
+
text.to_s.lines.map do |line|
|
70
|
+
line.strip.gsub(/^(\s*(\/\*+|\/\/|\*+\/|\*)+\s?)/m, '')
|
71
|
+
end.join("\n").strip
|
72
|
+
end
|
63
73
|
end
|
64
74
|
end
|
65
75
|
end
|
@@ -22,7 +22,7 @@ module Inch
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def fullname
|
25
|
-
|
25
|
+
@hash['longname']
|
26
26
|
end
|
27
27
|
|
28
28
|
# Returns all files declaring the object in the form of an Array
|
@@ -47,11 +47,7 @@ module Inch
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def parent_fullname
|
50
|
-
|
51
|
-
nil
|
52
|
-
else
|
53
|
-
fullname.split('.')[0...-1].join('.')
|
54
|
-
end
|
50
|
+
@hash['memberof'] || retrieve_parent_fullname
|
55
51
|
end
|
56
52
|
|
57
53
|
def api_tag?
|
@@ -100,7 +96,7 @@ module Inch
|
|
100
96
|
end
|
101
97
|
|
102
98
|
def has_code_example?
|
103
|
-
|
99
|
+
docstring.code_examples.size > 0
|
104
100
|
end
|
105
101
|
|
106
102
|
def has_doc?
|
@@ -108,7 +104,7 @@ module Inch
|
|
108
104
|
end
|
109
105
|
|
110
106
|
def has_multiple_code_examples?
|
111
|
-
|
107
|
+
docstring.code_examples.size > 1
|
112
108
|
end
|
113
109
|
|
114
110
|
def has_unconsidered_tags?
|
@@ -151,7 +147,7 @@ module Inch
|
|
151
147
|
end
|
152
148
|
|
153
149
|
def private?
|
154
|
-
|
150
|
+
visibility == 'private'
|
155
151
|
end
|
156
152
|
|
157
153
|
def tagged_as_internal_api?
|
@@ -163,11 +159,11 @@ module Inch
|
|
163
159
|
end
|
164
160
|
|
165
161
|
def protected?
|
166
|
-
|
162
|
+
visibility == 'protected'
|
167
163
|
end
|
168
164
|
|
169
165
|
def public?
|
170
|
-
|
166
|
+
visibility == 'public'
|
171
167
|
end
|
172
168
|
|
173
169
|
def questioning_name?
|
@@ -175,15 +171,15 @@ module Inch
|
|
175
171
|
end
|
176
172
|
|
177
173
|
def return_described?
|
178
|
-
|
174
|
+
docstring.describes_return?
|
179
175
|
end
|
180
176
|
|
181
177
|
def return_mentioned?
|
182
|
-
|
178
|
+
docstring.mentions_return?
|
183
179
|
end
|
184
180
|
|
185
181
|
def return_typed?
|
186
|
-
|
182
|
+
return_mentioned?
|
187
183
|
end
|
188
184
|
|
189
185
|
def in_root?
|
@@ -207,7 +203,7 @@ module Inch
|
|
207
203
|
end
|
208
204
|
|
209
205
|
def visibility
|
210
|
-
docstring.visibility
|
206
|
+
docstring.visibility(@hash['access'])
|
211
207
|
end
|
212
208
|
|
213
209
|
protected
|
@@ -219,6 +215,14 @@ module Inch
|
|
219
215
|
def meta
|
220
216
|
@hash['meta']
|
221
217
|
end
|
218
|
+
|
219
|
+
def retrieve_parent_fullname
|
220
|
+
if depth == 1
|
221
|
+
nil
|
222
|
+
else
|
223
|
+
fullname.split('.')[0...-1].join('.')
|
224
|
+
end
|
225
|
+
end
|
222
226
|
end
|
223
227
|
end
|
224
228
|
end
|
@@ -9,7 +9,7 @@ module Inch
|
|
9
9
|
# Parses the source tree (using JSDoc)
|
10
10
|
class Parser
|
11
11
|
# TODO: should we remove constant and namespace from this list?
|
12
|
-
IGNORE_TYPES = %w(member package constant namespace)
|
12
|
+
IGNORE_TYPES = %w(interface member package param constant namespace)
|
13
13
|
|
14
14
|
attr_reader :parsed_objects
|
15
15
|
|
data/lib/inch/version.rb
CHANGED
@@ -0,0 +1,253 @@
|
|
1
|
+
{
|
2
|
+
"args": [],
|
3
|
+
"branch_name": "master",
|
4
|
+
"client_name": "inchjs",
|
5
|
+
"client_version": "0.1.4",
|
6
|
+
"git_repo_url": "git@github.com:inch-ci/Hello-World-NodeJS.git",
|
7
|
+
"language": "nodejs",
|
8
|
+
"objects": [
|
9
|
+
{
|
10
|
+
"comment": "",
|
11
|
+
"kind": "function",
|
12
|
+
"longname": "InstanciatableClass",
|
13
|
+
"meta": {
|
14
|
+
"code": {
|
15
|
+
"id": "astnode100000004",
|
16
|
+
"name": "InstanciatableClass",
|
17
|
+
"type": "FunctionExpression",
|
18
|
+
"value": "function"
|
19
|
+
},
|
20
|
+
"filename": "inch_test.js",
|
21
|
+
"lineno": 4,
|
22
|
+
"path": "/src",
|
23
|
+
"range": [
|
24
|
+
20,
|
25
|
+
55
|
26
|
+
]
|
27
|
+
},
|
28
|
+
"name": "InstanciatableClass",
|
29
|
+
"scope": "global",
|
30
|
+
"undocumented": true
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"comment": "",
|
34
|
+
"kind": "function",
|
35
|
+
"longname": "InstanciatableClass#render",
|
36
|
+
"memberof": "InstanciatableClass",
|
37
|
+
"meta": {
|
38
|
+
"code": {
|
39
|
+
"id": "astnode100000009",
|
40
|
+
"name": "InstanciatableClass.prototype.render",
|
41
|
+
"paramnames": [],
|
42
|
+
"type": "FunctionExpression",
|
43
|
+
"value": "function"
|
44
|
+
},
|
45
|
+
"filename": "inch_test.js",
|
46
|
+
"lineno": 5,
|
47
|
+
"path": "/src",
|
48
|
+
"range": [
|
49
|
+
57,
|
50
|
+
125
|
51
|
+
]
|
52
|
+
},
|
53
|
+
"name": "render",
|
54
|
+
"scope": "instance",
|
55
|
+
"undocumented": true
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"access": "private",
|
59
|
+
"comment": "/**\n* @private\n*/",
|
60
|
+
"kind": "function",
|
61
|
+
"longname": "InchTest.generate_docs",
|
62
|
+
"memberof": "InchTest",
|
63
|
+
"meta": {
|
64
|
+
"code": {
|
65
|
+
"id": "astnode100000024",
|
66
|
+
"name": "InchTest.generate_docs",
|
67
|
+
"paramnames": [
|
68
|
+
"project",
|
69
|
+
"version",
|
70
|
+
"args",
|
71
|
+
"options"
|
72
|
+
],
|
73
|
+
"type": "FunctionExpression",
|
74
|
+
"value": "function"
|
75
|
+
},
|
76
|
+
"filename": "inch_test.js",
|
77
|
+
"lineno": 13,
|
78
|
+
"path": "/src",
|
79
|
+
"range": [
|
80
|
+
165,
|
81
|
+
236
|
82
|
+
]
|
83
|
+
},
|
84
|
+
"name": "generate_docs",
|
85
|
+
"scope": "static"
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"comment": "// Generate JSON documentation for the given modules",
|
89
|
+
"kind": "function",
|
90
|
+
"longname": "InchTest.Docs.Formatter.run",
|
91
|
+
"memberof": "InchTest.Docs.Formatter",
|
92
|
+
"meta": {
|
93
|
+
"code": {
|
94
|
+
"id": "astnode100000042",
|
95
|
+
"name": "run",
|
96
|
+
"type": "FunctionExpression",
|
97
|
+
"value": "function"
|
98
|
+
},
|
99
|
+
"filename": "inch_test.js",
|
100
|
+
"lineno": 19,
|
101
|
+
"path": "/src",
|
102
|
+
"range": [
|
103
|
+
333,
|
104
|
+
398
|
105
|
+
]
|
106
|
+
},
|
107
|
+
"name": "run",
|
108
|
+
"scope": "static",
|
109
|
+
"undocumented": true
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"comment": "/**\n*\n* This function takes `param1` and `param2` as arguments.\n*\n* @param {Number} param1 A number from 0 to 26 that will result in a letter a-z\n* @param {String} param2 A text\n* @return {String} A character from a-z based on the input number n\n*\n* Examples:\n*\n* > InchTest.Naming.resource_name(MyApp.User)\n* \"user\"\n* > InchTest.Naming.resource_name(MyApp.UserView, \"View\")\n* \"user\"\n*/",
|
113
|
+
"description": "This function takes `param1` and `param2` as arguments.",
|
114
|
+
"kind": "function",
|
115
|
+
"longname": "InchTest.Functions.full_doc",
|
116
|
+
"memberof": "InchTest.Functions",
|
117
|
+
"meta": {
|
118
|
+
"code": {
|
119
|
+
"id": "astnode100000057",
|
120
|
+
"name": "InchTest.Functions.full_doc",
|
121
|
+
"paramnames": [
|
122
|
+
"param1",
|
123
|
+
"param2"
|
124
|
+
],
|
125
|
+
"type": "FunctionExpression",
|
126
|
+
"value": "function"
|
127
|
+
},
|
128
|
+
"filename": "inch_test.js",
|
129
|
+
"lineno": 41,
|
130
|
+
"path": "/src",
|
131
|
+
"range": [
|
132
|
+
841,
|
133
|
+
914
|
134
|
+
]
|
135
|
+
},
|
136
|
+
"name": "full_doc",
|
137
|
+
"params": [
|
138
|
+
{
|
139
|
+
"description": "A number from 0 to 26 that will result in a letter a-z",
|
140
|
+
"name": "param1",
|
141
|
+
"type": {
|
142
|
+
"names": [
|
143
|
+
"Number"
|
144
|
+
]
|
145
|
+
}
|
146
|
+
},
|
147
|
+
{
|
148
|
+
"description": "A text",
|
149
|
+
"name": "param2",
|
150
|
+
"type": {
|
151
|
+
"names": [
|
152
|
+
"String"
|
153
|
+
]
|
154
|
+
}
|
155
|
+
}
|
156
|
+
],
|
157
|
+
"returns": [
|
158
|
+
{
|
159
|
+
"description": "A character from a-z based on the input number n\n\nExamples:\n\n > InchTest.Naming.resource_name(MyApp.User)\n \"user\"\n > InchTest.Naming.resource_name(MyApp.UserView, \"View\")\n \"user\"",
|
160
|
+
"type": {
|
161
|
+
"names": [
|
162
|
+
"String"
|
163
|
+
]
|
164
|
+
}
|
165
|
+
}
|
166
|
+
],
|
167
|
+
"scope": "static"
|
168
|
+
},
|
169
|
+
{
|
170
|
+
"comment": "/**\n*\n* This function takes a `param1` and a second parameter that is never used\n* (maybe, because it is a callback or something like that). However, the\n* second param should impact the evaluation by Inch.\n*\n* Examples:\n*\n* > InchTest.Naming.resource_name(MyApp.User)\n* \"user\"\n* > InchTest.Naming.resource_name(MyApp.UserView, \"View\")\n* \"user\"\n*/",
|
171
|
+
"description": "This function takes a `param1` and a second parameter that is never used\n(maybe, because it is a callback or something like that). However, the\nsecond param should impact the evaluation by Inch.\n\nExamples:\n\n > InchTest.Naming.resource_name(MyApp.User)\n \"user\"\n > InchTest.Naming.resource_name(MyApp.UserView, \"View\")\n \"user\"",
|
172
|
+
"kind": "function",
|
173
|
+
"longname": "InchTest.Functions.full_doc_second_parameter_unnamed",
|
174
|
+
"memberof": "InchTest.Functions",
|
175
|
+
"meta": {
|
176
|
+
"code": {
|
177
|
+
"id": "astnode100000070",
|
178
|
+
"name": "InchTest.Functions.full_doc_second_parameter_unnamed",
|
179
|
+
"paramnames": [
|
180
|
+
"param1",
|
181
|
+
"_"
|
182
|
+
],
|
183
|
+
"type": "FunctionExpression",
|
184
|
+
"value": "function"
|
185
|
+
},
|
186
|
+
"filename": "inch_test.js",
|
187
|
+
"lineno": 57,
|
188
|
+
"path": "/src",
|
189
|
+
"range": [
|
190
|
+
1271,
|
191
|
+
1364
|
192
|
+
]
|
193
|
+
},
|
194
|
+
"name": "full_doc_second_parameter_unnamed",
|
195
|
+
"scope": "static"
|
196
|
+
},
|
197
|
+
{
|
198
|
+
"comment": "/**\n*\n* This function takes no arguments.\n*\n* Examples:\n*\n* > InchTest.Naming.resource_name(MyApp.User)\n* \"user\"\n* > InchTest.Naming.resource_name(MyApp.UserView, \"View\")\n* \"user\"\n*/",
|
199
|
+
"description": "This function takes no arguments.\n\nExamples:\n\n > InchTest.Naming.resource_name(MyApp.User)\n \"user\"\n > InchTest.Naming.resource_name(MyApp.UserView, \"View\")\n \"user\"",
|
200
|
+
"kind": "function",
|
201
|
+
"longname": "InchTest.CodeExamples.single_code_example",
|
202
|
+
"memberof": "InchTest.CodeExamples",
|
203
|
+
"meta": {
|
204
|
+
"code": {
|
205
|
+
"id": "astnode100000088",
|
206
|
+
"name": "single_code_example",
|
207
|
+
"type": "FunctionExpression",
|
208
|
+
"value": "function"
|
209
|
+
},
|
210
|
+
"filename": "inch_test.js",
|
211
|
+
"lineno": 74,
|
212
|
+
"path": "/src",
|
213
|
+
"range": [
|
214
|
+
1609,
|
215
|
+
1665
|
216
|
+
]
|
217
|
+
},
|
218
|
+
"name": "single_code_example",
|
219
|
+
"scope": "static"
|
220
|
+
},
|
221
|
+
{
|
222
|
+
"comment": "/**\n*\n* This function takes no arguments.\n*\n* Examples:\n*\n* > InchTest.Naming.resource_name(MyApp.User)\n* \"user\"\n* > InchTest.Naming.resource_name(MyApp.UserView, \"View\")\n* \"user\"\n*\n* In general, `underscore` can be thought of as the reverse ...\n*\n* > InchTest.Naming.resource_name(MyApp.User)\n* \"user\"\n* > InchTest.Naming.resource_name(MyApp.UserView, \"View\")\n* \"user\"\n*/",
|
223
|
+
"description": "This function takes no arguments.\n\nExamples:\n\n > InchTest.Naming.resource_name(MyApp.User)\n \"user\"\n > InchTest.Naming.resource_name(MyApp.UserView, \"View\")\n \"user\"\n\nIn general, `underscore` can be thought of as the reverse ...\n\n > InchTest.Naming.resource_name(MyApp.User)\n \"user\"\n > InchTest.Naming.resource_name(MyApp.UserView, \"View\")\n \"user\"",
|
224
|
+
"kind": "function",
|
225
|
+
"longname": "InchTest.CodeExamples.multiple_code_examples",
|
226
|
+
"memberof": "InchTest.CodeExamples",
|
227
|
+
"meta": {
|
228
|
+
"code": {
|
229
|
+
"id": "astnode100000093",
|
230
|
+
"name": "multiple_code_examples",
|
231
|
+
"type": "FunctionExpression",
|
232
|
+
"value": "function"
|
233
|
+
},
|
234
|
+
"filename": "inch_test.js",
|
235
|
+
"lineno": 95,
|
236
|
+
"path": "/src",
|
237
|
+
"range": [
|
238
|
+
2094,
|
239
|
+
2153
|
240
|
+
]
|
241
|
+
},
|
242
|
+
"name": "multiple_code_examples",
|
243
|
+
"scope": "static"
|
244
|
+
},
|
245
|
+
{
|
246
|
+
"files": [
|
247
|
+
"/home/rf/devel/Hello-World-NodeJS/src/inch_test.js"
|
248
|
+
],
|
249
|
+
"kind": "package",
|
250
|
+
"longname": "package:undefined"
|
251
|
+
}
|
252
|
+
]
|
253
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../../test_helper')
|
2
|
+
|
3
|
+
describe ::Inch::Language::Elixir::CodeObject::FunctionObject do
|
4
|
+
before do
|
5
|
+
@codebase = fresh_codebase(:nodejs, :inch_test, 'all.json')
|
6
|
+
@objects = @codebase.objects
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'Scores' do
|
10
|
+
#
|
11
|
+
it 'should not' do
|
12
|
+
m = @objects.find('InchTest.generate_docs')
|
13
|
+
assert m.score >= 50
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should recognize the relationship between modules and functions' do
|
18
|
+
skip "InchTest is a member and therefore not counted at the moment"
|
19
|
+
mod = @objects.find('InchTest')
|
20
|
+
assert mod.has_children?
|
21
|
+
assert mod.children.size > 1
|
22
|
+
fun = @objects.find('InchTest.generate_docs')
|
23
|
+
assert_equal mod, fun.parent
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should recognize the depth of methods' do
|
27
|
+
m = @objects.find('InchTest')
|
28
|
+
m = @objects.find('InchTest.Docs.Formatter.run')
|
29
|
+
assert_equal 4, m.depth
|
30
|
+
skip "InchTest is a member and therefore not counted at the moment"
|
31
|
+
|
32
|
+
assert_equal 1, m.depth
|
33
|
+
m = @objects.find('InchTest.Config')
|
34
|
+
assert_equal 2, m.depth
|
35
|
+
m = @objects.find('InchTest.Docs.Formatter')
|
36
|
+
assert_equal 3, m.depth
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should parse parameters correctly' do
|
40
|
+
m = @objects.find('InchTest.generate_docs')
|
41
|
+
assert_equal 4, m.parameters.size
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should parse parameters correctly' do
|
45
|
+
m = @objects.find('InchTest.Functions.full_doc')
|
46
|
+
assert_equal 2, m.parameters.size
|
47
|
+
assert_equal 'A', m.grade.to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should recognize code examples' do
|
51
|
+
m = @objects.find('InchTest.CodeExamples.single_code_example')
|
52
|
+
assert m.has_code_example?
|
53
|
+
refute m.has_multiple_code_examples?
|
54
|
+
|
55
|
+
m = @objects.find('InchTest.CodeExamples.multiple_code_examples')
|
56
|
+
assert m.has_code_example?
|
57
|
+
assert m.has_multiple_code_examples?
|
58
|
+
end
|
59
|
+
end
|
@@ -42,6 +42,27 @@ describe ::Inch::Language::Nodejs::Provider::JSDoc::Docstring do
|
|
42
42
|
refute docstring.describes_return?
|
43
43
|
end
|
44
44
|
|
45
|
+
it 'should notice things in jsdoc style docs 3' do
|
46
|
+
text = <<-DOC
|
47
|
+
/**
|
48
|
+
*
|
49
|
+
* This function takes `param1` and `param2` as arguments.
|
50
|
+
*
|
51
|
+
* @param {Number} param1 A number from 0 to 26 that will result in a letter a-z
|
52
|
+
* @param {String} param2 A text
|
53
|
+
* @return {String} A character from a-z based on the input number n
|
54
|
+
*
|
55
|
+
*/
|
56
|
+
DOC
|
57
|
+
docstring = described_class.new(text)
|
58
|
+
assert docstring.mentions_parameter?(:param1)
|
59
|
+
assert docstring.describes_parameter?(:param1)
|
60
|
+
assert docstring.mentions_parameter?(:param2)
|
61
|
+
assert docstring.describes_parameter?(:param2)
|
62
|
+
assert docstring.mentions_return?
|
63
|
+
assert docstring.describes_return?
|
64
|
+
end
|
65
|
+
|
45
66
|
it 'should notice things in jsdoc style docs' do
|
46
67
|
%w(public protected private).each do |visibility|
|
47
68
|
text = <<-DOC
|
@@ -77,7 +98,7 @@ Set or get the context `Runnable` to `runnable`.
|
|
77
98
|
@api private
|
78
99
|
DOC
|
79
100
|
docstring = described_class.new(text)
|
80
|
-
assert_equal without_comment_markers.strip, docstring.
|
101
|
+
assert_equal without_comment_markers.strip, docstring.to_s
|
81
102
|
end
|
82
103
|
|
83
104
|
it 'should remove comment markers for parsing 2' do
|
@@ -91,19 +112,20 @@ Set or get the context `Runnable` to `runnable`.
|
|
91
112
|
Set or get the context `Runnable` to `runnable`.
|
92
113
|
DOC
|
93
114
|
docstring = described_class.new(text)
|
94
|
-
assert_equal without_comment_markers.strip, docstring.
|
115
|
+
assert_equal without_comment_markers.strip, docstring.to_s
|
95
116
|
end
|
96
117
|
|
97
118
|
|
98
119
|
it 'should remove comment markers for parsing 3' do
|
99
120
|
text = <<-DOC
|
100
|
-
//Set or get the context `Runnable` to `runnable`.
|
121
|
+
// Set or get the context `Runnable` to `runnable`.
|
122
|
+
// Set or get the context `Runnable` to `runnable`.
|
101
123
|
DOC
|
102
124
|
without_comment_markers = <<-DOC
|
125
|
+
Set or get the context `Runnable` to `runnable`.
|
103
126
|
Set or get the context `Runnable` to `runnable`.
|
104
127
|
DOC
|
105
128
|
docstring = described_class.new(text)
|
106
|
-
assert_equal without_comment_markers.strip, docstring.
|
129
|
+
assert_equal without_comment_markers.strip, docstring.to_s
|
107
130
|
end
|
108
|
-
|
109
131
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- René Föhring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -311,6 +311,7 @@ files:
|
|
311
311
|
- lib/inch/utils/weighted_list.rb
|
312
312
|
- lib/inch/version.rb
|
313
313
|
- test/fixtures/elixir/inch_test/all.json
|
314
|
+
- test/fixtures/nodejs/inch_test/all.json
|
314
315
|
- test/fixtures/ruby/alias_cycle/lib/alias.rb
|
315
316
|
- test/fixtures/ruby/code_examples/lib/foo.rb
|
316
317
|
- test/fixtures/ruby/diff1/lib/diff1.rb
|
@@ -369,6 +370,7 @@ files:
|
|
369
370
|
- test/unit/evaluation/role_test.rb
|
370
371
|
- test/unit/language/elixir/code_object/function_object_test.rb
|
371
372
|
- test/unit/language/elixir/code_object/module_object_test.rb
|
373
|
+
- test/unit/language/nodejs/code_object/function_object_test.rb
|
372
374
|
- test/unit/language/nodejs/provider/jsdoc/docstring_test.rb
|
373
375
|
- test/unit/language/ruby/code_object/alias_test.rb
|
374
376
|
- test/unit/language/ruby/code_object/method_object_test.rb
|
@@ -405,6 +407,7 @@ specification_version: 4
|
|
405
407
|
summary: Documentation measurement tool for Ruby
|
406
408
|
test_files:
|
407
409
|
- test/fixtures/elixir/inch_test/all.json
|
410
|
+
- test/fixtures/nodejs/inch_test/all.json
|
408
411
|
- test/fixtures/ruby/alias_cycle/lib/alias.rb
|
409
412
|
- test/fixtures/ruby/code_examples/lib/foo.rb
|
410
413
|
- test/fixtures/ruby/diff1/lib/diff1.rb
|
@@ -463,6 +466,7 @@ test_files:
|
|
463
466
|
- test/unit/evaluation/role_test.rb
|
464
467
|
- test/unit/language/elixir/code_object/function_object_test.rb
|
465
468
|
- test/unit/language/elixir/code_object/module_object_test.rb
|
469
|
+
- test/unit/language/nodejs/code_object/function_object_test.rb
|
466
470
|
- test/unit/language/nodejs/provider/jsdoc/docstring_test.rb
|
467
471
|
- test/unit/language/ruby/code_object/alias_test.rb
|
468
472
|
- test/unit/language/ruby/code_object/method_object_test.rb
|