Skip to content

Commit b9aba53

Browse files
authored
Merge pull request #24 from bit-docs/docs
Update docs
2 parents 9a25ccd + 58af048 commit b9aba53

File tree

4 files changed

+48
-22
lines changed

4 files changed

+48
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
package-lock.json
12
node_modules/
23
temp/

bit-docs.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
var tags = require("./tags");
22

33
/**
4-
* @module {function} bit-docs-html-toc
54
* @parent plugins
5+
* @module {function} bit-docs-html-toc
6+
* @group bit-docs-html-toc/tags tags
7+
* @group bit-docs-html-toc/static static
68
*
79
* @description Injects a table of contents for the page into an HTML element.
810
*
911
* @body
1012
*
11-
* TBD
13+
* This plugin registers onto these hooks:
14+
* - `tags`
15+
* - `html`
16+
*
17+
* Registering the `tags` hook adds the [bit-docs-html-toc/tags/outline] tag.
18+
*
19+
* Registering the `html` hook adds a static JavaScript file used to hydrate
20+
* the table of contents [bit-docs-html-toc/toc.js].
1221
*/
1322
module.exports = function(bitDocs) {
1423
var pkg = require("./package.json");

tags.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
11
/**
2-
* @constructor documentjs.tags.outline @outline
3-
* @parent documentjs.tags
2+
* @parent bit-docs-html-toc/tags
3+
* @module {bit-docs-process-tags/types/tag} bit-docs-html-toc/tags/outline @outline
44
*
5-
* @description
6-
*
7-
* Controls the outline behavior.
5+
* @description Controls the outline behavior.
86
*
97
* @signature `@outline DEPTH TAG`
108
*
119
* Controls the outline's depth and type.
1210
*
13-
* @param {Number} [DEPTH=1] The number of headers below and including h2. For example,
14-
* `2` will include `h2` and `h3` elements.
11+
* @param {Number} [DEPTH=1] The number of headers below and including h2. For
12+
* example, `2` will include `h2` and `h3` elements.
1513
*
1614
* @param {String} [TAG="ul"] Make the list an ordered list.
1715
*
1816
* @body
1917
*
2018
*/
2119
exports.outline = {
22-
add: function (line, curData, scope, docMap) {
23-
var m = line.match(/@outline\s+(\d+)(?:\s+(ol|ul))?/);
24-
if(m) {
25-
if(!this.outline) {
26-
this.outline = {};
27-
}
28-
if(m[1]) {
29-
this.outline.depth = +m[1];
30-
}
31-
if(m[2]) {
32-
this.outline.tag = m[2];
33-
}
20+
add: function (line, curData, scope, docMap) {
21+
var m = line.match(/@outline\s+(\d+)(?:\s+(ol|ul))?/);
22+
if(m) {
23+
if(!this.outline) {
24+
this.outline = {};
25+
}
26+
if(m[1]) {
27+
this.outline.depth = +m[1];
28+
}
29+
if(m[2]) {
30+
this.outline.tag = m[2];
3431
}
3532
}
36-
};
33+
}
34+
};

toc.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/**
2+
* @parent bit-docs-html-toc/static
3+
* @module {function} bit-docs-html-toc/toc.js
4+
*
5+
* Main front end JavaScript file for static portion of this plugin.
6+
*
7+
* @signature `TOCContainer(el)`
8+
*
9+
* Hydrates the container element with class `on-this-page-container` with the
10+
* headers from the page.
11+
*
12+
* If `DEPTH` was specified to the [bit-docs-html-toc/tags/outline] tag, then
13+
* only headers less than and including that depth will be hydrated.
14+
*
15+
* @param {HTMLElement} el The HTML element to hydrate.
16+
*
17+
* @body
18+
*/
119
var TOCContainer = require("./toc-container-control");
220

321
var el = document.getElementsByClassName("on-this-page-container");

0 commit comments

Comments
 (0)