Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 1x 31x 1x 8x 4x 4x 3x 1x 2x 1x 2x 1x 4x 4x 4x 1x 5x 5x 21x 1x 22x 22x 22x | 'use strict' const getIndent = (indent) => { return typeof indent === 'number' ? ' '.repeat(indent) : indent } module.exports = exports = function stringify (arg, opts) { if (Array.isArray(arg)) { return stringifyBlocks(arg, opts) } if (arg && typeof arg === 'object') { if ('tag' in arg) { return stringifyTag(arg, opts) } if ('tags' in arg) { return stringifyBlock(arg, opts) } } throw new TypeError('Unexpected argument passed to `stringify`.') } const stringifyBlocks = exports.stringifyBlocks = function stringifyBlocks ( blocks, { indent = '' } = {} ) { const indnt = getIndent(indent) return blocks.reduce((s, block) => { return s + stringifyBlock(block, { indent }) }, (indnt ? indnt.slice(0, -1) : '') + '/**\n') + indnt + '*/' } const stringifyBlock = exports.stringifyBlock = function stringifyBlock ( block, { indent = '' } = {} ) { // block.line const indnt = getIndent(indent) return (block.description ? `${indnt}* ${block.description}\n${indnt}*\n` : '') + block.tags.reduce((s, tag) => { return s + stringifyTag(tag, { indent }) }, '') } const stringifyTag = exports.stringifyTag = function stringifyTag ( tag, { indent = '' } = {} ) { const indnt = getIndent(indent) const { type, name, optional, description, tag: tagName, default: deflt //, line , source } = tag return indnt + `* @${tagName}` + (type ? ` {${type}}` : '') + (name ? ` ${ optional ? '[' : '' }${name}${deflt ? `=${deflt}` : ''}${ optional ? ']' : '' }` : '') + (description ? ` ${description.replace(/\n/g, '\n' + indnt + '* ')}` : '') + '\n' } |