deno.land / x / lodash@4.17.19 / lib / main / 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
80
81
82
83
84
'use strict';
const _ = require('lodash');const docdown = require('docdown');const fs = require('fs-extra');const path = require('path');
const util = require('../common/util');
const basePath = path.join(__dirname, '..', '..');const docPath = path.join(basePath, 'doc');const readmePath = path.join(docPath, 'README.md');
const pkg = require('../../package.json');const version = pkg.version;
const config = { 'base': { 'path': path.join(basePath, 'lodash.js'), 'title': `<a href="https://lodash.com/">lodash</a> <span>v${ version }</span>`, 'toc': 'categories', 'url': `https://github.com/lodash/lodash/blob/${ version }/lodash.js` }, 'github': { 'style': 'github', 'sublinks': [npmLink('&#x24C3;', 'See the npm package')] }, 'site': { 'entryLink': '<a href="${entryHref}" class="fa fa-link"></a>', 'sourceLink': '[source](${sourceHref})', 'tocHref': '', 'tocLink': '', 'sublinks': [npmLink('npm package')] }};
/** * Composes a npm link from `text` and optional `title`. * * @private * @param {string} text The link text. * @param {string} [title] The link title. * @returns {string} Returns the composed npm link. */function npmLink(text, title) { return ( '<% if (name == "templateSettings" || !/^(?:methods|properties|seq)$/i.test(category)) {' + 'print(' + '"[' + text + '](https://www.npmjs.com/package/lodash." + name.toLowerCase() + ' + '"' + (title == null ? '' : ' \\"' + title + '\\"') + ')"' + ');' + '} %>' );}
/** * Post-process `markdown` to make adjustments. * * @private * @param {string} markdown The markdown to process. * @returns {string} Returns the processed markdown. */function postprocess(markdown) { // Wrap symbol property identifiers in brackets. return markdown.replace(/\.(Symbol\.(?:[a-z]+[A-Z]?)+)/g, '[$1]');}
/*----------------------------------------------------------------------------*/
/** * Creates the documentation markdown formatted for 'github' or 'site'. * * @private * @param {string} type The format type. */function build(type) { const options = _.defaults({}, config.base, config[type]); const markdown = docdown(options);
fs.writeFile(readmePath, postprocess(markdown), util.pitch);}
build(_.last(process.argv));
lodash

Version Info

Tagged at
3 years ago

External Dependencies

No external dependencies 🎉