deno.land / x / lodash@4.17.19 / lib / fp / build-doc.js

نووسراو ببینە
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'use strict';
const _ = require('lodash');const fs = require('fs-extra');const path = require('path');
const file = require('../common/file');const mapping = require('../common/mapping');const util = require('../common/util');
const templatePath = path.join(__dirname, 'template/doc');const template = file.globTemplate(path.join(templatePath, '*.jst'));
const argNames = ['a', 'b', 'c', 'd'];
const templateData = { mapping, toArgOrder, toFuncList};
/** * Converts arranged argument `indexes` into a named argument string * representation of their order. * * @private * @param {number[]} indexes The arranged argument indexes. * @returns {string} Returns the named argument string. */function toArgOrder(indexes) { const reordered = []; _.each(indexes, (newIndex, index) => { reordered[newIndex] = argNames[index]; }); return '`(' + reordered.join(', ') + ')`';}
/** * Converts `funcNames` into a chunked list string representation. * * @private * @param {string[]} funcNames The function names. * @returns {string} Returns the function list string. */function toFuncList(funcNames) { let chunks = _.chunk(funcNames.slice().sort(), 5); let lastChunk = _.last(chunks); const lastName = lastChunk ? lastChunk.pop() : undefined;
chunks = _.reject(chunks, _.isEmpty); lastChunk = _.last(chunks);
let result = '`' + _.map(chunks, chunk => chunk.join('`, `') + '`').join(',\n`'); if (lastName == null) { return result; } if (_.size(chunks) > 1 || _.size(lastChunk) > 1) { result += ','; } result += ' &'; result += _.size(lastChunk) < 5 ? ' ' : '\n'; return result + '`' + lastName + '`';}
/*----------------------------------------------------------------------------*/
/** * Creates the FP-Guide wiki at the `target` path. * * @private * @param {string} target The output file path. */function build(target) { target = path.resolve(target); fs.writeFile(target, template.wiki(templateData), util.pitch);}
build(_.last(process.argv));
lodash

Version Info

Tagged at
3 years ago

External Dependencies

No external dependencies 🎉