Class: RDoc::Generator::Mdoc::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/generator/mdoc/section.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rdoc_section, rdoc_constants, rdoc_attributes, mandb_section, parent) ⇒ Section

Returns a new instance of Section.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rdoc/generator/mdoc/section.rb', line 12

def initialize(
  rdoc_section,
  rdoc_constants,
  rdoc_attributes,
  mandb_section,
  parent
)
  @rdoc_section = rdoc_section
  @rdoc_constants = rdoc_constants
  @rdoc_attributes = rdoc_attributes
  @mandb_section = mandb_section
  @parent = parent
end

Class Method Details

.method_typesObject



8
9
10
# File 'lib/rdoc/generator/mdoc/section.rb', line 8

def self.method_types
  [:class, :instance]
end

Instance Method Details

#attributesObject



48
49
50
51
52
# File 'lib/rdoc/generator/mdoc/section.rb', line 48

def attributes
  @attributes ||= rdoc_attributes.map do |rdoc_attribute|
    Attribute.new(rdoc_attribute)
  end
end

#constantsObject



42
43
44
45
46
# File 'lib/rdoc/generator/mdoc/section.rb', line 42

def constants
  @constants ||= rdoc_constants.map do |rdoc_constant|
    Constant.new(rdoc_constant)
  end
end

#described?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/rdoc/generator/mdoc/section.rb', line 34

def described?
  !description.empty?
end

#descriptionObject



38
39
40
# File 'lib/rdoc/generator/mdoc/section.rb', line 38

def description
  comment.mdoc_formatted_content
end

#methodsObject



54
55
56
# File 'lib/rdoc/generator/mdoc/section.rb', line 54

def methods
  self.class.method_types.flat_map { |type| methods_of_type(type) }
end

#methods_of_type(type) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rdoc/generator/mdoc/section.rb', line 58

def methods_of_type(type)
  @methods_of_type ||= {}
  @methods_of_type[type] ||=
    parent.
    methods_by_type(rdoc_section)[type.to_s].
    flat_map do |visibility, rdoc_methods|
      rdoc_methods.select do |rdoc_method|
        rdoc_method.is_a? RDoc::AnyMethod
      end.map do |rdoc_method|
        Method.new(rdoc_method, mandb_section, visibility)
      end
    end
end

#titleObject



30
31
32
# File 'lib/rdoc/generator/mdoc/section.rb', line 30

def title
  rdoc_section.title
end

#titled?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rdoc/generator/mdoc/section.rb', line 26

def titled?
  !title.nil?
end