Treat notes as chapters, but with the notes filename in epub
This commit is contained in:
@@ -69,6 +69,7 @@ class EPubType(Enum):
|
||||
PART = 2
|
||||
CHAPTER = 3
|
||||
BACKMATTER = 4
|
||||
NOTES = 5
|
||||
|
||||
|
||||
class ManifestEntry(NamedTuple):
|
||||
@@ -95,6 +96,7 @@ class ToEPub(ToHtml):
|
||||
self._isFront = True
|
||||
self._brTag = "<br />"
|
||||
self._nextFnIndex = 1
|
||||
self._useAnchors = False
|
||||
|
||||
##
|
||||
# Setters
|
||||
@@ -126,7 +128,7 @@ class ToEPub(ToHtml):
|
||||
self._section.text.append(f"<h1{hStyle}>{tHead}</h1>")
|
||||
|
||||
elif tType in (BlockTyp.TITLE, BlockTyp.PART):
|
||||
self._section = EPubSection(EPubType.PART)
|
||||
self._section = EPubSection(EPubType.PART if self._isNovel else EPubType.NOTES)
|
||||
self._sections.append(self._section)
|
||||
|
||||
tHead = tText.replace("\n", self._brTag)
|
||||
@@ -432,6 +434,7 @@ class EPubSection:
|
||||
EPubType.PART: "bodymatter",
|
||||
EPubType.CHAPTER: "bodymatter",
|
||||
EPubType.BACKMATTER: "backmatter",
|
||||
EPubType.NOTES: "bodymatter",
|
||||
}
|
||||
SECTION_TYPE: Final[dict[EPubType, tuple[str, str]]] = {
|
||||
EPubType.COVER: ("cover", ""),
|
||||
@@ -439,6 +442,7 @@ class EPubSection:
|
||||
EPubType.PART: ("part", " doc-part"),
|
||||
EPubType.CHAPTER: ("chapter", "doc-chapter"),
|
||||
EPubType.BACKMATTER: ("backmatter", ""),
|
||||
EPubType.NOTES: ("notes", " doc-chapter"),
|
||||
}
|
||||
|
||||
def __init__(self, eType: EPubType) -> None:
|
||||
|
||||
@@ -10,7 +10,7 @@ import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _genCoverageConfig(path: Path) -> None:
|
||||
def _genCoverageConfig(path: Path, branch: bool) -> None:
|
||||
"""Generate a config file for coverage.py."""
|
||||
exclude = [] # ["if TYPE_CHECKING:"]
|
||||
if sys.platform != "linux":
|
||||
@@ -25,7 +25,7 @@ def _genCoverageConfig(path: Path) -> None:
|
||||
|
||||
config = [
|
||||
"[run]",
|
||||
"branch = false",
|
||||
f"branch = {str(branch).lower()}",
|
||||
"source = novelwriter",
|
||||
"",
|
||||
"[report]",
|
||||
@@ -45,6 +45,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument("-t", action="store_true", help="Generate terminal report")
|
||||
parser.add_argument("-u", action="store_true", help="Generate uncovered terminal report")
|
||||
parser.add_argument("-x", action="store_true", help="Ignore OS-specific tests in reports")
|
||||
parser.add_argument("-b", action="store_true", help="Check branch coverage")
|
||||
parser.add_argument("-lf", action="store_true", help="Re-run failed tests")
|
||||
parser.add_argument("-sw", action="store_true", help="Run tests stepwise")
|
||||
parser.add_argument("-m", help="Test modules", metavar="MARKEXPR")
|
||||
@@ -58,7 +59,7 @@ if __name__ == "__main__":
|
||||
|
||||
if args.r or args.t or args.u:
|
||||
if args.x:
|
||||
_genCoverageConfig(tmpConf)
|
||||
_genCoverageConfig(tmpConf, args.b)
|
||||
cmd = ["coverage", "run"]
|
||||
if args.lf or args.sw:
|
||||
cmd += ["--append"]
|
||||
|
||||
Reference in New Issue
Block a user