@@ -26,14 +26,21 @@ class Validator(object):
26
26
27
27
def __init__ (self , directory = '.' , match = '*.html' , blacklist = None ,
28
28
ignore = None , ignore_re = None ,
29
- java_options = None , vnu_options = None ):
29
+ errors_only = False , detect_language = True , format = None ,
30
+ stack_size = None ):
30
31
self .directory = directory
31
32
self .match = match
32
33
self .blacklist = blacklist if blacklist else []
33
34
self .ignore = ignore if ignore else []
34
35
self .ignore_re = ignore_re if ignore_re else []
35
- self .java_options = java_options if java_options is not None else []
36
- self .vnu_options = vnu_options if vnu_options is not None else []
36
+
37
+ # java options
38
+ self .stack_size = stack_size
39
+
40
+ # vnu options
41
+ self .errors_only = errors_only
42
+ self .detect_language = detect_language
43
+ self .format = format
37
44
38
45
# add default ignore_re
39
46
self .ignore_re += DEFAULT_IGNORE_RE
@@ -50,6 +57,29 @@ def __init__(self, directory='.', match='*.html', blacklist=None,
50
57
self .vnu_jar_location = self ._cygwin_path_convert (
51
58
self .vnu_jar_location )
52
59
60
+ @property
61
+ def _java_options (self ):
62
+ java_options = []
63
+
64
+ if self .stack_size is not None :
65
+ java_options .append ('-Xss{}k' .format (self .stack_size ))
66
+
67
+ return java_options
68
+
69
+ @property
70
+ def _vnu_options (self ):
71
+ vnu_options = []
72
+
73
+ if self .errors_only :
74
+ vnu_options .append ('--errors_only' )
75
+ if not self .detect_language :
76
+ vnu_options .append ('--no-langdetect' )
77
+ if self .format is not None :
78
+ vnu_options .append ('--format' )
79
+ vnu_options .append (self .format )
80
+
81
+ return vnu_options
82
+
53
83
def _normalize_string (self , s ):
54
84
s = s .replace ('“' , '"' )
55
85
s = s .replace ('”' , '"' )
@@ -93,8 +123,8 @@ def validate(self, files=None):
93
123
raise JavaNotFoundException ()
94
124
95
125
try :
96
- cmd = (['java' ] + self .java_options +
97
- ['-jar' , self .vnu_jar_location ] + self .vnu_options + files )
126
+ cmd = (['java' ] + self ._java_options +
127
+ ['-jar' , self .vnu_jar_location ] + self ._vnu_options + files )
98
128
o = subprocess .check_output (
99
129
cmd ,
100
130
stderr = subprocess .STDOUT ,
0 commit comments