|
1 |
| -var tnd = require("bit-docs-type-annotate").typeNameDescription, |
2 |
| - matchTag = /^\s*@(\w+)/, |
3 |
| - distance = require("../lib/distance"), |
4 |
| - _ = require('lodash'); |
| 1 | +var tnd = require("bit-docs-type-annotate").typeNameDescription; |
| 2 | +var matchTag = /^\s*@(\w+)/; |
| 3 | +var distance = require("../lib/distance"); |
| 4 | +var _ = require('lodash'); |
5 | 5 |
|
| 6 | +/** |
| 7 | + * @hide |
| 8 | + * @parent bit-docs-process-tags/tags |
| 9 | + * @module {bit-docs-js/tag} bit-docs-process-tags/tags/_default @_default |
| 10 | + * |
| 11 | + * The default tag behavior when `@TAG` begins a line, but no tag is defined |
| 12 | + * for `TAG`. |
| 13 | + * |
| 14 | + * @signature `@TAG NAME[, ...]` |
| 15 | + * |
| 16 | + * Sets a `TAG` property on the docObject to `"NAME"`. |
| 17 | + * |
| 18 | + * Example: |
| 19 | + * @codestart javascript |
| 20 | + * /** |
| 21 | + * * @@memberOf _ |
| 22 | + * *| |
| 23 | + * findById: function( id, success ) { |
| 24 | + * @codeend |
| 25 | + * |
| 26 | + * This will make the docObject look like: |
| 27 | + * |
| 28 | + * ``` |
| 29 | + * {memberof: "_"} |
| 30 | + * ``` |
| 31 | + * |
| 32 | + * If `NAME` values are separated by comma-space (`, `), the values will be set |
| 33 | + * as an array. Example: |
| 34 | + * |
| 35 | + * @codestart javascript |
| 36 | + * /** |
| 37 | + * * @@memberOf _, lodash |
| 38 | + * *| |
| 39 | + * findById: function( id, success ) { |
| 40 | + * @codeend |
| 41 | + * |
| 42 | + * This will make the docObject look like: |
| 43 | + * |
| 44 | + * ``` |
| 45 | + * {memberof: ["_", "lodash"]} |
| 46 | + * ``` |
| 47 | + * |
| 48 | + * If multiple `@TAG NAME`s are found with the same `TAG`, an array with each |
| 49 | + * `"NAME"` will be created. Example: |
| 50 | + * |
| 51 | + * @codestart javascript |
| 52 | + * /** |
| 53 | + * * @@memberOf _ |
| 54 | + * * @@memberOf lodash |
| 55 | + * *| |
| 56 | + * findById: function( id, success ) { |
| 57 | + * @codeend |
| 58 | + * |
| 59 | + * This will make the docObject look like: |
| 60 | + * |
| 61 | + * ``` |
| 62 | + * {memberof: ["_", "lodash"]} |
| 63 | + * ``` |
| 64 | + * |
| 65 | + * @signature `@TAG` |
| 66 | + * |
| 67 | + * Sets a `TAG` property on the docObject to `true`. |
| 68 | + * |
| 69 | + * @body |
| 70 | + * |
| 71 | + */ |
| 72 | +module.exports = { |
6 | 73 |
|
| 74 | + add: function( line, curData, scope, objects, currentWrite, siteConfig ) { |
7 | 75 |
|
| 76 | + var tag = line.match(matchTag)[1].toLowerCase(), |
| 77 | + value = line.replace(matchTag,"").trim(); |
8 | 78 |
|
9 |
| - /** |
10 |
| - * @constructor documentjs.tags._default @_default |
11 |
| - * @tag documentation |
12 |
| - * @parent documentjs.tags |
13 |
| - * @hide |
14 |
| - * |
15 |
| - * The default tag behavior when `@TAG` begins a line, but no |
16 |
| - * tag is defined for `TAG`. |
17 |
| - * |
18 |
| - * |
19 |
| - * |
20 |
| - * @signature `@TAG NAME[, ...]` |
21 |
| - * |
22 |
| - * Sets a `TAG` property on the docObject to `"NAME"`. |
23 |
| - * |
24 |
| - * Example: |
25 |
| - * @codestart javascript |
26 |
| - * /** |
27 |
| - * * @@memberOf _ |
28 |
| - * *| |
29 |
| - * findById: function( id, success ) { |
30 |
| - * @codeend |
31 |
| - * |
32 |
| - * This will make the docObject look like: |
33 |
| - * |
34 |
| - * ``` |
35 |
| - * {memberof: "_"} |
36 |
| - * ``` |
37 |
| - * |
38 |
| - * If `NAME` values are seperated by comma-space (`, `), the values will be set as an array. Example: |
39 |
| - * |
40 |
| - * |
41 |
| - * |
42 |
| - * @codestart javascript |
43 |
| - * /** |
44 |
| - * * @@memberOf _, lodash |
45 |
| - * *| |
46 |
| - * findById: function( id, success ) { |
47 |
| - * @codeend |
48 |
| - * |
49 |
| - * This will make the docObject look like: |
50 |
| - * |
51 |
| - * ``` |
52 |
| - * {memberof: ["_", "lodash"]} |
53 |
| - * ``` |
54 |
| - * |
55 |
| - * If multiple `@TAG NAME`s are found with the same `TAG`, an array with each |
56 |
| - * `"NAME"` will be created. Example: |
57 |
| - * |
58 |
| - * @codestart javascript |
59 |
| - * /** |
60 |
| - * * @@memberOf _ |
61 |
| - * * @@memberOf lodash |
62 |
| - * *| |
63 |
| - * findById: function( id, success ) { |
64 |
| - * @codeend |
65 |
| - * |
66 |
| - * This will make the docObject look like: |
67 |
| - * |
68 |
| - * ``` |
69 |
| - * {memberof: ["_", "lodash"]} |
70 |
| - * ``` |
71 |
| - * |
72 |
| - * @signature `@TAG` |
73 |
| - * |
74 |
| - * Sets a `TAG` property on the docObject to `true`. |
75 |
| - * |
76 |
| - * @body |
77 |
| - * |
78 |
| - */ |
79 |
| - module.exports = { |
80 |
| - |
81 |
| - add: function( line, curData, scope, objects, currentWrite, siteConfig ) { |
82 |
| - |
83 |
| - var tag = line.match(matchTag)[1].toLowerCase(), |
84 |
| - value = line.replace(matchTag,"").trim(); |
85 |
| - |
86 |
| - if(value.indexOf(", ") >= 0) { |
87 |
| - value = value.split(", ").map(function(val){ |
88 |
| - return val.trim(); |
89 |
| - }); |
90 |
| - } |
91 |
| - if(value && typeof value === "string") { |
92 |
| - value = [value]; |
93 |
| - } |
| 79 | + if(value.indexOf(", ") >= 0) { |
| 80 | + value = value.split(", ").map(function(val){ |
| 81 | + return val.trim(); |
| 82 | + }); |
| 83 | + } |
| 84 | + if(value && typeof value === "string") { |
| 85 | + value = [value]; |
| 86 | + } |
94 | 87 |
|
95 |
| - suggestType(siteConfig.tags, tag, this.line, this.src); |
| 88 | + suggestType(siteConfig.tags, tag, this.line, this.src); |
96 | 89 |
|
97 |
| - if(value) { |
98 |
| - if( Array.isArray(this[tag]) ){ |
99 |
| - this[tag].push.apply(this[tag], value); |
100 |
| - } else if( this[tag] && tag != "name"){ |
101 |
| - this[tag] = [this[tag]].concat(value); |
102 |
| - } else { |
103 |
| - this[tag] = value.length > 1 ? value : value[0]; |
104 |
| - } |
| 90 | + if(value) { |
| 91 | + if( Array.isArray(this[tag]) ){ |
| 92 | + this[tag].push.apply(this[tag], value); |
| 93 | + } else if( this[tag] && tag != "name"){ |
| 94 | + this[tag] = [this[tag]].concat(value); |
105 | 95 | } else {
|
106 |
| - this[tag] = true; |
| 96 | + this[tag] = value.length > 1 ? value : value[0]; |
107 | 97 | }
|
108 |
| - |
| 98 | + } else { |
| 99 | + this[tag] = true; |
109 | 100 | }
|
110 |
| - }; |
111 | 101 |
|
| 102 | + } |
| 103 | +}; |
112 | 104 |
|
113 | 105 | function suggestType(tags, incorrect, line, src ) {
|
114 | 106 | var lowest = 1000,
|
|
0 commit comments