inch 0.5.0.rc3 → 0.5.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +15 -0
  3. data/.rubocop_todo.yml +94 -0
  4. data/CHANGELOG.md +26 -2
  5. data/Gemfile +5 -2
  6. data/README.md +3 -3
  7. data/Rakefile +6 -2
  8. data/bin/inch +3 -3
  9. data/config/{example.yml → .inch.yml.sample} +1 -0
  10. data/config/base.rb +53 -0
  11. data/config/elixir.rb +43 -0
  12. data/config/nodejs.rb +10 -0
  13. data/config/{defaults.rb → ruby.rb} +5 -54
  14. data/inch.gemspec +7 -7
  15. data/lib/inch.rb +14 -9
  16. data/lib/inch/api.rb +10 -10
  17. data/lib/inch/api/compare.rb +2 -2
  18. data/lib/inch/api/compare/code_objects.rb +2 -3
  19. data/lib/inch/api/compare/codebases.rb +1 -1
  20. data/lib/inch/api/diff.rb +13 -16
  21. data/lib/inch/api/filter.rb +1 -1
  22. data/lib/inch/api/get.rb +2 -2
  23. data/lib/inch/api/options/base.rb +4 -4
  24. data/lib/inch/api/options/filter.rb +0 -4
  25. data/lib/inch/api/options/suggest.rb +2 -6
  26. data/lib/inch/api/stats.rb +0 -1
  27. data/lib/inch/api/suggest.rb +9 -10
  28. data/lib/inch/cli.rb +6 -6
  29. data/lib/inch/cli/arguments.rb +2 -2
  30. data/lib/inch/cli/command.rb +15 -15
  31. data/lib/inch/cli/command/base.rb +30 -9
  32. data/lib/inch/cli/command/base_list.rb +2 -2
  33. data/lib/inch/cli/command/console.rb +5 -5
  34. data/lib/inch/cli/command/diff.rb +9 -9
  35. data/lib/inch/cli/command/inspect.rb +5 -4
  36. data/lib/inch/cli/command/list.rb +4 -4
  37. data/lib/inch/cli/command/options/base.rb +17 -16
  38. data/lib/inch/cli/command/options/base_list.rb +9 -5
  39. data/lib/inch/cli/command/options/console.rb +4 -3
  40. data/lib/inch/cli/command/options/diff.rb +8 -6
  41. data/lib/inch/cli/command/options/inspect.rb +2 -2
  42. data/lib/inch/cli/command/options/list.rb +3 -2
  43. data/lib/inch/cli/command/options/show.rb +2 -2
  44. data/lib/inch/cli/command/options/stats.rb +2 -1
  45. data/lib/inch/cli/command/options/suggest.rb +6 -3
  46. data/lib/inch/cli/command/output/base.rb +4 -6
  47. data/lib/inch/cli/command/output/console.rb +6 -7
  48. data/lib/inch/cli/command/output/diff.rb +6 -6
  49. data/lib/inch/cli/command/output/inspect.rb +6 -8
  50. data/lib/inch/cli/command/output/list.rb +0 -1
  51. data/lib/inch/cli/command/output/show.rb +4 -5
  52. data/lib/inch/cli/command/output/stats.rb +21 -21
  53. data/lib/inch/cli/command/output/suggest.rb +31 -28
  54. data/lib/inch/cli/command/show.rb +4 -4
  55. data/lib/inch/cli/command/stats.rb +4 -4
  56. data/lib/inch/cli/command/suggest.rb +6 -6
  57. data/lib/inch/cli/command_parser.rb +6 -5
  58. data/lib/inch/cli/sparkline_helper.rb +6 -6
  59. data/lib/inch/cli/trace_helper.rb +1 -1
  60. data/lib/inch/cli/yardopts_helper.rb +4 -3
  61. data/lib/inch/code_object.rb +3 -3
  62. data/lib/inch/code_object/converter.rb +6 -8
  63. data/lib/inch/code_object/provider.rb +11 -11
  64. data/lib/inch/code_object/proxy.rb +61 -30
  65. data/lib/inch/codebase.rb +7 -8
  66. data/lib/inch/codebase/object.rb +60 -0
  67. data/lib/inch/codebase/objects.rb +8 -10
  68. data/lib/inch/codebase/objects_filter.rb +7 -5
  69. data/lib/inch/codebase/proxy.rb +4 -4
  70. data/lib/inch/codebase/serializer.rb +3 -3
  71. data/lib/inch/config.rb +42 -11
  72. data/lib/inch/config/base.rb +8 -29
  73. data/lib/inch/config/codebase.rb +32 -7
  74. data/lib/inch/config/evaluation.rb +61 -0
  75. data/lib/inch/core_ext.rb +1 -1
  76. data/lib/inch/core_ext/string.rb +1 -1
  77. data/lib/inch/evaluation.rb +13 -21
  78. data/lib/inch/evaluation/file.rb +4 -2
  79. data/lib/inch/evaluation/grade_list.rb +4 -4
  80. data/lib/inch/evaluation/priority_range.rb +3 -0
  81. data/lib/inch/evaluation/proxy.rb +139 -14
  82. data/lib/inch/evaluation/role.rb +99 -0
  83. data/lib/inch/language.rb +3 -0
  84. data/lib/inch/language/elixir/code_object/base.rb +197 -0
  85. data/lib/inch/language/elixir/code_object/function_object.rb +74 -0
  86. data/lib/inch/language/elixir/code_object/module_object.rb +23 -0
  87. data/lib/inch/language/elixir/code_object/type_object.rb +11 -0
  88. data/lib/inch/language/elixir/evaluation/base.rb +28 -0
  89. data/lib/inch/language/elixir/evaluation/function_object.rb +31 -0
  90. data/lib/inch/language/elixir/evaluation/module_object.rb +27 -0
  91. data/lib/inch/language/elixir/evaluation/type_object.rb +11 -0
  92. data/lib/inch/language/elixir/import.rb +24 -0
  93. data/lib/inch/language/elixir/provider/reader.rb +19 -0
  94. data/lib/inch/language/elixir/provider/reader/object.rb +63 -0
  95. data/lib/inch/language/elixir/provider/reader/object/base.rb +191 -0
  96. data/lib/inch/language/elixir/provider/reader/object/function_object.rb +26 -0
  97. data/lib/inch/language/elixir/provider/reader/object/module_object.rb +22 -0
  98. data/lib/inch/language/elixir/provider/reader/object/type_object.rb +15 -0
  99. data/lib/inch/language/elixir/provider/reader/parser.rb +55 -0
  100. data/lib/inch/language/elixir/roles/base.rb +32 -0
  101. data/lib/inch/language/elixir/roles/function.rb +112 -0
  102. data/lib/inch/language/elixir/roles/module.rb +64 -0
  103. data/lib/inch/language/elixir/roles/object.rb +76 -0
  104. data/lib/inch/language/elixir/roles/type.rb +13 -0
  105. data/lib/inch/language/nodejs/import.rb +8 -0
  106. data/lib/inch/language/nodejs/provider/jsdoc.rb +19 -0
  107. data/lib/inch/language/nodejs/provider/jsdoc/object.rb +55 -0
  108. data/lib/inch/language/nodejs/provider/jsdoc/object/base.rb +191 -0
  109. data/lib/inch/language/nodejs/provider/jsdoc/parser.rb +59 -0
  110. data/lib/inch/language/ruby/code_object/base.rb +197 -0
  111. data/lib/inch/language/ruby/code_object/class_object.rb +10 -0
  112. data/lib/inch/language/ruby/code_object/class_variable_object.rb +10 -0
  113. data/lib/inch/language/ruby/code_object/constant_object.rb +10 -0
  114. data/lib/inch/language/ruby/code_object/method_object.rb +85 -0
  115. data/lib/inch/language/ruby/code_object/method_parameter_object.rb +64 -0
  116. data/lib/inch/language/ruby/code_object/module_object.rb +10 -0
  117. data/lib/inch/language/ruby/code_object/namespace_object.rb +35 -0
  118. data/lib/inch/language/ruby/evaluation/base.rb +45 -0
  119. data/lib/inch/language/ruby/evaluation/class_object.rb +10 -0
  120. data/lib/inch/language/ruby/evaluation/class_variable_object.rb +21 -0
  121. data/lib/inch/language/ruby/evaluation/constant_object.rb +21 -0
  122. data/lib/inch/language/ruby/evaluation/method_object.rb +74 -0
  123. data/lib/inch/language/ruby/evaluation/module_object.rb +10 -0
  124. data/lib/inch/language/ruby/evaluation/namespace_object.rb +30 -0
  125. data/lib/inch/language/ruby/import.rb +34 -0
  126. data/lib/inch/language/ruby/provider/yard.rb +58 -0
  127. data/lib/inch/language/ruby/provider/yard/docstring.rb +162 -0
  128. data/lib/inch/language/ruby/provider/yard/nodoc_helper.rb +97 -0
  129. data/lib/inch/language/ruby/provider/yard/object.rb +63 -0
  130. data/lib/inch/language/ruby/provider/yard/object/base.rb +325 -0
  131. data/lib/inch/language/ruby/provider/yard/object/class_object.rb +14 -0
  132. data/lib/inch/language/ruby/provider/yard/object/class_variable_object.rb +14 -0
  133. data/lib/inch/language/ruby/provider/yard/object/constant_object.rb +14 -0
  134. data/lib/inch/language/ruby/provider/yard/object/method_object.rb +170 -0
  135. data/lib/inch/language/ruby/provider/yard/object/method_parameter_object.rb +94 -0
  136. data/lib/inch/language/ruby/provider/yard/object/method_signature.rb +120 -0
  137. data/lib/inch/language/ruby/provider/yard/object/module_object.rb +14 -0
  138. data/lib/inch/language/ruby/provider/yard/object/namespace_object.rb +46 -0
  139. data/lib/inch/language/ruby/provider/yard/object/root_object.rb +14 -0
  140. data/lib/inch/language/ruby/provider/yard/parser.rb +71 -0
  141. data/lib/inch/language/ruby/roles/base.rb +17 -0
  142. data/lib/inch/language/ruby/roles/class_variable.rb +53 -0
  143. data/lib/inch/language/ruby/roles/constant.rb +53 -0
  144. data/lib/inch/language/ruby/roles/method.rb +112 -0
  145. data/lib/inch/language/ruby/roles/method_parameter.rb +84 -0
  146. data/lib/inch/language/ruby/roles/missing.rb +24 -0
  147. data/lib/inch/language/ruby/roles/namespace.rb +89 -0
  148. data/lib/inch/language/ruby/roles/object.rb +120 -0
  149. data/lib/inch/rake.rb +2 -2
  150. data/lib/inch/rake/suggest.rb +7 -2
  151. data/lib/inch/utils/buffered_ui.rb +16 -0
  152. data/lib/inch/utils/shell_helper.rb +1 -1
  153. data/lib/inch/utils/ui.rb +5 -5
  154. data/lib/inch/utils/weighted_list.rb +2 -3
  155. data/lib/inch/version.rb +1 -1
  156. data/test/fixtures/{code_examples → ruby/code_examples}/lib/foo.rb +0 -0
  157. data/test/fixtures/{diff1 → ruby/diff1}/lib/diff1.rb +0 -0
  158. data/test/fixtures/{diff2 → ruby/diff2}/lib/diff2.rb +0 -0
  159. data/test/fixtures/{inch-yml → ruby/inch-yml}/.inch.yml +0 -0
  160. data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/bar.rb +0 -0
  161. data/test/fixtures/{inch-yml → ruby/inch-yml}/foo/vendor/base.rb +0 -0
  162. data/test/fixtures/{parameters → ruby/parameters}/lib/foo.rb +0 -0
  163. data/test/fixtures/{readme → ruby/readme}/lib/foo.rb +0 -0
  164. data/test/fixtures/{really_good → ruby/really_good}/lib/foo.rb +0 -0
  165. data/test/fixtures/{really_good_pedantic → ruby/really_good_pedantic}/lib/foo.rb +0 -0
  166. data/test/fixtures/{simple → ruby/simple}/README +0 -0
  167. data/test/fixtures/{simple → ruby/simple}/lib/broken.rb +11 -19
  168. data/test/fixtures/ruby/simple/lib/broken_ruby_2_0_features.rb +7 -0
  169. data/test/fixtures/ruby/simple/lib/directives.rb +8 -0
  170. data/test/fixtures/{simple → ruby/simple}/lib/foo.rb +22 -1
  171. data/test/fixtures/{simple → ruby/simple}/lib/nodoc.rb +0 -0
  172. data/test/fixtures/{simple → ruby/simple}/lib/role_methods.rb +0 -0
  173. data/test/fixtures/{simple → ruby/simple}/lib/role_namespaces.rb +0 -0
  174. data/test/fixtures/{visibility → ruby/visibility}/lib/foo.rb +0 -0
  175. data/test/fixtures/{yardopts → ruby/yardopts}/.yardopts +0 -0
  176. data/test/fixtures/{yardopts → ruby/yardopts}/foo/bar.rb +0 -0
  177. data/test/integration/api/compare/codebases.rb +3 -3
  178. data/test/integration/cli/command/console_test.rb +6 -6
  179. data/test/integration/cli/command/diff_test.rb +62 -0
  180. data/test/integration/cli/command/inspect_test.rb +5 -6
  181. data/test/integration/cli/command/list_test.rb +4 -5
  182. data/test/integration/cli/command/show_test.rb +5 -5
  183. data/test/integration/cli/command/stats_test.rb +3 -3
  184. data/test/integration/cli/command/suggest_test.rb +13 -13
  185. data/test/integration/stats_options_test.rb +4 -4
  186. data/test/integration/visibility_options_test.rb +14 -14
  187. data/test/shared/base_list.rb +4 -3
  188. data/test/test_helper.rb +13 -13
  189. data/test/unit/api/filter_test.rb +7 -7
  190. data/test/unit/api/get_test.rb +1 -1
  191. data/test/unit/api/list_test.rb +1 -1
  192. data/test/unit/api/options/base_test.rb +3 -3
  193. data/test/unit/api/stats_test.rb +1 -1
  194. data/test/unit/api/suggest_test.rb +3 -3
  195. data/test/unit/cli/arguments_test.rb +2 -2
  196. data/test/unit/cli/command/base_test.rb +1 -1
  197. data/test/unit/cli/command/options/base_list_test.rb +2 -2
  198. data/test/unit/cli/command/options/base_object_test.rb +1 -1
  199. data/test/unit/cli/command/options/base_test.rb +1 -1
  200. data/test/unit/cli/command_parser_test.rb +3 -3
  201. data/test/unit/cli/trace_helper_test.rb +1 -1
  202. data/test/unit/cli/yardopts_helper_test.rb +6 -5
  203. data/test/unit/code_object/converter_test.rb +1 -1
  204. data/test/unit/code_object/provider_test.rb +2 -2
  205. data/test/unit/code_object/proxy_test.rb +2 -2
  206. data/test/unit/codebase/objects_test.rb +2 -2
  207. data/test/unit/codebase/proxy_test.rb +7 -5
  208. data/test/unit/config/codebase_test.rb +4 -4
  209. data/test/unit/config_test.rb +28 -0
  210. data/test/unit/evaluation/{role/base_test.rb → role_test.rb} +7 -7
  211. data/test/unit/{code_object/proxy → language/ruby/code_object}/method_object_test.rb +66 -21
  212. data/test/unit/{code_object → language/ruby}/provider/yard/docstring_test.rb +74 -38
  213. data/test/unit/{code_object → language/ruby}/provider/yard/nodoc_helper_test.rb +9 -7
  214. data/test/unit/{code_object → language/ruby}/provider/yard/object/method_object_test.rb +21 -11
  215. data/test/unit/language/ruby/provider/yard_test.rb +25 -0
  216. data/test/unit/utils/buffered_ui_test.rb +48 -0
  217. data/test/unit/utils/ui_test.rb +7 -7
  218. data/test/unit/utils/weighted_list_test.rb +7 -4
  219. metadata +139 -93
  220. data/lib/inch/code_object/provider/yard.rb +0 -57
  221. data/lib/inch/code_object/provider/yard/docstring.rb +0 -133
  222. data/lib/inch/code_object/provider/yard/nodoc_helper.rb +0 -93
  223. data/lib/inch/code_object/provider/yard/object.rb +0 -60
  224. data/lib/inch/code_object/provider/yard/object/base.rb +0 -302
  225. data/lib/inch/code_object/provider/yard/object/class_object.rb +0 -12
  226. data/lib/inch/code_object/provider/yard/object/class_variable_object.rb +0 -12
  227. data/lib/inch/code_object/provider/yard/object/constant_object.rb +0 -12
  228. data/lib/inch/code_object/provider/yard/object/method_object.rb +0 -153
  229. data/lib/inch/code_object/provider/yard/object/method_parameter_object.rb +0 -88
  230. data/lib/inch/code_object/provider/yard/object/method_signature.rb +0 -114
  231. data/lib/inch/code_object/provider/yard/object/module_object.rb +0 -12
  232. data/lib/inch/code_object/provider/yard/object/namespace_object.rb +0 -47
  233. data/lib/inch/code_object/provider/yard/object/root_object.rb +0 -12
  234. data/lib/inch/code_object/provider/yard/parser.rb +0 -62
  235. data/lib/inch/code_object/proxy/base.rb +0 -241
  236. data/lib/inch/code_object/proxy/class_object.rb +0 -8
  237. data/lib/inch/code_object/proxy/class_variable_object.rb +0 -8
  238. data/lib/inch/code_object/proxy/constant_object.rb +0 -8
  239. data/lib/inch/code_object/proxy/method_object.rb +0 -82
  240. data/lib/inch/code_object/proxy/method_parameter_object.rb +0 -60
  241. data/lib/inch/code_object/proxy/module_object.rb +0 -8
  242. data/lib/inch/code_object/proxy/namespace_object.rb +0 -33
  243. data/lib/inch/evaluation/object_schema.rb +0 -30
  244. data/lib/inch/evaluation/proxy/base.rb +0 -164
  245. data/lib/inch/evaluation/proxy/class_object.rb +0 -8
  246. data/lib/inch/evaluation/proxy/class_variable_object.rb +0 -19
  247. data/lib/inch/evaluation/proxy/constant_object.rb +0 -19
  248. data/lib/inch/evaluation/proxy/method_object.rb +0 -65
  249. data/lib/inch/evaluation/proxy/module_object.rb +0 -8
  250. data/lib/inch/evaluation/proxy/namespace_object.rb +0 -27
  251. data/lib/inch/evaluation/role/base.rb +0 -92
  252. data/lib/inch/evaluation/role/class_variable.rb +0 -55
  253. data/lib/inch/evaluation/role/constant.rb +0 -55
  254. data/lib/inch/evaluation/role/method.rb +0 -126
  255. data/lib/inch/evaluation/role/method_parameter.rb +0 -91
  256. data/lib/inch/evaluation/role/missing.rb +0 -20
  257. data/lib/inch/evaluation/role/namespace.rb +0 -85
  258. data/lib/inch/evaluation/role/object.rb +0 -143
  259. data/test/unit/code_object/provider/yard_test.rb +0 -25
