Class: JsDuck::Process::InheritClass
- Inherits:
-
Object
- Object
- JsDuck::Process::InheritClass
- Defined in:
- lib/jsduck/process/inherit_class.rb
Overview
Deals with inheriting class documentation.
Instance Method Summary collapse
-
#initialize(relations) ⇒ InheritClass
constructor
A new instance of InheritClass.
-
#resolve(cls) ⇒ Object
Inherits docs for class.
Constructor Details
#initialize(relations) ⇒ InheritClass
Returns a new instance of InheritClass.
8 9 10 |
# File 'lib/jsduck/process/inherit_class.rb', line 8 def initialize(relations) @relations = relations end |
Instance Method Details
#resolve(cls) ⇒ Object
Inherits docs for class.
For class we only inherit the value of :doc field.
When the class we’re inheriting from also has @inheritdoc tag, we first recursively resolve the inheritance of that class and only afterwards inherit to the current class.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jsduck/process/inherit_class.rb', line 19 def resolve(cls) return unless cls[:inheritdoc] parent = find_parent(cls) if parent && parent[:inheritdoc] resolve(parent) end if parent cls[:doc] = parent[:doc] if cls[:doc].empty? end cls[:inheritdoc] = nil end |