@@ -319,7 +319,7 @@ def generate_html(source, sections, preserve_paths=True, outdir=None):
319
319
320
320
".sql" : {"name" : "sql" , "symbol" : "--" },
321
321
322
- ".sh" : { "name" : "bash" , "symbol" : "#" },
322
+ ".sh" : {"name" : "bash" , "symbol" : "#" },
323
323
324
324
".c" : {"name" : "c" , "symbol" : "//" ,
325
325
"multistart" : "/*" , "multiend" : "*/" },
@@ -482,7 +482,8 @@ def _flatten_sources(sources):
482
482
return _sources
483
483
484
484
485
- def process (sources , preserve_paths = True , outdir = None , language = None , encoding = "utf8" , index = False ):
485
+ def process (sources , preserve_paths = True , outdir = None , language = None ,
486
+ encoding = "utf8" , index = False , skip = False ):
486
487
"""For each source file passed as argument, generate the documentation."""
487
488
488
489
if not outdir :
@@ -510,14 +511,20 @@ def next_file():
510
511
except OSError :
511
512
pass
512
513
513
- with open (dest , "wb" ) as f :
514
- f .write (generate_documentation (s , preserve_paths = preserve_paths ,
515
- outdir = outdir ,
516
- language = language ,
517
- encoding = encoding ))
518
-
519
- print ("pycco: {} -> {}" .format (s , dest ))
520
- generated_files .append (dest )
514
+ try :
515
+ with open (dest , "wb" ) as f :
516
+ f .write (generate_documentation (s , preserve_paths = preserve_paths ,
517
+ outdir = outdir ,
518
+ language = language ,
519
+ encoding = encoding ))
520
+
521
+ print ("pycco: {} -> {}" .format (s , dest ))
522
+ generated_files .append (dest )
523
+ except UnicodeDecodeError :
524
+ if skip :
525
+ print ("pycco [FAILURE]: {}" .format (s ))
526
+ else :
527
+ raise
521
528
522
529
if sources :
523
530
next_file ()
@@ -596,14 +603,19 @@ def main():
596
603
parser .add_option ('-i' , '--generate_index' , action = 'store_true' ,
597
604
help = 'Generate an index.html document with sitemap content' )
598
605
606
+ parser .add_option ('-s' , '--skip-bad-files' , action = 'store_true' ,
607
+ dest = 'skip_bad_files' ,
608
+ help = 'Continue processing after hitting a bad file' )
609
+
599
610
opts , sources = parser .parse_args ()
600
611
if opts .outdir == '' :
601
612
outdir = '.'
602
613
else :
603
614
outdir = opts .outdir
604
615
605
616
process (sources , outdir = outdir , preserve_paths = opts .paths ,
606
- language = opts .language , index = opts .generate_index )
617
+ language = opts .language , index = opts .generate_index ,
618
+ skip = opts .skip_bad_files )
607
619
608
620
# If the -w / --watch option was present, monitor the source directories
609
621
# for changes and re-generate documentation for source files whenever they
0 commit comments