Skip to content

Commit a095f73

Browse files
authored
Merge pull request #38 from bit-docs/docs
Document stuff in /build
2 parents 7104748 + 9ac1e31 commit a095f73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1414
-521
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package-lock.json
12
node_modules
23
site/static/
34
site/static/build/

bit-docs.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,41 @@ var mergeOnto = function(prop, dest, source){
1212
};
1313

1414
/**
15+
* @parent plugins
1516
* @module {function} bit-docs-generate-html
1617
* @group bit-docs-generate-html/modules modules
17-
* @parent plugins
18+
* @group bit-docs-generate-html/static static
19+
* @group bit-docs-generate-html/templates templates
20+
* @group bit-docs-generate-html/generated generated
21+
* @group bit-docs-generate-html/types types
1822
*
19-
* @description Generates HTML for a docMap. Supports plugins.
23+
* @description Generates HTML for a docMap and handles the `html` hook.
2024
*
2125
* @body
2226
*
23-
* TBD
27+
* This plugin registers onto these hooks:
28+
* - `tags`
29+
* - `generator`
30+
*
31+
* Registering the `tags` hook adds the `@templaterender` tag.
32+
*
33+
* Registering the `generator` hook makes it so this plugin can generate the
34+
* HTML output from the provided [bit-docs/types/docMap]. The entry point for
35+
* this generator is [bit-docs-generate-html/html].
36+
*
37+
* This plugin handles the `html` hook, which allows other plugins to hook into
38+
* the generation process, to do things like include their own static assets,
39+
* or provide their own mustache templates.
40+
*
41+
* This plugin provides a default set of mustache templates and static assets.
42+
* These mustache templates and less styles can be copied over into a theme
43+
* plugin and customized. Any custom mustache template will override a default
44+
* of the same name.
2445
*/
25-
2646
module.exports = function(bitDocs){
2747
bitDocs.register("generator", generator);
2848

29-
bitDocs.register("tags", tags);
49+
bitDocs.register("tags", tags);
3050

3151
bitDocs.handle("html", function(siteConfig, htmlConfig) {
3252
if(!siteConfig.html) {
@@ -42,5 +62,5 @@ module.exports = function(bitDocs){
4262
mergeOnto("staticDist", html, htmlConfig);
4363
mergeOnto("static", html, htmlConfig);
4464
mergeOnto("templates", html, htmlConfig);
45-
});
65+
});
4666
};

build/build.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
/**
2-
* @property {{}} documentjs.generators.html.build
3-
* @parent documentjs.generators.html.properties
2+
* @parent bit-docs-generate-html/modules
3+
* @module {{}} bit-docs-generate-html/build/build
44
*
5-
* @group documentjs.generators.html.build.methods 0 methods
6-
* @group documentjs.generators.html.build.types 1 types
7-
*
8-
* A collection of helpers used to build and compile the templates
9-
* used to render each [documentjs.process.docObject docObject] into
10-
* HTML and build the static JS and CSS used by that HTML.
5+
* A collection of helpers used to build and compile the templates used to
6+
* render each [bit-docs/types/docObject] into HTML and build the static JS and
7+
* CSS used by that HTML.
118
*
129
* @body
1310
*
11+
* Requires and exports these other modules:
12+
* - [bit-docs-generate-html/build/renderer] as `renderer`.
13+
* - [bit-docs-generate-html/build/static_dist] as `staticDist`.
14+
* - [bit-docs-generate-html/build/templates] as `templates`.
15+
* - [bit-docs-generate-html/build/helpers] as `helpers`.
1416
*/
15-
16-
17-
1817
exports.renderer = require("./renderer");
1918
exports.staticDist = require("./static_dist");
2019
exports.templates = require("./templates");
21-
exports.helpers = require("./helpers");
20+
exports.helpers = require("./helpers");

build/build_hash.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
var md5 = require('md5');
22

