Class: JsDuck::Process::InheritMembers

Inherits:
Object
  • Object
show all
Defined in:
lib/jsduck/process/inherit_members.rb

Overview

Deals with inheriting member documentation.

Instance Method Summary collapse

Constructor Details

#initialize(relations) ⇒ InheritMembers

Returns a new instance of InheritMembers.



9
10
11
# File 'lib/jsduck/process/inherit_members.rb', line 9

def initialize(relations)
  @relations = relations
end

Instance Method Details

#resolve(cls) ⇒ Object

Inherits docs for all members in class.

In case of members with explicit @inheritdoc tags we inherit the following fields when they’re not empty in current member:

  • :doc

  • :params

  • :return

  • :throws

In case of auto-detected members that inherit from a public member in parent class, we inherit all fields that aren’t present in current member, plus the :type field.

Auto-detected members inheriting from other private auto-detected members follow the same rules of inheritance as members with explicit @inheritdoc.

Additionally auto-detected properties get turned into configs when a public configs with same name is detected in parent class.



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jsduck/process/inherit_members.rb', line 35

def resolve(cls)
  new_cfgs = []

  cls.all_local_members.each do |member|
    if member[:inheritdoc]
      resolve_member(cls, member, new_cfgs)
    end
  end

  move_cfgs(cls, new_cfgs) if new_cfgs.length > 0
end