Skip to content

Commit df75dbf

Browse files
authored
Update docs (#12)
* Update docs * Update tags.js * Update README.md * Fix test passing, add ignore lock * Add .travis.yml * increase complext test time
1 parent e80f7dc commit df75dbf

File tree

7 files changed

+84
-6
lines changed

7 files changed

+84
-6
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
test/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"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
# bit-docs-tag-demo
2+
3+
Adds a @demo that can point at an iframe.

bit-docs.js

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

33
/**
4-
* @module {function} bit-docs-tag-demo
54
* @parent plugins
5+
* @module {function} bit-docs-tag-demo
6+
* @group bit-docs-tag-demo/tags tags
67
*
78
* @description Provides an `@demo` tag for embedding HTML, CSS, and JS in an iframe.
89
*
910
* @body
1011
*
11-
* TBD
12+
* This plugin registers onto these hooks:
13+
* - `tags`
14+
* - `html`
15+
*
16+
* Registering the `tags` hook adds the [bit-docs-tag-demo/tags/demo] tag.
17+
*
18+
* Registering the `html` hook adds a static JavaScript file used to create
19+
* the tabbed demo widget [bit-docs-tag-demo/demo].
1220
*/
1321
module.exports = function(bitDocs){
1422
var pkg = require("./package.json");
@@ -17,7 +25,10 @@ module.exports = function(bitDocs){
1725
deps[pkg.name] = pkg.version;
1826

1927
bitDocs.register("html", {
20-
dependencies: deps
28+
dependencies: deps,
29+
staticDist: [
30+
path.join(__dirname, "test", "demos")
31+
]
2132
});
2233

2334
bitDocs.register("tags", tags);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"devDependencies": {
2929
"bit-docs-generate-html": "0.5.0-pre.4",
30-
"can-stache": "3.0.20",
30+
"can-stache": "3.7.2",
3131
"express": "^4.15.2",
3232
"mocha": "^3.2.0",
3333
"rimraf": "^2.6.1",

tags.js

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,63 @@
1-
1+
/**
2+
* @parent bit-docs-tag-demo/tags
3+
* @module {bit-docs-process-tags/types/tag} bit-docs-tag-demo/tags/demo @demo
4+
*
5+
* @description Placeholder for an application demo.
6+
*
7+
* @signature `@demo PATH [HEIGHT]`
8+
*
9+
* @codestart javascript
10+
* /**
11+
* * @demo demos/example.html 300
12+
* *|
13+
* @codeend
14+
*
15+
* @param {String} PATH The path to a `.html` file.
16+
*
17+
* @param {Number} [HEIGHT] The height of the html page. If a height is not
18+
* provided, the height is determined as the content of the body.
19+
*
20+
* @body
21+
*
22+
* ## Specifying the HTML and JS source
23+
*
24+
* By default, `@demo` uses the html of the body minus any script tags as the
25+
* HTML source. This can be changed by:
26+
*
27+
* - Adding an element with `id="demo-html"` or
28+
* setting `window.DEMO_HTML` to the source text.
29+
* - Adding `id="demo-source"` to a script tag or
30+
* setting `window.DEMO_SOURCE` to the source JS.
31+
*
32+
* ### Example
33+
*
34+
* An example demo file might look like:
35+
*
36+
* ```html
37+
* <div id="demo-html"><b>Hello world!</b></div>
38+
* <script id="demo-source">
39+
* var div = document.createElement("div");
40+
* div.textContent = "it worked!";
41+
* document.body.appendChild(div);
42+
* </script>
43+
* ```
44+
*
45+
* That gets used like:
46+
*
47+
* ```js
48+
* @@demo demos/example.html
49+
* ```
50+
*
51+
* Which gets translated to:
52+
*
53+
* ```html
54+
* @demo demos/example.html
55+
* ```
56+
*
57+
* And renders like:
58+
*
59+
* @demo demos/example.html
60+
*/
261
exports.demo = {
362
add: function( line, curData, scope, objects, currentWrite ) {
463
var m = line.match(/^\s*@demo\s*([\w\.\/\-\$]*)\s*([\w]*)/)

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ describe('bit-docs-tag-demo', function () {
252252
});
253253

254254
describe('complex', function () {
255-
this.timeout(4000);
255+
this.timeout(8000);
256256

257257
before(function () {
258258
return browser.visit('/test/temp/complex.html');

0 commit comments

Comments
 (0)