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.
- 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,62 +0,0 @@
|
|
1
|
-
module Inch
|
2
|
-
module CodeObject
|
3
|
-
module Provider
|
4
|
-
module YARD
|
5
|
-
# Parses the source tree (using YARD)
|
6
|
-
class Parser
|
7
|
-
IGNORE_TYPES = [:macro]
|
8
|
-
|
9
|
-
# Helper method to parse an instance with the given +args+
|
10
|
-
#
|
11
|
-
# @see #parse
|
12
|
-
# @return [CodeObject::Provider::YARD::Parser] the instance that ran
|
13
|
-
def self.parse(*args)
|
14
|
-
parser = self.new
|
15
|
-
parser.parse(*args)
|
16
|
-
parser
|
17
|
-
end
|
18
|
-
|
19
|
-
# @param dir [String] directory
|
20
|
-
# @param config [Inch::Config::Codebase] configuration for codebase
|
21
|
-
# @return [void]
|
22
|
-
def parse(dir, config)
|
23
|
-
Dir.chdir(dir) do
|
24
|
-
parse_yard_objects(config.included_files, config.excluded_files)
|
25
|
-
inject_base_dir(dir)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# @return [Array<YARD::Object::Base>]
|
30
|
-
def objects
|
31
|
-
@objects ||= parsed_objects.map do |o|
|
32
|
-
YARD::Object.for(o) unless IGNORE_TYPES.include?(o.type)
|
33
|
-
end.compact
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def parse_yard_objects(paths, excluded)
|
39
|
-
YARD::Object.clear_cache
|
40
|
-
::YARD::Registry.clear
|
41
|
-
::YARD.parse(paths, excluded)
|
42
|
-
end
|
43
|
-
|
44
|
-
def inject_base_dir(dir)
|
45
|
-
objects.each do |object|
|
46
|
-
object.base_dir = dir
|
47
|
-
|
48
|
-
object.aliases_fullnames.each do |fullname|
|
49
|
-
_alias = objects.detect { |o| o.fullname == fullname }
|
50
|
-
_alias.aliased_object_fullname = object.fullname
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def parsed_objects
|
56
|
-
::YARD::Registry.all
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,241 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
module Inch
|
4
|
-
module CodeObject
|
5
|
-
module Proxy
|
6
|
-
# This is the base class for code object proxies.
|
7
|
-
# Code object proxies are via an attributes Hash and provide all methods
|
8
|
-
# necessary for the evaluation of its documentation.
|
9
|
-
#
|
10
|
-
# @abstract
|
11
|
-
class Base
|
12
|
-
extend Forwardable
|
13
|
-
|
14
|
-
# @return [Grade]
|
15
|
-
# when objects are assigned to GradeLists, this grade is set to
|
16
|
-
# enable easier querying for objects of a certain grade
|
17
|
-
attr_writer :grade
|
18
|
-
|
19
|
-
# @return [#find]
|
20
|
-
# an object that responds to #find to look up objects by their
|
21
|
-
# full name
|
22
|
-
attr_accessor :object_lookup
|
23
|
-
|
24
|
-
# convenient shortcuts to evalution object
|
25
|
-
def_delegators :evaluation, :score, :roles, :priority
|
26
|
-
|
27
|
-
def initialize(attributes = {})
|
28
|
-
@attributes = attributes
|
29
|
-
end
|
30
|
-
|
31
|
-
# Returns the attribute for the given +key+
|
32
|
-
#
|
33
|
-
# @param key [Symbol]
|
34
|
-
def [](key)
|
35
|
-
@attributes[key]
|
36
|
-
end
|
37
|
-
|
38
|
-
# @return [Evaluation::Base]
|
39
|
-
def evaluation
|
40
|
-
@evaluation ||= Evaluation::Proxy.for(self)
|
41
|
-
end
|
42
|
-
|
43
|
-
# @return [Symbol]
|
44
|
-
def grade
|
45
|
-
@grade ||= Evaluation.new_grade_lists.detect { |range|
|
46
|
-
range.scores.include?(score)
|
47
|
-
}.grade
|
48
|
-
end
|
49
|
-
|
50
|
-
# @return [Boolean] if the current object is an alias for something else
|
51
|
-
def alias?
|
52
|
-
!aliased_object.nil?
|
53
|
-
end
|
54
|
-
|
55
|
-
# @return [CodeObject::Proxy::Base] the object the current object is an alias of
|
56
|
-
def aliased_object
|
57
|
-
object_lookup.find( self[:aliased_object_fullname] )
|
58
|
-
end
|
59
|
-
|
60
|
-
# @return [Boolean] +true+ if the object has an @api tag
|
61
|
-
def api_tag?
|
62
|
-
self[:api_tag?]
|
63
|
-
end
|
64
|
-
|
65
|
-
# @return [Array] the children of the current object
|
66
|
-
def children
|
67
|
-
@children ||= self[:children_fullnames].map do |fullname|
|
68
|
-
object_lookup.find(fullname)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# @return [Boolean] +true+ if the object represents a constant
|
73
|
-
def constant?
|
74
|
-
self[:constant?]
|
75
|
-
end
|
76
|
-
|
77
|
-
def core?
|
78
|
-
self[:core?]
|
79
|
-
end
|
80
|
-
|
81
|
-
# The depth of the following is 4:
|
82
|
-
#
|
83
|
-
# Foo::Bar::Baz#initialize
|
84
|
-
# ^ ^ ^ ^
|
85
|
-
# 1 << 2 << 3 << 4
|
86
|
-
#
|
87
|
-
# +depth+ answers the question "how many layers of code objects are
|
88
|
-
# above this one?"
|
89
|
-
#
|
90
|
-
# @note top-level counts, that's why Foo has depth 1!
|
91
|
-
#
|
92
|
-
# @return [Fixnum] the depth of the object in terms of namespace
|
93
|
-
def depth
|
94
|
-
self[:depth]
|
95
|
-
end
|
96
|
-
|
97
|
-
# @return [Docstring]
|
98
|
-
def docstring
|
99
|
-
self[:docstring]
|
100
|
-
end
|
101
|
-
|
102
|
-
def files
|
103
|
-
self[:files]
|
104
|
-
end
|
105
|
-
|
106
|
-
# Returns the name of the file where the object is declared first
|
107
|
-
# @return [String] a filename
|
108
|
-
def filename
|
109
|
-
# just checking the first file (which is the file where an object
|
110
|
-
# is first declared)
|
111
|
-
files.first
|
112
|
-
end
|
113
|
-
|
114
|
-
# @return [String] the name of an object, e.g.
|
115
|
-
# "Docstring"
|
116
|
-
def name
|
117
|
-
self[:name]
|
118
|
-
end
|
119
|
-
|
120
|
-
# @return [String] the fully qualified name of an object, e.g.
|
121
|
-
# "Inch::CodeObject::Provider::YARD::Docstring"
|
122
|
-
def fullname
|
123
|
-
self[:fullname]
|
124
|
-
end
|
125
|
-
|
126
|
-
def has_alias?
|
127
|
-
!self[:aliases_fullnames].empty?
|
128
|
-
end
|
129
|
-
|
130
|
-
def has_children?
|
131
|
-
self[:has_children?]
|
132
|
-
end
|
133
|
-
|
134
|
-
def has_code_example?
|
135
|
-
self[:has_code_example?]
|
136
|
-
end
|
137
|
-
|
138
|
-
def has_doc?
|
139
|
-
self[:has_doc?]
|
140
|
-
end
|
141
|
-
|
142
|
-
def has_multiple_code_examples?
|
143
|
-
self[:has_multiple_code_examples?]
|
144
|
-
end
|
145
|
-
|
146
|
-
def has_unconsidered_tags?
|
147
|
-
self[:has_unconsidered_tags?]
|
148
|
-
end
|
149
|
-
|
150
|
-
def in_root?
|
151
|
-
self[:in_root?]
|
152
|
-
end
|
153
|
-
|
154
|
-
# @return [Boolean] +true+ if the object represents a method
|
155
|
-
def method?
|
156
|
-
self[:method?]
|
157
|
-
end
|
158
|
-
|
159
|
-
# @return [Boolean] +true+ if the object represents a namespace
|
160
|
-
def namespace?
|
161
|
-
self[:namespace?]
|
162
|
-
end
|
163
|
-
|
164
|
-
def original_docstring
|
165
|
-
self[:original_docstring]
|
166
|
-
end
|
167
|
-
|
168
|
-
# @return [Boolean] +true+ if the object was tagged not to be documented
|
169
|
-
def nodoc?
|
170
|
-
self[:nodoc?]
|
171
|
-
end
|
172
|
-
|
173
|
-
# @return [CodeObject::Proxy::Base,nil] the parent of the current object or +nil+
|
174
|
-
def parent
|
175
|
-
object_lookup.find( self[:parent_fullname] )
|
176
|
-
end
|
177
|
-
|
178
|
-
def private?
|
179
|
-
self[:private?]
|
180
|
-
end
|
181
|
-
|
182
|
-
# @return [Boolean]
|
183
|
-
# +true+ if the object or its parent is tagged as @private
|
184
|
-
def tagged_as_private?
|
185
|
-
self[:tagged_as_private?]
|
186
|
-
end
|
187
|
-
|
188
|
-
# @return [Boolean]
|
189
|
-
# +true+ if the object or its parent is tagged as part of an
|
190
|
-
# internal api
|
191
|
-
def tagged_as_internal_api?
|
192
|
-
self[:tagged_as_internal_api?]
|
193
|
-
end
|
194
|
-
|
195
|
-
def protected?
|
196
|
-
self[:protected?]
|
197
|
-
end
|
198
|
-
|
199
|
-
def public?
|
200
|
-
self[:public?]
|
201
|
-
end
|
202
|
-
|
203
|
-
def source
|
204
|
-
self[:source]
|
205
|
-
end
|
206
|
-
|
207
|
-
def type
|
208
|
-
self.class.to_s.gsub(/Object$/, '')
|
209
|
-
end
|
210
|
-
|
211
|
-
# @return [Boolean] +true+ if the object has no documentation at all
|
212
|
-
def undocumented?
|
213
|
-
self[:undocumented?]
|
214
|
-
end
|
215
|
-
|
216
|
-
# @return [Fixnum] the amount of tags not considered for this object
|
217
|
-
def unconsidered_tag_count
|
218
|
-
self[:unconsidered_tag_count]
|
219
|
-
end
|
220
|
-
|
221
|
-
def visibility
|
222
|
-
self[:visibility]
|
223
|
-
end
|
224
|
-
|
225
|
-
# Used to persist the code object
|
226
|
-
def marshal_dump
|
227
|
-
@attributes
|
228
|
-
end
|
229
|
-
|
230
|
-
# Used to load a persisted code object
|
231
|
-
def marshal_load(attributes)
|
232
|
-
@attributes = attributes
|
233
|
-
end
|
234
|
-
|
235
|
-
def inspect
|
236
|
-
"#<#{self.class.to_s}: #{fullname}>"
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
module Inch
|
2
|
-
module CodeObject
|
3
|
-
module Proxy
|
4
|
-
# Proxy class for methods
|
5
|
-
class MethodObject < Base
|
6
|
-
def constructor?
|
7
|
-
self[:constructor?]
|
8
|
-
end
|
9
|
-
|
10
|
-
def bang_name?
|
11
|
-
self[:bang_name?]
|
12
|
-
end
|
13
|
-
|
14
|
-
def getter?
|
15
|
-
self[:getter?]
|
16
|
-
end
|
17
|
-
|
18
|
-
def has_parameters?
|
19
|
-
!parameters.empty?
|
20
|
-
end
|
21
|
-
|
22
|
-
MANY_PARAMETERS_THRESHOLD = 3
|
23
|
-
def has_many_parameters?
|
24
|
-
parameters.size > MANY_PARAMETERS_THRESHOLD
|
25
|
-
end
|
26
|
-
|
27
|
-
MANY_LINES_THRESHOLD = 20
|
28
|
-
def has_many_lines?
|
29
|
-
# for now, this includes the 'def' line and comments
|
30
|
-
if source
|
31
|
-
size = source.lines.count
|
32
|
-
size > MANY_LINES_THRESHOLD
|
33
|
-
else
|
34
|
-
false
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def parameter(name)
|
39
|
-
parameters.detect { |p| p.name == name.to_s }
|
40
|
-
end
|
41
|
-
|
42
|
-
def parameters
|
43
|
-
@parameters ||= self[:parameters].map do |param_attr|
|
44
|
-
MethodParameterObject.new(param_attr)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def overridden?
|
49
|
-
self[:overridden?]
|
50
|
-
end
|
51
|
-
|
52
|
-
def overridden_method
|
53
|
-
@overridden_method ||= object_lookup.find(self[:overridden_method_fullname])
|
54
|
-
end
|
55
|
-
|
56
|
-
def return_mentioned?
|
57
|
-
self[:return_mentioned?]
|
58
|
-
end
|
59
|
-
|
60
|
-
def return_described?
|
61
|
-
self[:return_described?]
|
62
|
-
end
|
63
|
-
|
64
|
-
def return_typed?
|
65
|
-
self[:return_typed?]
|
66
|
-
end
|
67
|
-
|
68
|
-
def setter?
|
69
|
-
self[:setter?]
|
70
|
-
end
|
71
|
-
|
72
|
-
def source
|
73
|
-
self[:source?]
|
74
|
-
end
|
75
|
-
|
76
|
-
def questioning_name?
|
77
|
-
self[:questioning_name?]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
module Inch
|
2
|
-
module CodeObject
|
3
|
-
module Proxy
|
4
|
-
# Proxy class for method parameters
|
5
|
-
class MethodParameterObject
|
6
|
-
def initialize(attributes)
|
7
|
-
@attributes = attributes
|
8
|
-
end
|
9
|
-
|
10
|
-
def [](key)
|
11
|
-
@attributes[key]
|
12
|
-
end
|
13
|
-
|
14
|
-
BAD_NAME_EXCEPTIONS = %w(id)
|
15
|
-
BAD_NAME_THRESHOLD = 3
|
16
|
-
|
17
|
-
# @return [Boolean] +true+ if the name of the parameter is uncommunicative
|
18
|
-
def bad_name?
|
19
|
-
return false if BAD_NAME_EXCEPTIONS.include?(name)
|
20
|
-
name.size < BAD_NAME_THRESHOLD || name =~ /[0-9]$/
|
21
|
-
end
|
22
|
-
|
23
|
-
# @return [Boolean] +true+ if the parameter is a block
|
24
|
-
def block?
|
25
|
-
self[:block?]
|
26
|
-
end
|
27
|
-
|
28
|
-
# @return [Boolean] +true+ if an additional description given?
|
29
|
-
def described?
|
30
|
-
self[:described?]
|
31
|
-
end
|
32
|
-
|
33
|
-
# @return [Boolean] +true+ if the parameter is mentioned in the docs
|
34
|
-
def mentioned?
|
35
|
-
self[:mentioned?]
|
36
|
-
end
|
37
|
-
|
38
|
-
def name
|
39
|
-
self[:name]
|
40
|
-
end
|
41
|
-
alias fullname name
|
42
|
-
|
43
|
-
# @return [Boolean] +true+ if the parameter is a splat argument
|
44
|
-
def splat?
|
45
|
-
self[:splat?]
|
46
|
-
end
|
47
|
-
|
48
|
-
# @return [Boolean] +true+ if the type of the parameter is defined
|
49
|
-
def typed?
|
50
|
-
self[:typed?]
|
51
|
-
end
|
52
|
-
|
53
|
-
# @return [Boolean] +true+ if the parameter is mentioned in the docs, but not present in the method's signature
|
54
|
-
def wrongly_mentioned?
|
55
|
-
self[:wrongly_mentioned?]
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|