Method: Docurium#collect_warnings

Defined in:
lib/docurium.rb

#collect_warnings(data) ⇒ Object



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/docurium.rb', line 300

def collect_warnings(data)
  warnings = []
  input_dir = File.join(@project_dir, option_version("HEAD", 'input'))

  # check for unmatched paramaters
  data[:functions].each do |f, fdata|
    warnings << Warning::UnmatchedParameter.new(f, type: fdata, input_dir: input_dir) if fdata[:comments] =~ /@param/
  end

  # check for changed signatures
  sigchanges = []
  @sigs.each do |fun, sig_data|
    warnings << Warning::SignatureChanged.new(fun) if sig_data[:changes]['HEAD']
  end

  # check for undocumented things
  types = [:functions, :callbacks, :globals, :types]
  types.each do |type_id|
    under_type = type_id.tap {|t| break t.to_s[0..-2].to_sym }
    data[type_id].each do |ident, type|
      under_type = type[:type] if type_id == :types

      warnings << Warning::MissingDocumentation.new(under_type, ident, type: type, input_dir: input_dir) if type[:description].empty?

      case type[:type]
      when :struct
        if type[:fields]
          type[:fields].each do |field|
            warnings << Warning::MissingDocumentation.new(:field, "#{ident}.#{field[:name]}", type: type, input_dir: input_dir) if field[:comments].empty?
          end
        end
      end
    end
  end
  warnings
end