|
| 1 | +/** |
| 2 | + * @parent bit-docs-js/modules |
| 3 | + * @module {bit-docs-process-tags/types/tag} bit-docs-js/tags/codeend |
| 4 | + * |
| 5 | + * @description Use this module to add the [bit-docs-js/tag/codeend] tag. |
| 6 | + * |
| 7 | + * @signature `require('./tags/codeend');` |
| 8 | + * |
| 9 | + * @return {bit-docs-process-tags/types/tag} Tag object configured for the |
| 10 | + * [bit-docs-js/tag/codeend] tag. |
| 11 | + * |
| 12 | + * @body |
| 13 | + */ |
| 14 | +module.exports = { |
1 | 15 | /**
|
2 |
| - * @hide |
3 |
| - * @parent bit-docs-js/tags |
4 |
| - * @module {bit-docs/types/tag} bit-docs-js/tags/codeend @codeend |
| 16 | + * @signature `add(line, data)` |
5 | 17 | *
|
6 |
| - * @description |
| 18 | + * [bit-docs-process-tags/types/tag.add] for [bit-docs-js/tag/codeend]. |
7 | 19 | *
|
8 |
| - * Stops a code block. |
| 20 | + * @param {String} line Text from [bit-docs-js/tag/codeend] until the end |
| 21 | + * of line. |
9 | 22 | *
|
10 |
| - * ### Example: |
| 23 | + * For example: |
11 | 24 | *
|
12 |
| - * @codestart |
13 |
| - * |
14 |
| - * /* |
15 |
| - * * @codestart |
16 |
| - * * /* @class |
17 |
| - * * * Person represents a human with a name. Read about the |
18 |
| - * * * animal class [Animal | here]. |
19 |
| - * * * @constructor |
20 |
| - * * * You must pass in a name. |
21 |
| - * * * @param {String} name A person's name |
22 |
| - * * *| |
23 |
| - * * Person = function(name){ |
24 |
| - * * this.name = name |
25 |
| - * * Person.count ++; |
26 |
| - * * } |
27 |
| - * * /* @Static *| |
28 |
| - * * steal.Object.extend(Person, { |
29 |
| - * * /* Number of People *| |
30 |
| - * * count: 0 |
31 |
| - * * }) |
32 |
| - * * /* @Prototype *| |
33 |
| - * * Person.prototype = { |
34 |
| - * * /* Returns a formal name |
35 |
| - * * * @return {String} the name with "Mrs." added |
36 |
| - * * *| |
37 |
| - * * fancyName : function(){ |
38 |
| - * * return "Mrs. "+this.name; |
39 |
| - * * } |
40 |
| - * * } |
41 |
| - * * @codeend |
42 |
| - * *| |
43 |
| - * |
44 |
| - * @codeend |
| 25 | + * @codestart javascript |
| 26 | + * @@codeend |
| 27 | + * @codeend |
| 28 | + * |
| 29 | + * @param {Object} curData Custom data object hydrated by [bit-docs-js/tags/codestart]. |
| 30 | + * |
| 31 | + * For example: |
| 32 | + * |
| 33 | + * ```js |
| 34 | + * { |
| 35 | + * type: 'javascript', |
| 36 | + * lines: ['/**', ' * @demo demos/example.html 300', ' *|'], |
| 37 | + * last: { |
| 38 | + * code: '@demo PATH [HEIGHT]', |
| 39 | + * description: '\n', |
| 40 | + * params: [] |
| 41 | + * }, |
| 42 | + * _last: undefined |
| 43 | + * } |
| 44 | + * ``` |
| 45 | + * |
| 46 | + * @return {bit-docs-process-tags/types/processTagsCommand} `['poppop', '...']`. |
| 47 | + * |
| 48 | + * For example: |
| 49 | + * |
| 50 | + * @codestart javascript |
| 51 | + * [ |
| 52 | + * 'poppop', |
| 53 | + * '```javascript\n/**\n * @demo demos/example.html 300\n *|\n```' |
| 54 | + * ] |
| 55 | + * @codeend |
45 | 56 | */
|
46 |
| - module.exports = { |
47 |
| - add: function( line, data ) { |
| 57 | + add: function( line, data ) { |
| 58 | + if (!data.lines ) { |
| 59 | + console.warn('you probably have a @codeend without a @codestart') |
| 60 | + } |
48 | 61 |
|
49 |
| - if (!data.lines ) { |
50 |
| - console.warn('you probably have a @codeend without a @codestart') |
51 |
| - } |
| 62 | + var joined = data.lines.join("\n"); |
52 | 63 |
|
53 |
| - var joined = data.lines.join("\n"); |
| 64 | + if ( data.type == "javascript" || data.type == "js") { //convert comments |
| 65 | + joined = joined.replace(/\*\|/g, "*/") |
| 66 | + } |
54 | 67 |
|
55 |
| - if ( data.type == "javascript" || data.type == "js") { //convert comments |
56 |
| - joined = joined.replace(/\*\|/g, "*/") |
57 |
| - } |
58 |
| - var out = "```" + data.type + "\n" |
59 |
| - + joined.replace(/</g,"<") |
60 |
| - .replace(/>/g,">") |
61 |
| - .replace(/&/g,"&") + |
| 68 | + var out = "```" + data.type + "\n" |
| 69 | + + joined.replace(/</g,"<") |
| 70 | + .replace(/>/g,">") |
| 71 | + .replace(/&/g,"&") + |
62 | 72 | "\n```";
|
63 | 73 |
|
64 |
| - return ["poppop", out]; |
65 |
| - }, |
66 |
| - keepStack: true |
67 |
| - }; |
| 74 | + return ["poppop", out]; |
| 75 | + }, |
| 76 | + /** |
| 77 | + * @property {Boolean} keepStack |
| 78 | + * |
| 79 | + * [bit-docs-process-tags/types/tag.keepStack] set `true` for |
| 80 | + * [bit-docs-js/tag/codeend]. |
| 81 | + */ |
| 82 | + keepStack: true |
| 83 | +}; |
0 commit comments