diff --git a/lib/doc/apply-fp-mapping/description.js b/lib/doc/apply-fp-mapping/description.js new file mode 100644 index 000000000..f6b4f1bdd --- /dev/null +++ b/lib/doc/apply-fp-mapping/description.js @@ -0,0 +1,39 @@ +var _ = require('lodash'), + j = require('jscodeshift'), + Entry = require('docdown/lib/entry'), + common = require('./common'); + +var baseGetDesc = Entry.prototype.getDesc; + +var lineBreaksRegex = /\n?$/g; + +/** + * Return the `description` of the entry, only without the possible note about mutation. + * + * @returns {Function} Updated description. + */ +function getReorderedExample() { + var lines = baseGetDesc.call(this).split('\n'); + + var indexOfLine = _.findIndex(lines, function(line) { + return _.includes(line, 'mutate'); + }); + + if (indexOfLine === -1) { + return lines.join('\n'); + } + + var linesToDelete = 1; + while (indexOfLine + linesToDelete < lines.length && + !lines[indexOfLine + linesToDelete].startsWith('