@@ -143,16 +143,18 @@ def __str__(m):
143
143
def print_token_count (num_tokens , ** kwargs ):
144
144
print_size ("tokens" , num_tokens , 8192 , ** kwargs )
145
145
146
- def process_code (ctxt , source , input_count = False , count = False , lint = False , minify = False , rename = False , unminify = False , fail = True , want_count = True ):
146
+ def process_code (ctxt , source , input_count = False , count = False , lint = False , minify = False , rename = False , unminify = False , fail = True , want_count = True , annotate = False ):
147
147
need_lint = lint not in (None , False )
148
148
need_minify = minify not in (None , False )
149
149
need_rename = rename not in (None , False )
150
150
need_unminify = unminify not in (None , False )
151
+ need_annotate = annotate not in (None , False )
151
152
152
- if not need_lint and not need_minify and not need_unminify and not (want_count and (count or input_count )):
153
+ need_parse = need_lint or need_minify or need_unminify or need_annotate
154
+
155
+ if not need_parse and not (want_count and (count or input_count )):
153
156
return True , ()
154
-
155
- need_parse = need_lint or need_minify or need_unminify
157
+
156
158
need_all_comments = need_unminify or (need_minify and minify_needs_comments (minify ))
157
159
158
160
ok = False
@@ -182,6 +184,9 @@ def process_code(ctxt, source, input_count=False, count=False, lint=False, minif
182
184
new_tokens = root .get_tokens () if need_parse else tokens
183
185
print_token_count (count_tokens (new_tokens ), handler = count )
184
186
187
+ if annotate :
188
+ annotate_code (ctxt , source , root )
189
+
185
190
if fail and errors :
186
191
throw ("\n " .join (map (str , errors )))
187
192
return ok , errors
@@ -199,6 +204,7 @@ def echo_code(code, echo=True):
199
204
from pico_lint import lint_code
200
205
from pico_minify import minify_code , minify_needs_comments
201
206
from pico_unminify import unminify_code
207
+ from pico_annotate import annotate_code
202
208
from pico_rename import rename_tokens
203
209
204
210
# re-export some things for examples/etc.
0 commit comments