1
- var _ = require ( "lodash" ) ,
2
- path = require ( "path" ) ,
3
- stmd_to_html = require ( "../stmd_to_html" ) ,
4
- deepExtendWithoutBody = require ( "./deep_extend_without_body" ) ,
5
- escape = require ( 'escape-html' ) ,
6
- striptags = require ( 'striptags' ) ,
7
- DocMapInfo = require ( "../doc-map-info" ) ,
8
- unescapeHTML = require ( "unescape-html" ) ;
9
- // Helper helpers
10
-
1
+ var _ = require ( "lodash" ) ;
2
+ var path = require ( "path" ) ;
3
+ var stmd_to_html = require ( "../stmd_to_html" ) ;
4
+ var deepExtendWithoutBody = require ( "./deep_extend_without_body" ) ;
5
+ var escape = require ( 'escape-html' ) ;
6
+ var striptags = require ( 'striptags' ) ;
7
+ var DocMapInfo = require ( "../doc-map-info" ) ;
8
+ var unescapeHTML = require ( "unescape-html" ) ;
11
9
10
+ // Helper helpers
12
11
13
- var sortChildren = function ( child1 , child2 ) {
14
-
12
+ var sortChildren = function ( child1 , child2 ) {
15
13
if ( typeof child1 . order == "number" ) {
16
14
if ( typeof child2 . order == "number" ) {
17
15
// same order given?
@@ -24,7 +22,6 @@ var sortChildren = function(child1, child2){
24
22
} else {
25
23
return child1 . order - child2 . order ;
26
24
}
27
-
28
25
} else {
29
26
return - 1 ;
30
27
}
@@ -43,15 +40,15 @@ var sortChildren = function(child1, child2){
43
40
44
41
var docsFilename = require ( "../write/filename" ) ;
45
42
46
- var linksRegExp = / [ \[ ] ( .* ?) \] / g,
47
- linkRegExp = / ^ ( \S + ) \s * ( .* ) / ,
48
- httpRegExp = / ^ h t t p / ;
43
+ var linksRegExp = / [ \[ ] ( .* ?) \] / g;
44
+ var linkRegExp = / ^ ( \S + ) \s * ( .* ) / ;
45
+ var httpRegExp = / ^ h t t p / ;
49
46
50
47
/**
51
- * @add documentjs.generators.html.defaultHelpers
52
- */
48
+ * @parent bit-docs-generate-html/templates
49
+ * @module {function} bit-docs-generate-html/build/make_default_helpers
50
+ */
53
51
module . exports = function ( docMap , config , getCurrent , Handlebars ) {
54
-
55
52
var docMapInfo = new DocMapInfo ( docMap , getCurrent ) ;
56
53
57
54
var urlTo = function ( name ) {
@@ -153,9 +150,10 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
153
150
} ,
154
151
155
152
// GENERIC HELPERS
153
+
156
154
/**
157
- * @function documentjs.generators. html.defaultHelpers. ifEqual
158
- */
155
+ * @function bit-docs-generate- html/build/make_default_helpers.ifEqual ifEqual
156
+ */
159
157
ifEqual : function ( first , second , options ) {
160
158
if ( first == second ) {
161
159
return options . fn ( this ) ;
@@ -164,8 +162,8 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
164
162
}
165
163
} ,
166
164
/**
167
- * @function documentjs.generators. html.defaultHelpers. ifAny
168
- */
165
+ * @function bit-docs-generate- html/build/make_default_helpers.ifAny ifAny
166
+ */
169
167
ifAny : function ( ) {
170
168
var last = arguments . length - 1 ,
171
169
options = arguments [ last ] ;
@@ -177,16 +175,15 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
177
175
return options . inverse ( this ) ;
178
176
} ,
179
177
/**
180
- * @function documentjs.generators. html.defaultHelpers. ifNotEqual
181
- */
178
+ * @function bit-docs-generate- html/build/make_default_helpers.ifNotEqual ifNotEqual
179
+ */
182
180
ifNotEqual : function ( first , second , options ) {
183
181
if ( first !== second ) {
184
182
return options . fn ( this ) ;
185
183
} else {
186
184
return options . inverse ( this ) ;
187
185
}
188
186
} ,
189
-
190
187
config : function ( ) {
191
188
var configCopy = { } ;
192
189
for ( var prop in config ) {
@@ -196,28 +193,29 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
196
193
}
197
194
return JSON . stringify ( configCopy ) ;
198
195
} ,
199
-
200
196
/**
201
- * @function documentjs.generators. html.defaultHelpers. generatedWarning
197
+ * @function bit-docs-generate- html/build/make_default_helpers.generatedWarning generatedWarning
202
198
* @signature `{{{generatedWarning}}}`
203
199
*
204
200
* @body
205
201
*
206
202
* ## Use
203
+ *
207
204
* ```
208
205
* {{{generatedWarning}}}
209
206
* ```
207
+ *
210
208
* MUST use triple-braces to escape HTML so it is hidden in a comment.
211
209
*
212
210
* Creates a warning that looks like this:
213
211
*
214
- * ```
212
+ * ```html
215
213
* <!--####################################################################
216
214
* THIS IS A GENERATED FILE -- ANY CHANGES MADE WILL BE OVERWRITTEN
217
215
*
218
216
* INSTEAD CHANGE:
219
- * source: lib/tags/iframe .js
220
- * @@constructor documentjs.tags.iframe
217
+ * source: docs/modules/bit-docs-tag-demo/bit-docs .js
218
+ * @@module bit-docs-tag-demo
221
219
* ######################################################################## -->
222
220
* ```
223
221
*/
@@ -231,10 +229,11 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
231
229
"\n######################################################################## -->" ;
232
230
} ,
233
231
/**
234
- * @function documentjs.generators.html.defaultHelpers.makeTitle
235
- * Given the docObject context, returns a "pretty" name that is used
236
- * in the sidebar and the page header.
237
- */
232
+ * @function bit-docs-generate-html/build/make_default_helpers.makeTitle makeTitle
233
+ *
234
+ * Given the [bit-docs/types/docObject] context, returns a "pretty"
235
+ * name that is used in the sidebar and the page header.
236
+ */
238
237
makeTitle : function ( ) {
239
238
var node = this , title ;
240
239
@@ -259,9 +258,10 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
259
258
return title ;
260
259
} ,
261
260
/**
262
- * @function documentjs.generators.html.defaultHelpers.makeLinks
263
- * Looks for links like [].
264
- */
261
+ * @function bit-docs-generate-html/build/make_default_helpers.makeLinks makeLinks
262
+ *
263
+ * Looks for links like [].
264
+ */
265
265
makeLinks : function ( text ) {
266
266
if ( ! text ) return "" ;
267
267
var replacer = function ( match , content ) {
@@ -313,22 +313,22 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
313
313
}
314
314
} ,
315
315
/**
316
- * @function documentjs.generators. html.defaultHelpers. urlTo
317
- *
318
- * Returns a url that links to a docObject's name.
319
- */
316
+ * @function bit-docs-generate- html/build/make_default_helpers.urlTo urlTo
317
+ *
318
+ * Returns a url that links to a [bit-docs/types/ docObject] name.
319
+ */
320
320
urlTo : function ( name ) {
321
321
return urlTo ( name ) ;
322
322
} ,
323
323
// If the current docObject is something
324
324
/**
325
- * @function documentjs.generators. html.defaultHelpers. ifActive
326
- *
327
- * Renders the truthy section if the current item's name matches
328
- * the current docObject being rendered
329
- *
330
- * @param {HandlebarsOptions } options
331
- */
325
+ * @function bit-docs-generate- html/build/make_default_helpers.ifActive ifActive
326
+ *
327
+ * Renders the truthy section if the current item's name matches the
328
+ * current docObject being rendered
329
+ *
330
+ * @param {HandlebarsOptions } options
331
+ */
332
332
ifActive : function ( options ) {
333
333
if ( this . name == getCurrent ( ) . name ) {
334
334
return options . fn ( this ) ;
@@ -337,18 +337,18 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
337
337
}
338
338
} ,
339
339
/**
340
- * @function documentjs.generators.html.defaultHelpers.chain
341
- *
342
- * Chains multiple calls to mustache.
343
- *
344
- * @signature `{{chain [helperName...] content}}`
345
- *
346
- */
340
+ * @function bit-docs-generate-html/build/make_default_helpers.chain chain
341
+ *
342
+ * Chains multiple calls to mustache.
343
+ *
344
+ * @signature `{{chain [helperName...] content}}`
345
+ */
347
346
chain : function ( ) {
348
347
var helpersToCall = [ ] . slice . call ( arguments , 0 , arguments . length - 2 ) . map ( function ( name ) {
349
348
return Handlebars . helpers [ name ] ;
350
- } ) ,
351
- value = arguments [ arguments . length - 2 ] || "" ;
349
+ } ) ;
350
+
351
+ var value = arguments [ arguments . length - 2 ] || "" ;
352
352
353
353
helpersToCall . forEach ( function ( helper ) {
354
354
value = helper . call ( Handlebars , value ) ;
@@ -360,23 +360,24 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
360
360
return stmd_to_html ( content ) ;
361
361
} ,
362
362
renderAsTemplate : function ( content ) {
363
- var templateRender = config . templateRender || getCurrent ( ) . templateRender ,
364
- renderer ;
363
+ var templateRender = config . templateRender || getCurrent ( ) . templateRender ;
364
+ var renderer ;
365
365
366
366
if ( templateRender === true ) {
367
367
// Render {{}} if templateRender tag/option is true
368
368
renderer = Handlebars . compile ( content . toString ( ) ) ;
369
369
return renderer ( docMap ) ;
370
370
} else if ( templateRender && templateRender . length === 2 ) {
371
371
// Render custom delimiters if supplied by templateRender
372
- var open = new RegExp ( templateRender [ 0 ] , 'g' ) ,
373
- close = new RegExp ( templateRender [ 1 ] , 'g' ) ,
374
- toRender = content
372
+ var open = new RegExp ( templateRender [ 0 ] , 'g' ) ;
373
+ var close = new RegExp ( templateRender [ 1 ] , 'g' ) ;
374
+ var toRender = content
375
375
. replace ( / { { / g, '\\{\\{' )
376
376
. replace ( / } } / g, '\\}\\}' )
377
377
. replace ( open , '{{' )
378
378
. replace ( close , '}}' ) ;
379
379
renderer = Handlebars . compile ( toRender ) ;
380
+
380
381
return renderer ( docMap )
381
382
. replace ( / \\ { \\ { / g, '{{' )
382
383
. replace ( / \\ } \\ } / g, '}}' ) ;
@@ -386,9 +387,9 @@ module.exports = function(docMap, config, getCurrent, Handlebars){
386
387
}
387
388
} ,
388
389
/**
389
- * @function bit-docs-generate-html/theme/templates/helpers/ getTitle
390
+ * @function bit-docs-generate-html/build/make_default_helpers.getTitle getTitle
390
391
*
391
- * Returns the parent docObject's title.
392
+ * Returns the parent [bit-docs/types/ docObject] title.
392
393
*/
393
394
getTitle : function ( ) {
394
395
var root = docMap [ config . parent ] ;
0 commit comments