summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE/client/bower_components/lodash/lib/main/build-doc.js
blob: 6c5f22b577774863f419b4466e2035851d1023c0 (plain)
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
'use strict';

var _ = require('lodash'),
    docdown = require('docdown'),
    fs = require('fs-extra'),
    path = require('path');

var basePath = path.join(__dirname, '..', '..'),
    docPath = path.join(basePath, 'doc'),
    readmePath = path.join(docPath, 'README.md');

var pkg = require('../../package.json'),
    version = pkg.version;

var config = {
  'base': {
    'entryLinks': [
      '<% if (name == "templateSettings" || !/^(?:methods|properties|seq)$/i.test(category)) {' +
      'print("[&#x24C3;](https://www.npmjs.com/package/lodash." + name.toLowerCase() + " \\"See the npm package\\")")' +
      '} %>'
    ],
    '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': {
    'hash': 'github'
  },
  'site': {
    'tocLink': '#docs'
  }
};

function postprocess(string) {
  // Wrap symbol property identifiers in brackets.
  return string.replace(/\.(Symbol\.(?:[a-z]+[A-Z]?)+)/g, '[$1]');
}

/*----------------------------------------------------------------------------*/

function onComplete(error) {
  if (error) {
    throw error;
  }
}

function build(type) {
  var options = _.defaults({}, config.base, config[type]),
      markdown = docdown(options);

  fs.writeFile(readmePath, postprocess(markdown), onComplete);
}

build(_.last(process.argv));