class JsDuck::Process::InheritClass
Deals with inheriting class documentation.
Public Class Methods
new(relations)
click to toggle source
# File lib/jsduck/process/inherit_class.rb, line 8 def initialize(relations) @relations = relations end
Public Instance Methods
resolve(cls)
click to toggle source
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.
# 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
Private Instance Methods
find_parent(cls)
click to toggle source
# File lib/jsduck/process/inherit_class.rb, line 36 def find_parent(cls) if cls[:inheritdoc][:cls] # @inheritdoc MyClass parent = @relations[cls[:inheritdoc][:cls]] return warn("class not found", cls) unless parent else # @inheritdoc parent = cls.parent return warn("parent class not found", cls) unless parent end return parent end
warn(msg, cls)
click to toggle source
# File lib/jsduck/process/inherit_class.rb, line 50 def warn(msg, cls) Logger.warn(:inheritdoc, "@inheritdoc #{cls[:inheritdoc][:cls]} - #{msg}", cls[:files][0]) return nil end