Skip to content

Commit

Permalink
Add -s to continue on bad files
Browse files Browse the repository at this point in the history
  • Loading branch information
subsetpark committed Jun 4, 2016
1 parent 05e7a5c commit a9a7fa1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
34 changes: 23 additions & 11 deletions pycco/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def generate_html(source, sections, preserve_paths=True, outdir=None):

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

".sh": { "name": "bash", "symbol": "#" },
".sh": {"name": "bash", "symbol": "#"},

".c": {"name": "c", "symbol": "//",
"multistart": "/*", "multiend": "*/"},
Expand Down Expand Up @@ -482,7 +482,8 @@ def _flatten_sources(sources):
return _sources


def process(sources, preserve_paths=True, outdir=None, language=None, encoding="utf8", index=False):
def process(sources, preserve_paths=True, outdir=None, language=None,
encoding="utf8", index=False, skip=False):
"""For each source file passed as argument, generate the documentation."""

if not outdir:
Expand Down Expand Up @@ -510,14 +511,20 @@ def next_file():
except OSError:
pass

with open(dest, "wb") as f:
f.write(generate_documentation(s, preserve_paths=preserve_paths,
outdir=outdir,
language=language,
encoding=encoding))

print("pycco: {} -> {}".format(s, dest))
generated_files.append(dest)
try:
with open(dest, "wb") as f:
f.write(generate_documentation(s, preserve_paths=preserve_paths,
outdir=outdir,
language=language,
encoding=encoding))

print("pycco: {} -> {}".format(s, dest))
generated_files.append(dest)
except UnicodeDecodeError:
if skip:
print("pycco [FAILURE]: {}".format(s))
else:
raise

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

parser.add_option('-s', '--skip-bad-files', action='store_true',
dest='skip_bad_files',
help='Continue processing after hitting a bad file')

opts, sources = parser.parse_args()
if opts.outdir == '':
outdir = '.'
else:
outdir = opts.outdir

process(sources, outdir=outdir, preserve_paths=opts.paths,
language=opts.language, index=opts.generate_index)
language=opts.language, index=opts.generate_index,
skip=opts.skip_bad_files)

# If the -w / --watch option was present, monitor the source directories
# for changes and re-generate documentation for source files whenever they
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="Pycco",
version="0.4.1",
version="0.5.1",
description="""A Python port of Docco: the original quick-and-dirty,
hundred-line-long, literate-programming-style documentation generator.
""",
Expand Down

0 comments on commit a9a7fa1

Please sign in to comment.