-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbit-docs.js
67 lines (63 loc) · 2.16 KB
/
bit-docs.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
var generator = require("./html");
var _ = require("lodash");
var tags = require("./tags/tags");
var mergeOnto = function(prop, dest, source){
if(!dest[prop]) {
dest[prop] = [];
}
if(source[prop]) {
dest[prop] = dest[prop].concat(source[prop]);
}
};
/**
* @parent plugins
* @module {function} bit-docs-generate-html
* @group bit-docs-generate-html/modules modules
* @group bit-docs-generate-html/static static
* @group bit-docs-generate-html/templates templates
* @group bit-docs-generate-html/generated generated
* @group bit-docs-generate-html/types types
*
* @description Generates HTML for a docMap and handles the `html` hook.
*
* @body
*
* This plugin registers onto these hooks:
* - `tags`
* - `generator`
*
* Registering the `tags` hook adds the `@templaterender` tag.
*
* Registering the `generator` hook makes it so this plugin can generate the
* HTML output from the provided [bit-docs/types/docMap]. The entry point for
* this generator is [bit-docs-generate-html/html].
*
* This plugin handles the `html` hook, which allows other plugins to hook into
* the generation process, to do things like include their own static assets,
* or provide their own mustache templates.
*
* This plugin provides a default set of mustache templates and static assets.
* These mustache templates and less styles can be copied over into a theme
* plugin and customized. Any custom mustache template will override a default
* of the same name.
*/
module.exports = function(bitDocs){
bitDocs.register("generator", generator);
bitDocs.register("tags", tags);
bitDocs.handle("html", function(siteConfig, htmlConfig) {
if(!siteConfig.html) {
siteConfig.html = {};
}
_.defaultsDeep(siteConfig.html, {
dependencies: {},
static: [],
templates: [],
staticDist: []
});
var html = siteConfig.html;
_.assign(html.dependencies, htmlConfig.dependencies || {});
mergeOnto("staticDist", html, htmlConfig);
mergeOnto("static", html, htmlConfig);
mergeOnto("templates", html, htmlConfig);
});
};