def display_errors_summary(build_errors: Dict[str, List[DocBuildError]]) -> None: """Displays summary of errors""" console.print() console.print("[red]" + "#" * 30 + " Start docs build errors summary " + "#" * 30 + "[/]") console.print() for package_name, errors in build_errors.items(): if package_name: console.print("=" * 30 + f" [info]{package_name}[/] " + "=" * 30) else: console.print("=" * 30, " [info]General[/] ", "=" * 30) for warning_no, error in enumerate(sorted(errors), 1): console.print("-" * 30, f"[red]Error {warning_no:3}[/]", "-" * 20) console.print(error.message) console.print() if error.file_path and not error.file_path.endswith("<unknown>") and error.line_no: console.print( f"File path: {os.path.relpath(error.file_path, start=DOCS_DIR)} ({error.line_no})" ) console.print() console.print(prepare_code_snippet(error.file_path, error.line_no)) elif error.file_path: console.print(f"File path: {error.file_path}") console.print() console.print("[red]" + "#" * 30 + " End docs build errors summary " + "#" * 30 + "[/]") console.print()
def __str__(self): result = f"{self.msg}\nFilename: {self.file_path}\n\n" for error_no, parse_error in enumerate(self.parse_errors, 1): result += "=" * 20 + f" Parse error {error_no:3} " + "=" * 20 + "\n" result += f"{parse_error.message}\n" if parse_error.line_no: result += f"Line number: {parse_error.line_no}\n" if parse_error.line_no and is_tty(): result += "\n" + prepare_code_snippet(self.file_path, parse_error.line_no) + "\n" return result
def _display_error(error: SpellingError): console.print(error.message) console.print() if error.file_path: console.print(f"File path: {os.path.relpath(error.file_path, start=DOCS_DIR)}") if error.spelling: console.print(f"Incorrect Spelling: '{error.spelling}'") if error.suggestion: console.print(f"Suggested Spelling: '{error.suggestion}'") if error.context_line: console.print(f"Line with Error: '{error.context_line}'") if error.line_no: console.print(f"Line Number: {error.line_no}") console.print(prepare_code_snippet(error.file_path, error.line_no))
def __str__(self): result = self.msg + "\nFilename: " + self.file_path + "\n\n" for error_no, parse_error in enumerate(self.parse_errors, 1): result += "=" * 20 + " Parse error {error_no:3} ".format( error_no=error_no) + "=" * 20 + "\n" result += parse_error.message + "\n" if parse_error.line_no: result += "Line number: {}\n".format(parse_error.line_no) if parse_error.line_no and is_tty(): result += "\n" + prepare_code_snippet( self.file_path, parse_error.line_no) + "\n" return result
def display_errors_summary(build_errors: Dict[str, List[DocBuildError]]) -> None: """Displays summary of errors""" print("#" * 20, "Docs build errors summary", "#" * 20) for package_name, errors in build_errors.items(): if package_name: print("=" * 20, package_name, "=" * 20) else: print("=" * 20, "General", "=" * 20) for warning_no, error in enumerate(sorted(errors), 1): print("-" * 20, f"Error {warning_no:3}", "-" * 20) print(error.message) print() if error.file_path and error.line_no: print(f"File path: {os.path.relpath(error.file_path, start=DOCS_DIR)} ({error.line_no})") print() print(prepare_code_snippet(error.file_path, error.line_no)) elif error.file_path: print(f"File path: {error.file_path}") print("#" * 50)