Skip to content

Commit a9a7fa1

Browse files
committed
Add -s to continue on bad files
1 parent 05e7a5c commit a9a7fa1

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

Diff for: pycco/main.py

+23-11
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def generate_html(source, sections, preserve_paths=True, outdir=None):
319319

320320
".sql": {"name": "sql", "symbol": "--"},
321321

322-
".sh": { "name": "bash", "symbol": "#" },
322+
".sh": {"name": "bash", "symbol": "#"},
323323

324324
".c": {"name": "c", "symbol": "//",
325325
"multistart": "/*", "multiend": "*/"},
@@ -482,7 +482,8 @@ def _flatten_sources(sources):
482482
return _sources
483483

484484

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):
486487
"""For each source file passed as argument, generate the documentation."""
487488

488489
if not outdir:
@@ -510,14 +511,20 @@ def next_file():
510511
except OSError:
511512
pass
512513

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
521528

522529
if sources:
523530
next_file()
@@ -596,14 +603,19 @@ def main():
596603
parser.add_option('-i', '--generate_index', action='store_true',
597604
help='Generate an index.html document with sitemap content')
598605

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+
599610
opts, sources = parser.parse_args()
600611
if opts.outdir == '':
601612
outdir = '.'
602613
else:
603614
outdir = opts.outdir
604615

605616
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)
607619

608620
# If the -w / --watch option was present, monitor the source directories
609621
# for changes and re-generate documentation for source files whenever they

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="Pycco",
5-
version="0.4.1",
5+
version="0.5.1",
66
description="""A Python port of Docco: the original quick-and-dirty,
77
hundred-line-long, literate-programming-style documentation generator.
88
""",

0 commit comments

Comments
 (0)