@@ -0,0 +1,32 @@
1
+ module Inch
2
+ module Language
3
+ module Elixir
4
+ module Evaluation
5
+ module Role
6
+ # @abstract
7
+ class Base < Inch::Evaluation::Role
8
+ # Returns the type of the +object+ that is being evaluated.
9
+ def object_type
10
+ object.class.to_s.split("::").last.gsub(/Object$/, "").downcase
11
+ end
12
+ end
13
+
14
+ # Missing is the base class for things that can be improved in the doc
15
+ #
16
+ class Missing < Base
17
+ def score
18
+ nil
19
+ end
20
+
21
+ # @return [Fixnum]
22
+ # a score that can be achieved by adding the missing thing mentioned
23
+ # by the role
24
+ def potential_score
25
+ @value.to_i
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,112 @@
1
+ module Inch
2
+ module Language
3
+ module Elixir
4
+ module Evaluation
5
+ module Role
6
+ module Function
7
+ # Role assigned to methods without parameters
8
+ class WithoutParameters < Base
9
+ applicable_unless :has_parameters?
10
+ end
11
+
12
+ # Role assigned to methods with many parameters
13
+ #
14
+ # @see CodeObject::Ruby::MethodObject#has_many_parameters?
15
+ class WithManyParameters < Base
16
+ applicable_if :has_many_parameters?
17
+ priority +2
18
+ end
19
+
20
+ # Role assigned to methods where the return value is typed in the docs
21
+ class WithReturnType < Base
22
+ applicable_if :return_typed?
23
+ end
24
+
25
+ # Role assigned to methods where the return value is not typed
26
+ class WithoutReturnType < Missing
27
+ applicable_unless :return_typed?
28
+
29
+ def suggestion
30
+ "Describe what '#{object.name}' returns"
31
+ end
32
+ end
33
+
34
+ # Role assigned to methods where the return value is decribed in the
35
+ # docs
36
+ class WithReturnDescription < Base
37
+ applicable_if :return_described?
38
+ end
39
+
40
+ # Role assigned to methods where the return value is not decribed
41
+ class WithoutReturnDescription < Missing
42
+ applicable_unless :return_described?
43
+
44
+ def suggestion
45
+ "Describe what '#{object.name}' returns"
46
+ end
47
+ end
48
+
49
+ # Role assigned to methods with many lines
50
+ #
51
+ # @see CodeObject::Ruby::MethodObject#has_many_lines?
52
+ class WithManyLines < Base
53
+ applicable_if :has_many_lines?
54
+ priority +2
55
+ end
56
+
57
+ # Role assigned to methods whose name end in a '!'
58
+ class WithBangName < Base
59
+ applicable_if :bang_name?
60
+ priority +3
61
+ end
62
+
63
+ # Role assigned to methods whose name end in a '?'
64
+ class WithQuestioningName < Base
65
+ applicable_if :questioning_name?
66
+ priority -4
67
+ end
68
+
69
+ # Role assigned to methods which are aliased
70
+ class HasAlias < Base
71
+ applicable_if :has_alias?
72
+ priority +2
73
+ end
74
+
75
+ # Role assigned to methods that are constructors
76
+ class Constructor < Base
77
+ applicable_if :constructor?
78
+ end
79
+
80
+ # Role assigned to methods that are getters
81
+ class Getter < Base
82
+ applicable_if :getter?
83
+ end
84
+
85
+ # Role assigned to methods that are setters
86
+ class Setter < Base
87
+ applicable_if :setter?
88
+ end
89
+
90
+ # Role assigned to methods that are overriding another method
91
+ class Overridden < Base
92
+ applicable_if :overridden?
93
+ # It seems more important to document the overridden method,
94
+ # than the overriding one
95
+ priority -2
96
+
97
+ # This role doesnot assign a score.
98
+ def score
99
+ nil
100
+ end
101
+
102
+ # This role sets a min_score.
103
+ def min_score
104
+ @value.to_f
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,64 @@
1
+ module Inch
2
+ module Language
3
+ module Elixir
4
+ module Evaluation
5
+ module Role
6
+ # Roles assigned to modules
7
+ module Module
8
+ # Role assigned to modules with children
9
+ #
10
+ # @see CodeObject::Ruby::NamespaceObject#has_children?
11
+ class WithChildren < Base
12
+ applicable_if :has_children?
13
+
14
+ # This role doesnot assign a score.
15
+ def score
16
+ 0
17
+ end
18
+
19
+ # This role sets a max_score.
20
+ def max_score
21
+ # @value.to_f
22
+ end
23
+ end
24
+
25
+ # Role assigned to modules with many children
26
+ #
27
+ # @see CodeObject::Ruby::NamespaceObject#has_many_children?
28
+ class WithManyChildren < Base
29
+ applicable_if :has_many_children?
30
+
31
+ # +priority
32
+ def priority
33
+ +1
34
+ end
35
+ end
36
+
37
+ # Role assigned to modules without any children
38
+ class WithoutChildren < Base
39
+ applicable_unless :has_children?
40
+ end
41
+
42
+ # Role assigned to modules without any methods
43
+ class WithoutMethods < Base
44
+ applicable_unless :has_methods?
45
+
46
+ def priority
47
+ -2
48
+ end
49
+ end
50
+
51
+ # A 'pure' namespace has only modules as children
52
+ class Pure < Base
53
+ applicable_if :pure_namespace?
54
+
55
+ def priority
56
+ -2
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,76 @@
1
+ module Inch
2
+ module Language
3
+ module Elixir
4
+ module Evaluation
5
+ module Role
6
+ # Roles assigned to all objects
7
+ module Object
8
+ # Role assigned to objects with a describing comment (docstring)
9
+ class WithDoc < Base
10
+ applicable_if :has_doc?
11
+ end
12
+
13
+ # Role assigned to objects without a docstring
14
+ class WithoutDoc < Missing
15
+ applicable_unless :has_doc?
16
+
17
+ def suggestion
18
+ "Add a comment describing the #{object_type}"
19
+ end
20
+ end
21
+
22
+ # Tagged means tagged in an unconsidred way, i.e. YARD tags not
23
+ # considered by Inch. Since these tags are parsed from the docstring
24
+ # the object seems undocumented to Inch.
25
+ class Tagged < Base
26
+ applicable_if :has_unconsidered_tags?
27
+ priority -1
28
+ end
29
+
30
+ # Role assigned to objects explicitly or implicitly tagged not to be
31
+ # documented.
32
+ #
33
+ # @see CodeObject::NodocHelper
34
+ class TaggedAsNodoc < Base
35
+ applicable_if :nodoc?
36
+ priority -7
37
+ end
38
+
39
+ # Role assigned to objects declared in the top-level namespace
40
+ class InRoot < Base
41
+ applicable_if :in_root?
42
+ priority +3
43
+ end
44
+
45
+ # Role assigned to public objects
46
+ class Public < Base
47
+ applicable_if :public?
48
+ priority 0
49
+ end
50
+
51
+ # Role assigned to objects with a single code example
52
+ class WithCodeExample < Base
53
+ applicable_if do |o|
54
+ o.has_code_example? && !o.has_multiple_code_examples?
55
+ end
56
+ end
57
+
58
+ # Role assigned to objects with multiple code examples
59
+ class WithMultipleCodeExamples < Base
60
+ applicable_if :has_multiple_code_examples?
61
+ end
62
+
63
+ # Role assigned to objects without a code example
64
+ class WithoutCodeExample < Missing
65
+ applicable_unless :has_code_example?
66
+
67
+ def suggestion
68
+ "Add a code example (optional)"
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,13 @@
1
+ module Inch
2
+ module Language
3
+ module Elixir
4
+ module Evaluation
5
+ module Role
6
+ # Roles assigned to types
7
+ module Type
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ module Inch
2
+ module Language
3
+ module Nodejs
4
+ end
5
+ end
6
+ end
7
+
8
+ require "inch/language/nodejs/provider/jsdoc"
@@ -0,0 +1,19 @@
1
+ require 'json'
2
+
3
+ module Inch
4
+ module Language
5
+ module Nodejs
6
+ module Provider
7
+ # Parses the source tree (using JSDoc)
8
+ module JSDoc
9
+ # @see Provider.parse
10
+ def self.parse(dir, config)
11
+ Parser.parse(dir, config)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ require "inch/language/nodejs/provider/jsdoc/parser"
@@ -0,0 +1,55 @@
1
+ module Inch
2
+ module Language
3
+ module Nodejs
4
+ module Provider
5
+ module JSDoc
6
+ # CodeObject::Provider::JSDoc::Object object represent code objects.
7
+ #
8
+ module Object
9
+ class << self
10
+ def clear_cache
11
+ @cache = {}
12
+ end
13
+
14
+ # Returns a Proxy object for the given +jsdoc_object+
15
+ #
16
+ # @param jsdoc_object [Hash]
17
+ # @return [Provider::JSDoc::Object]
18
+ def for(jsdoc_object)
19
+ @cache ||= {}
20
+ if proxy_object = @cache[cache_key(jsdoc_object)]
21
+ proxy_object
22
+ else
23
+ @cache[cache_key(jsdoc_object)] =
24
+ class_for(jsdoc_object).new(jsdoc_object)
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ # Returns a Proxy class for the given +jsdoc_object+
31
+ #
32
+ # @param jsdoc_object [Hash]
33
+ # @return [Class]
34
+ def class_for(jsdoc_object)
35
+ class_name = jsdoc_object.class.to_s.split("::").last
36
+ const_get(class_name)
37
+ rescue NameError
38
+ Base
39
+ end
40
+
41
+ # Returns a cache key for the given +jsdoc_object+
42
+ #
43
+ # @param jsdoc_object [Hash]
44
+ # @return [String]
45
+ def cache_key(jsdoc_object)
46
+ return if jsdoc_object['meta'].nil?
47
+ "#{jsdoc_object['meta']['path']}/#{jsdoc_object['meta']['path']}:#{jsdoc_object['meta']['lineno']}"
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,191 @@
1
+ module Inch
2
+ module Language
3
+ module Nodejs
4
+ module Provider
5
+ module JSDoc
6
+ module Object
7
+ # @abstract
8
+ class Base
9
+ # @param hash [Hash] hash returned via JSON interface
10
+ def initialize(hash)
11
+ @hash = hash
12
+ end
13
+
14
+ def name
15
+ raise NotImplementedError
16
+ end
17
+
18
+ def fullname
19
+ raise NotImplementedError
20
+ end
21
+
22
+ def files
23
+ raise NotImplementedError
24
+ end
25
+
26
+ def filename
27
+ raise NotImplementedError
28
+ end
29
+
30
+ def children_fullnames
31
+ raise NotImplementedError
32
+ end
33
+
34
+ def parent_fullname
35
+ raise NotImplementedError
36
+ end
37
+
38
+ def api_tag?
39
+ raise NotImplementedError
40
+ end
41
+
42
+ def aliased_object_fullname
43
+ raise NotImplementedError
44
+ end
45
+
46
+ def aliases_fullnames
47
+ raise NotImplementedError
48
+ end
49
+
50
+ def attributes
51
+ raise NotImplementedError
52
+ end
53
+
54
+ def bang_name?
55
+ raise NotImplementedError
56
+ end
57
+
58
+ def constant?
59
+ raise NotImplementedError
60
+ end
61
+
62
+ def constructor?
63
+ raise NotImplementedError
64
+ end
65
+
66
+ def depth
67
+ raise NotImplementedError
68
+ end
69
+
70
+ def docstring
71
+ raise NotImplementedError
72
+ end
73
+
74
+ def getter?
75
+ raise NotImplementedError
76
+ end
77
+
78
+ def has_children?
79
+ raise NotImplementedError
80
+ end
81
+
82
+ def has_code_example?
83
+ raise NotImplementedError
84
+ end
85
+
86
+ def has_doc?
87
+ raise NotImplementedError
88
+ end
89
+
90
+ def has_multiple_code_examples?
91
+ raise NotImplementedError
92
+ end
93
+
94
+ def has_unconsidered_tags?
95
+ raise NotImplementedError
96
+ end
97
+
98
+ def method?
99
+ raise NotImplementedError
100
+ end
101
+
102
+ def nodoc?
103
+ raise NotImplementedError
104
+ end
105
+
106
+ def namespace?
107
+ raise NotImplementedError
108
+ end
109
+
110
+ def original_docstring
111
+ raise NotImplementedError
112
+ end
113
+
114
+ def overridden?
115
+ raise NotImplementedError
116
+ end
117
+
118
+ def overridden_method_fullname
119
+ raise NotImplementedError
120
+ end
121
+
122
+ def parameters
123
+ raise NotImplementedError
124
+ end
125
+
126
+ def private?
127
+ raise NotImplementedError
128
+ end
129
+
130
+ def tagged_as_internal_api?
131
+ raise NotImplementedError
132
+ end
133
+
134
+ def tagged_as_private?
135
+ raise NotImplementedError
136
+ end
137
+
138
+ def protected?
139
+ raise NotImplementedError
140
+ end
141
+
142
+ def public?
143
+ raise NotImplementedError
144
+ end
145
+
146
+ def questioning_name?
147
+ raise NotImplementedError
148
+ end
149
+
150
+ def return_described?
151
+ raise NotImplementedError
152
+ end
153
+
154
+ def return_mentioned?
155
+ raise NotImplementedError
156
+ end
157
+
158
+ def return_typed?
159
+ raise NotImplementedError
160
+ end
161
+
162
+ def in_root?
163
+ raise NotImplementedError
164
+ end
165
+
166
+ def setter?
167
+ raise NotImplementedError
168
+ end
169
+
170
+ def source
171
+ raise NotImplementedError
172
+ end
173
+
174
+ def unconsidered_tag_count
175
+ raise NotImplementedError
176
+ end
177
+
178
+ def undocumented?
179
+ raise NotImplementedError
180
+ end
181
+
182
+ def visibility
183
+ raise NotImplementedError
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
191
+ end