File tree Expand file tree Collapse file tree 4 files changed +48
-22
lines changed Expand file tree Collapse file tree 4 files changed +48
-22
lines changed Original file line number Diff line number Diff line change
1
+ package-lock.json
1
2
node_modules /
2
3
temp /
Original file line number Diff line number Diff line change 1
1
var tags = require ( "./tags" ) ;
2
2
3
3
/**
4
- * @module {function} bit-docs-html-toc
5
4
* @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
6
8
*
7
9
* @description Injects a table of contents for the page into an HTML element.
8
10
*
9
11
* @body
10
12
*
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].
12
21
*/
13
22
module . exports = function ( bitDocs ) {
14
23
var pkg = require ( "./package.json" ) ;
Original file line number Diff line number Diff line change 1
1
/**
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
4
4
*
5
- * @description
6
- *
7
- * Controls the outline behavior.
5
+ * @description Controls the outline behavior.
8
6
*
9
7
* @signature `@outline DEPTH TAG`
10
8
*
11
9
* Controls the outline's depth and type.
12
10
*
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.
15
13
*
16
14
* @param {String } [TAG="ul"] Make the list an ordered list.
17
15
*
18
16
* @body
19
17
*
20
18
*/
21
19
exports . outline = {
22
- add : function ( line , curData , scope , docMap ) {
23
- var m = line . match ( / @ o u t l i n e \s + ( \d + ) (?: \s + ( o l | u l ) ) ? / ) ;
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 ( / @ o u t l i n e \s + ( \d + ) (?: \s + ( o l | u l ) ) ? / ) ;
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 ] ;
34
31
}
35
32
}
36
- } ;
33
+ }
34
+ } ;
Original file line number Diff line number Diff line change
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
+ */
1
19
var TOCContainer = require ( "./toc-container-control" ) ;
2
20
3
21
var el = document . getElementsByClassName ( "on-this-page-container" ) ;
You can’t perform that action at this time.
0 commit comments