Skip to content

Commit

Permalink
fix: gracefully handle format_code exceptions (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
dandhlee committed Nov 16, 2021
1 parent 4e1d03f commit a679ace
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docfx_yaml/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from functools import partial
from itertools import zip_longest
from typing import List
from black import InvalidInput

try:
from subprocess import getoutput
Expand Down Expand Up @@ -984,7 +985,11 @@ def format_code(code):
def process_signature(app, _type, name, obj, options, signature, return_annotation):
if signature:
short_name = name.split('.')[-1]
signature = format_code(short_name + signature)
signature = short_name + signature
try:
signature = format_code(signature)
except InvalidInput as e:
print(f"Could not format the given code: \n{e})")
app.env.docfx_signature_funcs_methods[name] = signature


Expand Down

0 comments on commit a679ace

Please sign in to comment.