1
1
"use strict" ;
2
2
var fs = require ( "fs" )
3
3
var dox = require ( "dox" ) ;
4
+ var marked = require ( "marked" ) ;
4
5
5
6
var optionsSrc = __dirname + "/../res/jshint/src/options.js" ;
7
+ var deprecationMsg = "<strong>Warning</strong> This option has been " +
8
+ "deprecated and will be removed in the next major release of JSHint."
6
9
7
10
dox . setMarkedOptions ( {
8
11
breaks : false
@@ -38,12 +41,31 @@ function getCategory(annotation) {
38
41
return name ;
39
42
}
40
43
44
+ function getDeprecationReason ( annotation ) {
45
+ var tags = annotation . tags ;
46
+ var idx , length , tag ;
47
+
48
+ if ( ! tags ) {
49
+ return null ;
50
+ }
51
+
52
+ for ( idx = 0 , length = tags . length ; idx < length ; ++ idx ) {
53
+ tag = tags [ idx ] ;
54
+ if ( tag . type === 'deprecated' ) {
55
+ return tag . string ;
56
+ }
57
+ }
58
+
59
+ return null ;
60
+ }
61
+
41
62
options . annotations . map ( function ( annotation ) {
42
63
var name = annotation . code . split ( ":" ) [ 0 ] ;
43
64
var option = options . parsed [ name ] ;
44
65
45
66
annotation . name = name . trim ( ) ;
46
67
annotation . category = getCategory ( annotation ) ;
68
+ annotation . deprecationReason = getDeprecationReason ( annotation ) ;
47
69
48
70
return annotation ;
49
71
} ) . forEach ( function ( annotation ) {
@@ -62,13 +84,26 @@ function table2html(annotations) {
62
84
63
85
return header + annotations . map ( function ( annotation ) {
64
86
var name = annotation . name ;
87
+ var description = '' ;
88
+
89
+ if ( annotation . deprecationReason ) {
90
+ description += "<div class='deprecation-msg'>" + deprecationMsg + " " +
91
+ // TODO: Remove this when the `dox` module is updated to also parse
92
+ // annotations for Markdown.
93
+ // See: "Parse tag strings with Markdown"
94
+ // https://github.com/tj/dox/pull/139
95
+ marked ( annotation . deprecationReason ) +
96
+ "</div>" ;
97
+ }
98
+
99
+ description += annotation . description . full ;
65
100
66
101
return [
67
102
"<tr>" ,
68
103
"<td class='name' id='" + name + "'>" ,
69
104
"<a href='#" + name + "'>" + name + "</a>" ,
70
105
"</td>" ,
71
- "<td class='desc'>" + annotation . description . full + "</td>" ,
106
+ "<td class='desc'>" + description + "</td>" ,
72
107
"</tr>"
73
108
] . join ( "\n" ) ;
74
109
} ) . join ( "\n" ) + footer ;
0 commit comments