Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix broken log print in console #12387

Merged
merged 5 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sphinx/builders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def write(
with progress_message(__('preparing documents')):
self.prepare_writing(docnames)

with progress_message(__('copying assets')):
picnixz marked this conversation as resolved.
Show resolved Hide resolved
with progress_message(__('copying assets'), nonl=False):
self.copy_assets()

if self.parallel_ok:
Expand Down
12 changes: 7 additions & 5 deletions sphinx/util/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,29 @@ class SkipProgressMessage(Exception):


class progress_message:
def __init__(self, message: str) -> None:
def __init__(self, message: str, *, nonl: bool = True) -> None:
self.message = message
self.nonl = nonl

def __enter__(self) -> None:
logger.info(bold(self.message + '... '), nonl=True)
logger.info(bold(self.message + '... '), nonl=self.nonl)

def __exit__(
self,
typ: type[BaseException] | None,
val: BaseException | None,
tb: TracebackType | None,
) -> bool:
prefix = "" if self.nonl else bold(self.message + ': ')
if isinstance(val, SkipProgressMessage):
logger.info(__('skipped'))
logger.info(prefix + __('skipped'))
if val.args:
logger.info(*val.args)
return True
elif val:
logger.info(__('failed'))
logger.info(prefix + __('failed'))
else:
logger.info(__('done'))
logger.info(prefix + __('done'))

return False

Expand Down