33
/**
4-
* @function documentjs.generators.html.build.buildHash
5-
* @parent documentjs.generators.html.build.methods
4+
* @parent bit-docs-generate-html/modules
5+
* @module {function} bit-docs-generate-html/build/build_hash
66
*
77
* Returns a unique hash for the options that control the build.
88
*
9-
* @signature `.build.buildHash(options)`
9+
* @signature `buildHash(options)`
1010
*
1111
* @param {{}} options Options that might change the characteristic of the build:
1212
*
13-
* @option {Boolean} [minifyBuild=true] If set to `false` the build will not
14-
* be minified. This behavior should be implemented by the "build" module.
13+
* @option {Boolean} [minifyBuild=true] If set to `false` the build will not be
14+
* minified. This behavior should be implemented by the "build" module.
15+
*
16+
* @option {Boolean} [devBuild=false] If set to `true` the build will not be
17+
* built and copied in "development" mode.
18+
*
19+
* @option {String} static The location of static content used to overwrite or
20+
* add to the default static content.
21+
*
22+
* @option {String} [templates] The location of templates used to overwrite or
23+
* add to the default templates.
1524
*
16-
* @option {Boolean} [devBuild=false] If set to `true` the build will not be built
17-
* and copied in "development" mode.
18-
*
19-
* @option {String} static The location of static content used to overwrite or
20-
* add to the default static content.
21-
*
22-
* @option {String} [templates] The location of templates used to overwrite or
23-
* add to the default templates.
25+
* @return {String} a hash that represents this build.
2426
*
27+
* @body
2528
*
26-
* @return {String} a hash that represents this build.
29+
* The generated hash will be something like `917c51373c902dc4a003c7fd949774c5`.
2730
*/
2831
module.exports = function(options){
2932
var values = {};

build/builder.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

build/helpers.js

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
1-
2-
var getDefaultHelpers = require("./make_default_helpers"),
3-
_ = require("lodash");
1+
var getDefaultHelpers = require("./make_default_helpers");
2+
var _ = require("lodash");
43
var fsx = require('../fs_extras');
54
var path = require('path');
65
var md5 = require("md5");
7-
var Handlebars = require("handlebars"),
8-
buildHash = require("./build_hash");
6+
var Handlebars = require("handlebars");
7+
var buildHash = require("./build_hash");
8+
99
/**
10-
* @function documentjs.generators.html.build.helpers
11-
* @parent documentjs.generators.html.build.methods
12-
*
13-
* Gets the default helpers and helpers in the _documentjs/site/templates_ folder and
14-
* registers them with Handlebars.
10+
* @parent bit-docs-generate-html/modules
11+
* @module {Promise} bit-docs-generate-html/build/helpers
1512
*
16-
* @signature `.build.helpers(buildTemplatesPromise, docMap, options, getCurrent)`
13+
* Gets the default helpers, and helpers in the
14+
* [bit-docs-generate-html/site/templates/buildHash] folder, and registers them
15+
* with Handlebars.
16+
*
17+
* @signature `build.helpers(buildTemplatesPromise, docMap, options, getCurrent)`
1718
*
1819
* Registers helpers
1920
*
20-
*
2121
* @param {Promise<Handlebars>} buildTemplatesPromise The result of calling
22-
* [documentjs.generators.html.build.templates]. Building the helpers
23-
* must happen after the templates have been copied over. Passing this
24-
* argument enforces that.
22+
* [bit-docs-generate-html/build/templates]. Building the helpers must happen
23+
* after the templates have been copied over. Passing this argument enforces
24+
* that.
2525
*
26-
* @param {documentjs.process.docMap} docMap The docMap which contains all
27-
* docObjects that will be documented.
26+
* @param {bit-docs/types/docMap} docMap The [bit-docs/types/docMap] which
27+
* contains all [bit-docs/types/docObject]s that will be documented.
2828
*
2929
* @param {Object} options
3030
*
31+
* @param {function():bit-docs/types/docObject} getCurrent
3132
*
32-
* @param {function():documentjs.process.docObject} getCurrent
33-
*
34-
* A function that when called, returns the `docObject` currently being
35-
* generated.
33+
* A function that when called, returns the [bit-docs/types/docObject]
34+
* currently being generated.
3635
*
37-
* @return {Promise} A promise that resolves when helpers have been added to Handlebars.
36+
* @return {Promise} A promise that resolves when helpers have been added to
37+
* Handlebars.
3838
*
3939
* @body
40-
*
4140
*/
4241
module.exports = function(buildTemplatesPromise, docMap, options, getCurrent){
4342

4443
return buildTemplatesPromise.then(function(OtherHandlebars){
45-
// get the default heleprs
44+
// get the default helpers
4645
var helpers = getDefaultHelpers(docMap,options,getCurrent, OtherHandlebars);
4746

4847
var templatesPath = path.join('site/templates', buildHash(options) );
@@ -73,8 +72,4 @@ module.exports = function(buildTemplatesPromise, docMap, options, getCurrent){
7372

7473
});
7574

76-
77-
78-
79-
8075
};

0 commit comments

Comments
 (0)