Skip to content

Commit b7dc96a

Browse files
authored
Merge pull request #7 from bit-docs/docs
Update docs
2 parents 2445c0b + c1b5d51 commit b7dc96a

File tree

5 files changed

+74
-3
lines changed

5 files changed

+74
-3
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/

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
node_js: node
3+
before_install:
4+
- "export DISPLAY=:99.0"
5+
- "sh -e /etc/init.d/xvfb start"

bit-docs.js

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

33
/**
4-
* @module {function} bit-docs-html-highlight-line
54
* @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
68
*
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].
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
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].
1222
*/
1323
module.exports = function(bitDocs){
1424
var pkg = require("./package.json");

highlight-line.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ var getLines = function(lineString) {
2828
return result;
2929
};
3030

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+
*/
3150
function addHighlights() {
3251

3352
$('span[line-highlight]').each(function(i, el) {

tags.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
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+
*/
137
exports.highlight = {
238
add: function(line, curData) {
339
var lines = line.replace("@highlight","").trim();

0 commit comments

Comments
 (0)