|
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 | + */ |
2 | 61 | exports.demo = { |
3 | 62 | add: function( line, curData, scope, objects, currentWrite ) { |
4 | 63 | var m = line.match(/^\s*@demo\s*([\w\.\/\-\$]*)\s*([\w]*)/) |
|
0 commit comments