diff --git a/novelwriter/core/index.py b/novelwriter/core/index.py index 661b71b4..7c40e120 100644 --- a/novelwriter/core/index.py +++ b/novelwriter/core/index.py @@ -708,9 +708,8 @@ class NWIndex: return "", "", None, None -# =============================================================================================== # -# The Tags Index Object -# =============================================================================================== # +# The Tags Index Object +# ===================== class TagsIndex: """Core: Tags Index Wrapper Class @@ -831,9 +830,8 @@ class TagsIndex: return -# =============================================================================================== # -# The Item Index Objects -# =============================================================================================== # +# The Item Index Objects +# ====================== class ItemIndex: """Core: Item Index Wrapper Class @@ -1346,9 +1344,9 @@ class IndexHeading: return -# =============================================================================================== # -# Text Processing Functions -# =============================================================================================== # +# Text Processing Functions +# ========================= + MODIFIERS = { "synopsis": nwComment.SYNOPSIS, "short": nwComment.SHORT, diff --git a/novelwriter/core/toodt.py b/novelwriter/core/toodt.py index e06c8de6..b30bbc0d 100644 --- a/novelwriter/core/toodt.py +++ b/novelwriter/core/toodt.py @@ -1080,9 +1080,8 @@ class ToOdt(Tokenizer): return -# =============================================================================================== # -# Auto-Style Classes -# =============================================================================================== # +# Auto-Style Classes +# ================== class ODTParagraphStyle: """Wrapper class for the paragraph style setting used by the @@ -1454,9 +1453,9 @@ class ODTTextStyle: return -# =============================================================================================== # -# XML Complex Element Helper Class -# =============================================================================================== # +# XML Complex Element Helper Class +# ================================ + X_ROOT_TEXT = 0 X_ROOT_TAIL = 1 X_SPAN_TEXT = 2 diff --git a/novelwriter/error.py b/novelwriter/error.py index 9026803e..b8c00f53 100644 --- a/novelwriter/error.py +++ b/novelwriter/error.py @@ -42,10 +42,6 @@ if TYPE_CHECKING: # pragma: no cover logger = logging.getLogger(__name__) -# =============================================================================================== # -# Utility Functions -# =============================================================================================== # - def logException() -> None: """Log the content of an exception message.""" exType, exValue, _ = sys.exc_info() @@ -61,10 +57,6 @@ def formatException(exc: BaseException) -> str: return f"{type(exc).__name__}: {str(exc)}" -# =============================================================================================== # -# Error Handler -# =============================================================================================== # - class NWErrorMessage(QDialog): def __init__(self, parent: QWidget) -> None: diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index 36349e6b..879cc33b 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -78,7 +78,7 @@ class _SelectAction(Enum): KEEP_POSITION = 2 MOVE_AFTER = 3 - + class GuiDocEditor(QPlainTextEdit): """Gui Widget: Main Document Editor""" @@ -2129,8 +2129,6 @@ class GuiDocEditor(QPlainTextEdit): self._doReplace = False return - - class MetaCompleter(QMenu): """GuiWidget: Meta Completer Menu @@ -2208,15 +2206,13 @@ class MetaCompleter(QMenu): self.complete.emit(pos, length, value) return - - - -# =============================================================================================== # -# The Off-GUI Thread Word Counter -# A runnable for the word counter to be run in the thread pool off the main GUI thread. -# =============================================================================================== # class BackgroundWordCounter(QRunnable): + """The Off-GUI Thread Word Counter + + A runnable for the word counter to be run in the thread pool off the + main GUI thread. + """ def __init__(self, docEditor: GuiDocEditor, forSelection: bool = False) -> None: super().__init__() @@ -2249,8 +2245,6 @@ class BackgroundWordCounter(QRunnable): return - - class BackgroundWordCounterSignals(QObject): """The QRunnable cannot emit a signal, so we need a simple QObject @@ -2258,15 +2252,13 @@ class BackgroundWordCounterSignals(QObject): """ countsReady = pyqtSignal(int, int, int) - - - -# =============================================================================================== # -# The Formatting and Options Fold Out Menu -# Only used by DocEditor, and is opened by the first button in the header -# =============================================================================================== # class GuiDocToolBar(QWidget): + """The Formatting and Options Fold Out Menu + + Only used by DocEditor, and is opened by the first button in the + header. + """ requestDocAction = pyqtSignal(nwDocAction) @@ -2391,15 +2383,13 @@ class GuiDocToolBar(QWidget): return - - - -# =============================================================================================== # -# The Embedded Document Search/Replace Feature -# Only used by DocEditor, and is at a fixed position in the QTextEdit's viewport -# =============================================================================================== # class GuiDocEditSearch(QFrame): + """The Embedded Document Search/Replace Feature + + Only used by DocEditor, and is at a fixed position in the + QTextEdit's viewport. + """ def __init__(self, docEditor: GuiDocEditor) -> None: super().__init__(parent=docEditor) @@ -2755,15 +2745,13 @@ class GuiDocEditSearch(QFrame): self.searchBox.setPalette(qPalette) return - - - -# =============================================================================================== # -# The Embedded Document Header -# Only used by DocEditor, and is at a fixed position in the QTextEdit's viewport -# =============================================================================================== # class GuiDocEditHeader(QWidget): + """The Embedded Document Header + + Only used by DocEditor, and is at a fixed position in the + QTextEdit's viewport. + """ closeDocumentRequest = pyqtSignal() toggleToolBarRequest = pyqtSignal() @@ -2978,15 +2966,13 @@ class GuiDocEditHeader(QWidget): self.docEditor.requestProjectItemSelected.emit(self._docHandle or "", True) return - - - -# =============================================================================================== # -# The Embedded Document Footer -# Only used by DocEditor, and is at a fixed position in the QTextEdit's viewport -# =============================================================================================== # class GuiDocEditFooter(QWidget): + """The Embedded Document Footer + + Only used by DocEditor, and is at a fixed position in the + QTextEdit's viewport. + """ def __init__(self, parent: QWidget) -> None: super().__init__(parent=parent) @@ -3169,5 +3155,3 @@ class GuiDocEditFooter(QWidget): wText = self._trWordCount.format("0", "+0") self.wordsText.setText(wText) return - - diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py index 89052faf..fbcb5ab0 100644 --- a/novelwriter/gui/docviewer.py +++ b/novelwriter/gui/docviewer.py @@ -610,12 +610,12 @@ class GuiDocViewHistory: return -# =============================================================================================== # -# The Embedded Document Header -# Only used by DocViewer, and is at a fixed position in the QTextBrowser's viewport -# =============================================================================================== # - class GuiDocViewHeader(QWidget): + """The Embedded Document Header + + Only used by DocViewer, and is at a fixed position in the + QTextBrowser's viewport. + """ def __init__(self, docViewer: GuiDocViewer) -> None: super().__init__(parent=docViewer) @@ -832,12 +832,12 @@ class GuiDocViewHeader(QWidget): return -# =============================================================================================== # -# The Embedded Document Footer -# Only used by DocViewer, and is at a fixed position in the QTextBrowser's viewport -# =============================================================================================== # - class GuiDocViewFooter(QWidget): + """The Embedded Document Footer + + Only used by DocViewer, and is at a fixed position in the + QTextBrowser's viewport. + """ def __init__(self, docViewer: GuiDocViewer) -> None: super().__init__(parent=docViewer) diff --git a/novelwriter/gui/theme.py b/novelwriter/gui/theme.py index 170bb452..5ecc4444 100644 --- a/novelwriter/gui/theme.py +++ b/novelwriter/gui/theme.py @@ -46,12 +46,11 @@ STYLES_MIN_TOOLBUTTON = "minimalToolButton" STYLES_BIG_TOOLBUTTON = "bigToolButton" -# =============================================================================================== # -# Gui Theme Class -# Handles the look and feel of novelWriter -# =============================================================================================== # - class GuiTheme: + """Gui Theme Class + + Handles the look and feel of novelWriter. + """ def __init__(self) -> None: @@ -482,12 +481,6 @@ class GuiTheme: return -# End Class GuiTheme - - -# =============================================================================================== # -# Icons Class -# =============================================================================================== # class GuiIcons: """The icon class manages the content of the assets/icons folder, @@ -796,9 +789,8 @@ class GuiIcons: return self._noIcon -# =============================================================================================== # -# Module Functions -# =============================================================================================== # +# Module Functions +# ================ def _sortTheme(data: tuple[str, str]) -> str: diff --git a/tests/mocked.py b/tests/mocked.py index 545a32ce..afa62d25 100644 --- a/tests/mocked.py +++ b/tests/mocked.py @@ -23,10 +23,6 @@ from __future__ import annotations from PyQt5.QtGui import QPixmap from PyQt5.QtWidgets import QWidget -# =========================================================================== # -# Mock GUI -# =========================================================================== # - class MockGuiMain(QWidget): @@ -87,10 +83,9 @@ class MockApp: return -# =========================================================================== # -# Error Functions -# Mock functions that will raise errors instead. -# =========================================================================== # +# Error Functions +# =============== +# Mock functions that will raise errors instead. def causeOSError(*args, **kwargs): raise OSError("Mock OSError")