File tree Expand file tree Collapse file tree 5 files changed +74
-3
lines changed Expand file tree Collapse file tree 5 files changed +74
-3
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
+ language : node_js
2
+ node_js : node
3
+ before_install :
4
+ - " export DISPLAY=:99.0"
5
+ - " sh -e /etc/init.d/xvfb start"
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-highlight-line
5
4
* @parent plugins
5
+ * @module {function} bit-docs-html-highlight-line
6
+ * @group bit-docs-html-highlight-line/tags tags
7
+ * @group bit-docs-html-highlight-line/static static
6
8
*
7
- * @description Adds a `@highlight` tag. Needs to be used after ` bit-docs-prettify` .
9
+ * @description Adds a `@highlight` tag. Needs to be used after [ bit-docs-prettify] .
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
18
+ * [bit-docs-html-highlight-line/tags/highlight] tag.
19
+ *
20
+ * Registering the `html` hook adds a static JavaScript file used to do the
21
+ * highlighting [bit-docs-html-highlight-line/highlight-line.js].
12
22
*/
13
23
module . exports = function ( bitDocs ) {
14
24
var pkg = require ( "./package.json" ) ;
Original file line number Diff line number Diff line change @@ -28,6 +28,25 @@ var getLines = function(lineString) {
28
28
return result ;
29
29
} ;
30
30
31
+ /**
32
+ * @parent bit-docs-html-highlight-line/static
33
+ * @module {function} bit-docs-html-highlight-line/highlight-line.js
34
+ *
35
+ * Main front end JavaScript file for static portion of this plugin.
36
+ *
37
+ * @signature `addHighlights()`
38
+ *
39
+ * Goes through the lines in a `<code>` block and highlights the specified
40
+ * ranges.
41
+ *
42
+ * Finds all `<span highlight-line="..."></span>` elements and uses those as
43
+ * directives for what to highlight.
44
+ *
45
+ * If the `only` option was specified to the
46
+ * [bit-docs-html-highlight-line/tags/highlight] tag, then non-highlighted
47
+ * lines will be collapsed if they exist greater than three lines away from a
48
+ * highlighted line.
49
+ */
31
50
function addHighlights ( ) {
32
51
33
52
$ ( 'span[line-highlight]' ) . each ( function ( i , el ) {
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @parent bit-docs-html-highlight-line/tags
3
+ * @module {bit-docs-process-tags/types/tag} bit-docs-html-highlight-line/tags/highlight @highlight
4
+ *
5
+ * Highlight the specified code lines.
6
+ *
7
+ * @signature `@highlight LINES[,ONLY]`
8
+ *
9
+ * @param {String } LINES The lines to highlight like `2-4`.
10
+ *
11
+ * @param {String } [,ONLY] Collapse non-highlighted lines greater than three
12
+ * lines away (useful for long code snippets).
13
+ *
14
+ * @codestart javascript
15
+ * /**
16
+ * * ```js
17
+ * * {
18
+ * * "name": "bit-docs",
19
+ * * "description": "Documentation generator",
20
+ * * "author": "Bitovi",
21
+ * * "license": "MIT",
22
+ * * "date": "2017",
23
+ * * "location": "Chicago",
24
+ * * "season": "Summer",
25
+ * * "awesome": "yes"
26
+ * * }
27
+ * * ```
28
+ * *
29
+ * * @highlight 2-4,only
30
+ * *|
31
+ * @codeend
32
+ *
33
+ * Injects a `<span line-highlight="2-4,only"></span>` element to the page that
34
+ * will be picked up and used by the static front-end script
35
+ * [bit-docs-html-highlight-line/highlight-line.js].
36
+ */
1
37
exports . highlight = {
2
38
add : function ( line , curData ) {
3
39
var lines = line . replace ( "@highlight" , "" ) . trim ( ) ;
You can’t perform that action at this time.
0 commit comments