(doc)
| 400 | * @return {String[]} issues |
| 401 | */ |
| 402 | export function validateDoc (doc) { |
| 403 | const issues = [] |
| 404 | |
| 405 | function ignore (field) { |
| 406 | return IGNORE_WARNINGS[field].includes(doc.name) |
| 407 | } |
| 408 | |
| 409 | if (!doc.name) { |
| 410 | issues.push('name missing in document') |
| 411 | } |
| 412 | |
| 413 | if (!doc.description) { |
| 414 | issues.push('function "' + doc.name + '": description missing') |
| 415 | } |
| 416 | |
| 417 | if (!doc.syntax || doc.syntax.length === 0) { |
| 418 | issues.push('function "' + doc.name + '": syntax missing') |
| 419 | } |
| 420 | |
| 421 | if (!doc.examples || doc.examples.length === 0) { |
| 422 | issues.push('function "' + doc.name + '": examples missing') |
| 423 | } |
| 424 | |
| 425 | if (doc.parameters && doc.parameters.length) { |
| 426 | doc.parameters.forEach(function (param, index) { |
| 427 | if (!param.name || !param.name.trim()) { |
| 428 | issues.push('function "' + doc.name + '": name missing of parameter ' + index + '') |
| 429 | } |
| 430 | if (!param.description || !param.description.trim()) { |
| 431 | issues.push('function "' + doc.name + '": description missing for parameter ' + (param.name || index)) |
| 432 | } |
| 433 | if (!param.types || !param.types.length) { |
| 434 | issues.push('function "' + doc.name + '": types missing for parameter ' + (param.name || index)) |
| 435 | } |
| 436 | }) |
| 437 | } else { |
| 438 | if (!ignore('parameters')) { |
| 439 | issues.push('function "' + doc.name + '": parameters missing') |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | if (doc.mayThrow && doc.mayThrow.length) { |
| 444 | doc.mayThrow.forEach(function (err, index) { |
| 445 | if (!err.type) { |
| 446 | issues.push( |
| 447 | 'function "' + doc.name + '": error type missing for throw ' + index) |
| 448 | } |
| 449 | }) |
| 450 | } |
| 451 | |
| 452 | if (doc.returns) { |
| 453 | if (!doc.returns.description || !doc.returns.description.trim()) { |
| 454 | issues.push('function "' + doc.name + '": description missing of returns') |
| 455 | } |
| 456 | if (!doc.returns.types || !doc.returns.types.length) { |
| 457 | issues.push('function "' + doc.name + '": types missing of returns') |
| 458 | } |
| 459 | } else { |
no test coverage detected
searching dependent graphs…