tools/docgenerator.js
function validateDoc (doc) {
  let issues = []

  function ignore (field) {
    return IGNORE_WARNINGS[field].indexOf(doc.name) !== -1
  }

  if (!doc.name) {
    issues.push('name missing in document')
  }

  if (!doc.description) {
    issues.push('function "' + doc.name + '": description missing')
  }

  if (!doc.syntax || doc.syntax.length === 0) {
    issues.push('function "' + doc.name + '": syntax missing')
  }

  if (!doc.examples || doc.examples.length === 0) {
    issues.push('function "' + doc.name + '": examples missing')
  }

  if (doc.parameters && doc.parameters.length) {
    doc.parameters.forEach(function (param, index) {
      if (!param.name || !param.name.trim()) {
        issues.push('function "' + doc.name + '": name missing of parameter ' + index + '')
      }
      if (!param.description || !param.description.trim()) {
        issues.push('function "' + doc.name + '": description missing for parameter ' + (param.name || index))
      }
      if (!param.types || !param.types.length) {
        issues.push('function "' + doc.name + '": types missing for parameter ' + (param.name || index))
      }
    })
  } else {
    if (!ignore('parameters')) {
      issues.push('function "' + doc.name + '": parameters missing')
    }
  }

  if (doc.returns) {
    if (!doc.returns.description || !doc.returns.description.trim()) {
      issues.push('function "' + doc.name + '": description missing of returns')
    }
    if (!doc.returns.types || !doc.returns.types.length) {
      issues.push('function "' + doc.name + '": types missing of returns')
    }
  } else {
    if (!ignore('returns')) {
      issues.push('function "' + doc.name + '": returns missing')
    }
  }

  if (!doc.seeAlso || doc.seeAlso.length === 0) {
    if (!ignore('seeAlso')) {
      issues.push('function "' + doc.name + '": seeAlso missing')
    }
  }

  return issues
}
function validateDoc (doc) {
  let issues = []

  function ignore (field) {
    return IGNORE_WARNINGS[field].indexOf(doc.name) !== -1
  }

  if (!doc.name) {
    issues.push('name missing in document')
  }

  if (!doc.description) {
    issues.push('function "' + doc.name + '": description missing')
  }

  if (!doc.syntax || doc.syntax.length === 0) {
    issues.push('function "' + doc.name + '": syntax missing')
  }

  if (!doc.examples || doc.examples.length === 0) {
    issues.push('function "' + doc.name + '": examples missing')
  }

  if (doc.parameters && doc.parameters.length) {
    doc.parameters.forEach(function (param, index) {
      if (!param.name || !param.name.trim()) {
        issues.push('function "' + doc.name + '": name missing of parameter ' + index + '')
      }
      if (!param.description || !param.description.trim()) {
        issues.push('function "' + doc.name + '": description missing for parameter ' + (param.name || index))
      }
      if (!param.types || !param.types.length) {
        issues.push('function "' + doc.name + '": types missing for parameter ' + (param.name || index))
      }
    })
  } else {
    if (!ignore('parameters')) {
      issues.push('function "' + doc.name + '": parameters missing')
    }
  }

  if (doc.returns) {
    if (!doc.returns.description || !doc.returns.description.trim()) {
      issues.push('function "' + doc.name + '": description missing of returns')
    }
    if (!doc.returns.types || !doc.returns.types.length) {
      issues.push('function "' + doc.name + '": types missing of returns')
    }
  } else {
    if (!ignore('returns')) {
      issues.push('function "' + doc.name + '": returns missing')
    }
  }

  if (!doc.seeAlso || doc.seeAlso.length === 0) {
    if (!ignore('seeAlso')) {
      issues.push('function "' + doc.name + '": seeAlso missing')
    }
  }

  return issues
}
function validateDoc ( doc ) { let issues = [ ] function ignore ( field ) { return IGNORE_WARNINGS [ field ] . indexOf ( doc . name ) !== - 1 } if ( ! doc . name ) { issues . push ( 'name missing in document' ) } if ( ! doc . description ) { issues . push ( 'function "' + doc . name + '": description missing' ) } if ( ! doc . syntax || doc . syntax . length === 0 ) { issues . push ( 'function "' + doc . name + '": syntax missing' ) } if ( ! doc . examples || doc . examples . length === 0 ) { issues . push ( 'function "' + doc . name + '": examples missing' ) } if ( doc . parameters && doc . parameters . length ) { doc . parameters . forEach ( function ( param , index ) { if ( ! param . name || ! param . name . trim ( ) ) { issues . push ( 'function "' + doc . name + '": name missing of parameter ' + index + '' ) } if ( ! param . description || ! param . description . trim ( ) ) { issues . push ( 'function "' + doc . name + '": description missing for parameter ' + ( param . name || index ) ) } if ( ! param . types || ! param . types . length ) { issues . push ( 'function "' + doc . name + '": types missing for parameter ' + ( param . name || index ) ) } } ) } else { if ( ! ignore ( 'parameters' ) ) { issues . push ( 'function "' + doc . name + '": parameters missing' ) } } if ( doc . returns ) { if ( ! doc . returns . description || ! doc . returns . description . trim ( ) ) { issues . push ( 'function "' + doc . name + '": description missing of returns' ) } if ( ! doc . returns . types || ! doc . returns . types . length ) { issues . push ( 'function "' + doc . name + '": types missing of returns' ) } } else { if ( ! ignore ( 'returns' ) ) { issues . push ( 'function "' + doc . name + '": returns missing' ) } } if ( ! doc . seeAlso || doc . seeAlso . length === 0 ) { if ( ! ignore ( 'seeAlso' ) ) { issues . push ( 'function "' + doc . name + '": seeAlso missing' ) } } return issues }
Validate whether all required fields are available in given doc
@param {Object} doc
@return {String[]} issues
Validate whether all required fields are available in given doc