@@ -47,21 +47,31 @@ function inferHierarchy(comments) {
47
47
nameIndex [ comments [ i ] . name ] = comments [ i ] ;
48
48
comments [ i ] . members = { instance : [ ] , static : [ ] } ;
49
49
}
50
+
50
51
for ( i = comments . length - 1 ; i >= 0 ; i -- ) {
51
- if ( comments [ i ] . memberof ) {
52
- if ( nameIndex [ comments [ i ] . memberof ] ) {
53
- if ( comments [ i ] . scope ) {
54
- nameIndex [ comments [ i ] . memberof ] . members [ comments [ i ] . scope ] . push ( comments [ i ] ) ;
55
- // remove non-root nodes from the lowest level: these are reachable
56
- // as members of other docs.
57
- comments . splice ( i , 1 ) ;
58
- } else {
59
- console . error ( error ( comments [ i ] , 'found memberof but no @scope, @static, or @instance tag' ) ) ;
60
- }
61
- } else {
62
- console . error ( error ( comments [ i ] , 'memberof reference to %s not found' , comments [ i ] . memberof ) ) ;
63
- }
52
+ var comment = comments [ i ] ;
53
+
54
+ if ( ! comment . memberof ) {
55
+ continue ;
56
+ }
57
+
58
+ var parent = nameIndex [ comment . memberof ] ;
59
+
60
+ if ( ! parent ) {
61
+ console . error ( error ( comment , 'memberof reference to %s not found' , comment . memberof ) ) ;
62
+ continue ;
64
63
}
64
+
65
+ if ( ! comment . scope ) {
66
+ console . error ( error ( comment , 'found memberof but no @scope, @static, or @instance tag' ) ) ;
67
+ continue ;
68
+ }
69
+
70
+ parent . members [ comment . scope ] . push ( comment ) ;
71
+
72
+ // remove non-root nodes from the lowest level: these are reachable
73
+ // as members of other docs.
74
+ comments . splice ( i , 1 ) ;
65
75
}
66
76
67
77
// Now the members are in the right order but the root comments are reversed
0 commit comments