Class: Inch::CodeObject::Provider::YARD::Object::Base
Abstract
- Inherits:
-
Object
- Object
- Inch::CodeObject::Provider::YARD::Object::Base
show all
- Extended by:
- Forwardable
- Includes:
- NodocHelper
- Defined in:
- lib/inch/code_object/provider/yard/object/base.rb
Overview
Defined Under Namespace
Classes: CodeLocation
Constant Summary
collapse
- CONSIDERED_YARD_TAGS =
%w(api example param private return since)
- AUTO_GENERATED_TAG_NAMES =
%w(raise yield)
- RUBY_CORE =
%w(Array Bignum BasicObject Object Module Class Complex NilClass Numeric String Float Fiber FiberError Continuation Dir File Encoding Enumerator StopIteration Enumerator::Generator Enumerator::Yielder Exception SystemExit SignalException Interrupt StandardError TypeError ArgumentError IndexError KeyError RangeError ScriptError SyntaxError LoadError NotImplementedError NameError NoMethodError RuntimeError SecurityError NoMemoryError EncodingError SystemCallError Encoding::CompatibilityError File::Stat IO Hash ENV IOError EOFError ARGF RubyVM RubyVM::InstructionSequence Math::DomainError ZeroDivisionError FloatDomainError Integer Fixnum Data TrueClass FalseClass Mutex Thread Proc LocalJumpError SystemStackError Method UnboundMethod Binding Process::Status Random Range Rational RegexpError Regexp MatchData Symbol Struct ThreadGroup ThreadError Time Encoding::UndefinedConversionError Encoding::InvalidByteSequenceError Encoding::ConverterNotFoundError Encoding::Converter RubyVM::Env) +
%w(Comparable Kernel File::Constants Enumerable Errno FileTest GC ObjectSpace GC::Profiler IO::WaitReadable IO::WaitWritable Marshal Math Process Process::UID Process::GID Process::Sys Signal)
Constants included
from NodocHelper
NodocHelper::DOC_REGEX, NodocHelper::NO_DOC_ALL_REGEX, NodocHelper::NO_DOC_REGEX
Instance Attribute Summary collapse
Instance Method Summary
collapse
#declarations, #explicit_doc_comment?, #explicit_nodoc_all_comment?, #explicit_nodoc_comment?, #get_line_no, #implicit_nodoc_all_comment?, #implicit_nodoc_comment?, #nodoc?, #nodoc_comment?
Constructor Details
#initialize(object) ⇒ Base
Returns a new instance of Base.
27
28
29
30
31
32
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 27
def initialize(object)
@object = object
@__api_tag = __api_tag
@__parent = __parent
@__private_tag = __private_tag
end
|
Instance Attribute Details
#aliased_object_fullname ⇒ Object
Returns the fullname of the object that the current object is an alias for
36
37
38
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 36
def aliased_object_fullname
@aliased_object_fullname
end
|
#base_dir ⇒ String
Returns the codebase’s directory.
17
18
19
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 17
def base_dir
@base_dir
end
|
#object ⇒ YARD::CodeObjects::Base
Returns the actual (YARD) code object.
14
15
16
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 14
def object
@object
end
|
Instance Method Details
193
194
195
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 193
def __parent
YARD::Object.for(object.parent) if object.parent
end
|
#aliases_fullnames ⇒ Object
Returns the fullnames of the objects that are aliases for the current object
40
41
42
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 40
def aliases_fullnames
[]
end
|
48
49
50
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 48
def api_tag
@__api_tag
end
|
#api_tag? ⇒ Boolean
44
45
46
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 44
def api_tag?
!api_tag.nil?
end
|
55
56
57
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 55
def child(name)
nil
end
|
66
67
68
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 66
def children
[]
end
|
#children_fullnames ⇒ Array?
Returns the full names of the children of the current object.
60
61
62
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 60
def children_fullnames
[]
end
|
#core? ⇒ Boolean
72
73
74
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 72
def core?
RUBY_CORE.include?(name.to_s)
end
|
#depth ⇒ Fixnum
Note:
top-level counts, that’s why Foo has depth 1!
The depth of the following is 4:
Foo::Bar::Baz#initialize
^ ^ ^ ^
1 << 2 << 3 << 4
depth
answers the question “how many layers of code objects are above this one?”
165
166
167
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 165
def depth
@__depth ||= __depth
end
|
77
78
79
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 77
def docstring
@docstring ||= Docstring.new(object.docstring)
end
|
#filename ⇒ String
Returns the name of the file where the object is declared first
104
105
106
107
108
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 104
def filename
files.first && files.first.filename
end
|
Returns all files declaring the object in the form of an Array of Arrays containing the location of their declaration.
85
86
87
88
89
90
91
92
93
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 85
def files
object.files.map do |(filename, line_no)|
CodeLocation.new(base_dir, filename, line_no)
end
rescue ::YARD::CodeObjects::ProxyMethodError
[]
end
|
110
111
112
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 110
def fullname
@fullname ||= object.path
end
|
#has_children? ⇒ Boolean
118
119
120
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 118
def has_children?
!children.empty?
end
|
#has_code_example? ⇒ Boolean
122
123
124
125
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 122
def has_code_example?
!tags(:example).empty? ||
docstring.contains_code_example?
end
|
#has_doc? ⇒ Boolean
127
128
129
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 127
def has_doc?
!docstring.empty?
end
|
#has_multiple_code_examples? ⇒ Boolean
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 131
def has_multiple_code_examples?
if tags(:example).size > 1 || docstring.code_examples.size > 1
true
else
if tag = tag(:example)
multi_code_examples?(tag.text)
elsif text = docstring.code_examples.first
multi_code_examples?(text)
else
false
end
end
end
|
145
146
147
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 145
def has_unconsidered_tags?
!unconsidered_tags.empty?
end
|
#in_in_root? ⇒ Boolean
149
150
151
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 149
def in_in_root?
depth == 1
end
|
#in_root? ⇒ Boolean
217
218
219
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 217
def in_root?
depth == 1
end
|
230
231
232
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 230
def inspect
"#<#{self.class.to_s}: #{fullname}>"
end
|
#method? ⇒ Boolean
Returns true
if the object represents a method.
170
171
172
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 170
def method?
false
end
|
114
115
116
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 114
def name
@name ||= object.name
end
|
#namespace? ⇒ Boolean
Returns true
if the object represents a namespace.
175
176
177
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 175
def namespace?
false
end
|
#original_docstring ⇒ String
Returns the documentation comments.
180
181
182
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 180
def original_docstring
object.docstring.all.to_s
end
|
#parameters ⇒ Object
184
185
186
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 184
def parameters
[]
end
|
#parent ⇒ Array?
Returns the parent of the current object or nil
.
189
190
191
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 189
def parent
@__parent
end
|
#private? ⇒ Boolean
197
198
199
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 197
def private?
visibility == :private
end
|
#protected? ⇒ Boolean
209
210
211
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 209
def protected?
visibility == :protected
end
|
#public? ⇒ Boolean
213
214
215
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 213
def public?
visibility == :public
end
|
#tagged_as_internal_api? ⇒ Boolean
201
202
203
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 201
def tagged_as_internal_api?
private_api_tag? || docstring.describes_internal_api?
end
|
#tagged_as_private? ⇒ Boolean
205
206
207
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 205
def tagged_as_private?
private_tag? || docstring.describes_private_object?
end
|
#unconsidered_tag_count ⇒ Object
226
227
228
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 226
def unconsidered_tag_count
unconsidered_tags.size
end
|
#undocumented? ⇒ Boolean
Returns true
if the object has no documentation at all.
222
223
224
|
# File 'lib/inch/code_object/provider/yard/object/base.rb', line 222
def undocumented?
original_docstring.empty?
end
|