From b082583253baa14d2994e10081ee27de8185b73a Mon Sep 17 00:00:00 2001 From: RepoDynamicsBot <80158628+AAriam@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:26:59 +0200 Subject: [PATCH] update --- pyproject.toml | 2 +- src/exceptionman/__init__.py | 1 + src/exceptionman/reporter_exception.py | 18 +++++++++++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 470c6a6..3497698 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ namespaces = true # ----------------------------------------- Project Metadata ------------------------------------- [project] -version = "0.0.0.dev0" +version = "0.0.0.dev1" name = "ExceptionMan" dependencies = [ "markitup", diff --git a/src/exceptionman/__init__.py b/src/exceptionman/__init__.py index e69de29..8124be2 100644 --- a/src/exceptionman/__init__.py +++ b/src/exceptionman/__init__.py @@ -0,0 +1 @@ +from exceptionman.reporter_exception import ReporterException \ No newline at end of file diff --git a/src/exceptionman/reporter_exception.py b/src/exceptionman/reporter_exception.py index fc7fee3..4fb3af5 100644 --- a/src/exceptionman/reporter_exception.py +++ b/src/exceptionman/reporter_exception.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Literal as _Literal from markitup import html as _html, doc as _doc @@ -16,12 +18,14 @@ def __init__( ): message_html = message_html or message description_html = description_html or description + self.summary = message + (f"\n{description}" if description else "") - super().__init__(message + (f"\n{description}" if description else "")) + super().__init__(self.summary) self.message = message self.description = description self.message_html = message_html self.description_html = description_html + self.summary_html = self.message_html + (f" {self.description_html}" if self.description_html else "") self._html_head = _html.elem.head( [ _html.elem.title(report_heading), @@ -53,15 +57,15 @@ def __init__( def report(self, mode: _Literal["full", "short"] = "full", md: bool = False) -> _doc.Document: """Generate a report for the exception.""" detail_section_content = self._report_content(mode, md) - summary = self.message_html + (f" {self.description_html}" if self.description_html else "") + section = _doc.from_contents( + heading="Error Details", + content=detail_section_content, + ) report = _doc.from_contents( heading=self._report_heading, - content={"summary": _html.elem.p(summary, align="justify")}, + content={"summary": _html.elem.p(self.summary_html, align="justify")}, head=self._html_head if not md else None, - section=_doc.from_contents( - heading="Error Details", - content=detail_section_content, - ) if detail_section_content else None, + section= {"details": section} if detail_section_content else None, ) if not md: report.add_highlight(style="monokai-sublime", languages=["yaml", "json", "toml"])