File tree Expand file tree Collapse file tree 2 files changed +56
-26
lines changed Expand file tree Collapse file tree 2 files changed +56
-26
lines changed Original file line number Diff line number Diff line change
1
+ /*global env: true */
2
+ /**
3
+ * @overview Dump information about parser events to the console.
4
+ * @module plugins/eventDumper
5
+ * @author Jeff Williams <[email protected] >
6
+ */
7
+
8
+ var _ = require ( 'underscore' ) ;
9
+
10
+ var conf = env . conf . eventDumper || { } ;
11
+
12
+ // Dump the included parser events (defaults to all events)
13
+ var events = conf . include || [
14
+ 'fileBegin' ,
15
+ 'beforeParse' ,
16
+ 'jsdocCommentFound' ,
17
+ 'symbolFound' ,
18
+ 'newDoclet' ,
19
+ 'fileComplete'
20
+ ] ;
21
+ // Don't dump the excluded parser events
22
+ if ( conf . exclude ) {
23
+ events = _ . difference ( events , conf . exclude ) ;
24
+ }
25
+
26
+ /**
27
+ * Get rid of native Java crud in an event object so that JSON.stringify() works.
28
+ * @param {object } e The event object.
29
+ * @return {object } The fixed-up object.
30
+ */
31
+ function cleanse ( e ) {
32
+ var result = { } ;
33
+
34
+ for ( var prop in e ) {
35
+ // go down an extra level for these
36
+ if ( [ 'code' , 'doclet' , 'meta' ] . indexOf ( prop ) !== - 1 ) {
37
+ result [ prop ] = cleanse ( e [ prop ] ) ;
38
+ } else {
39
+ result [ prop ] = String ( e [ prop ] ) ;
40
+ }
41
+ }
42
+
43
+ return result ;
44
+ }
45
+
46
+
47
+ exports . handlers = { } ;
48
+
49
+ events . forEach ( function ( eventType ) {
50
+ exports . handlers [ eventType ] = function ( e ) {
51
+ console . log ( JSON . stringify ( {
52
+ type : eventType ,
53
+ content : cleanse ( e )
54
+ } , null , 4 ) ) ;
55
+ } ;
56
+ } ) ;
Original file line number Diff line number Diff line change @@ -304,32 +304,6 @@ function getBasename(name) {
304
304
return name ;
305
305
}
306
306
307
- /**
308
- * Dump an event to the console.
309
- * @private
310
- * @memberof module:src/parser.Parser
311
- * @param {object } e The event to dump.
312
- */
313
- function dumpEvent ( e ) {
314
- for ( var prop in e ) {
315
- // can't use hasOwnProp() on native objects, so let's just make JSHint happy
316
- if ( e [ prop ] ) {
317
- console . log ( "e." + prop + ": " + e [ prop ] ) ;
318
- // go one level down for e.code
319
- if ( prop === "code" ) {
320
- for ( prop in e . code ) {
321
- // can't use hasOwnProp() on native objects, so let's just make JSHint happy
322
- if ( e . code [ prop ] ) {
323
- console . log ( "e.code." + prop + ": " + e . code [ prop ] ) ;
324
- }
325
- }
326
- }
327
- }
328
- }
329
-
330
- console . log ( "\n\n" ) ;
331
- }
332
-
333
307
/** @private */
334
308
function visitNode ( node ) {
335
309
var e ,
You can’t perform that action at this time.
0 commit comments