Class: Documentation::Doc

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Includes:
Enumerable
Defined in:
lib/pdoc/parser/documentation_nodes.rb

Instance Method Summary collapse

Instance Method Details

#eachObject



9
10
11
# File 'lib/pdoc/parser/documentation_nodes.rb', line 9

def each
  tags.each { |tag| yield tag }
end

#find_by_name(name) ⇒ Object

find_by_name allows you to search through all the documented instances based on the instances Base#full_name. For example:

PDoc::Parser.new("prototype.js").parse.root.find_by_name("Element#update")

Return an instance of InstanceMethod corresponding to “Element#update”.



20
21
22
# File 'lib/pdoc/parser/documentation_nodes.rb', line 20

def find_by_name(name)
  find { |e| e.full_name == name }
end

#inspectObject



24
25
26
# File 'lib/pdoc/parser/documentation_nodes.rb', line 24

def inspect
  to_a.inspect
end

#nameObject



33
34
35
# File 'lib/pdoc/parser/documentation_nodes.rb', line 33

def name
  "Home"
end

#serialize(serializer) ⇒ Object



37
38
39
# File 'lib/pdoc/parser/documentation_nodes.rb', line 37

def serialize(serializer)
  each { |obj| obj.serialize(serializer) }
end

#sizeObject

Returns the total number of documented instances



29
30
31
# File 'lib/pdoc/parser/documentation_nodes.rb', line 29

def size
  to_a.length
end

#tagsObject



5
6
7
# File 'lib/pdoc/parser/documentation_nodes.rb', line 5

def tags
  @tags ||= elements.first.elements.map { |e| e.elements.last }
end