Class: Documentation::Method

Inherits:
Base
  • Object
show all
Defined in:
lib/pdoc/parser/documentation_nodes.rb

Direct Known Subclasses

Constructor, InstanceMethod, KlassMethod, Utility

Instance Method Summary collapse

Methods inherited from Base

#alias_of, #deprecated?, #description, #doc_parent, #ebnf_expressions, #inspect, #namespace, #parent_id, #related_to, #root, #section_name, #src_code_line, #tags, #to_yaml

Methods included from Memoized

#avoid_infinite_method_added_loop, #memoize, #method_added

Instance Method Details

#argumentsObject



293
294
295
296
# File 'lib/pdoc/parser/documentation_nodes.rb', line 293

def arguments
  args = argument_descriptions.elements
  args ? args.first.elements :  []
end

#firesObject



306
307
308
# File 'lib/pdoc/parser/documentation_nodes.rb', line 306

def fires
  events.empty? ? [] : events.to_a
end

#full_nameObject



277
278
279
# File 'lib/pdoc/parser/documentation_nodes.rb', line 277

def full_name
  ebnf_expressions.first.full_name
end

#klassObject



269
270
271
# File 'lib/pdoc/parser/documentation_nodes.rb', line 269

def klass
  namespace
end

#klass_nameObject



273
274
275
# File 'lib/pdoc/parser/documentation_nodes.rb', line 273

def klass_name
  ebnf_expressions.first.klass_name
end

#methodized?Boolean



285
286
287
# File 'lib/pdoc/parser/documentation_nodes.rb', line 285

def methodized?
  ebnf_expressions.first.methodized?
end

#nameObject



281
282
283
# File 'lib/pdoc/parser/documentation_nodes.rb', line 281

def name
  ebnf_expressions.first.name
end

#namespace_stringObject



289
290
291
# File 'lib/pdoc/parser/documentation_nodes.rb', line 289

def namespace_string
  ebnf_expressions.first.namespace
end

#returnsObject



302
303
304
# File 'lib/pdoc/parser/documentation_nodes.rb', line 302

def returns
  ebnf_expressions.first.returns
end

#serialize(serializer) ⇒ Object



314
315
316
317
318
319
320
321
322
323
# File 'lib/pdoc/parser/documentation_nodes.rb', line 314

def serialize(serializer)
  str = to_yaml
  str << "\nmethodized: true" if respond_to?(:methodized?) && methodized?
  
  serialize_signatures(str)
  
  serialize_arguments(str) unless arguments.empty?
  
  serializer << str
end

#serialize_arguments(str) ⇒ Object



334
335
336
337
338
339
340
341
342
343
# File 'lib/pdoc/parser/documentation_nodes.rb', line 334

def serialize_arguments(str)
  str << "\narguments:"
  arguments.each do |arg|
    str << "\n -"
    str << "\n  name: #{arg.name}"
    str << "\n  types: [#{arg.types.join(', ')}]" unless arg.types.empty?
    str << "\n  description: >"
    str << "\n    #{arg.description}\n"
  end
end

#serialize_signatures(str) ⇒ Object



325
326
327
328
329
330
331
332
# File 'lib/pdoc/parser/documentation_nodes.rb', line 325

def serialize_signatures(str)
  str << "\nsignatures:"
  ebnf_expressions.each do |ebnf|
    str << "\n -"
    str << "\n  signature: #{ebnf.signature.inspect}"
    str << "\n  return_value: #{ebnf.returns.inspect}" if ebnf.returns
  end
end

#signatureObject



298
299
300
# File 'lib/pdoc/parser/documentation_nodes.rb', line 298

def signature
  ebnf_expressions.first.signature
end

#signaturesObject



310
311
312
# File 'lib/pdoc/parser/documentation_nodes.rb', line 310

def signatures
  ebnf_expressions
end