Clean up variables in doc builder

This commit is contained in:
Veronica Berglyd Olsen
2023-06-06 00:03:27 +02:00
parent 9bc66128a7
commit 67f1dd6677
+30 -45
View File
@@ -107,7 +107,7 @@ class NWBuildDocument:
return return
def iterBuild(self, path: Path, bFormat: str) -> Iterable[tuple[int, bool]]: def iterBuild(self, path: Path, bFormat: str) -> Iterable[tuple[int, bool]]:
"""Wrapper for builder based on format.""" """Wrapper for builders based on format."""
if bFormat in ("odt", "fodt"): if bFormat in ("odt", "fodt"):
yield from self.iterBuildOpenDocument(path, bFormat == "fodt") yield from self.iterBuildOpenDocument(path, bFormat == "fodt")
elif bFormat in ("html", "jhtml"): elif bFormat in ("html", "jhtml"):
@@ -238,65 +238,50 @@ class NWBuildDocument:
def _setupBuild(self, bldObj: Tokenizer) -> dict: def _setupBuild(self, bldObj: Tokenizer) -> dict:
"""Configure the build object.""" """Configure the build object."""
# Get Settings # Get Settings
fmtTitle = self._build.getStr("headings.fmtTitle") buildLang = self._build.getStr("format.buildLang")
fmtChapter = self._build.getStr("headings.fmtChapter") textFont = self._build.getStr("format.textFont")
fmtUnnumbered = self._build.getStr("headings.fmtUnnumbered") textSize = self._build.getInt("format.textSize")
fmtScene = self._build.getStr("headings.fmtScene")
fmtSection = self._build.getStr("headings.fmtSection")
hideScene = self._build.getBool("headings.hideScene")
hideSection = self._build.getBool("headings.hideSection")
incSynopsis = self._build.getBool("text.includeSynopsis")
incComments = self._build.getBool("text.includeComments")
incKeywords = self._build.getBool("text.includeKeywords")
incBodyText = self._build.getBool("text.includeBodyText")
noteHeadings = self._build.getBool("text.addNoteHeadings")
buildLang = self._build.getStr("format.buildLang")
textFont = self._build.getStr("format.textFont")
textSize = self._build.getInt("format.textSize")
lineHeight = self._build.getFloat("format.lineHeight")
justifyText = self._build.getBool("format.justifyText")
replaceUCode = self._build.getBool("format.stripUnicode")
odtAddColours = self._build.getBool("odt.addColours")
htmlAddStyles = self._build.getBool("html.addStyles")
# The language lookup dict is reloaded if needed # The language lookup dict is reloaded if needed
self._project.setProjectLang(buildLang) self._project.setProjectLang(buildLang)
# Get font information fontFamily = textFont or CONFIG.textFont
if not textFont: bldFont = QFont(fontFamily, textSize)
textFont = str(CONFIG.textFont)
bldFont = QFont(textFont, textSize)
fontInfo = QFontInfo(bldFont) fontInfo = QFontInfo(bldFont)
textFixed = fontInfo.fixedPitch() textFixed = fontInfo.fixedPitch()
bldObj.setTitleFormat(fmtTitle) bldObj.setTitleFormat(self._build.getStr("headings.fmtTitle"))
bldObj.setChapterFormat(fmtChapter) bldObj.setChapterFormat(self._build.getStr("headings.fmtChapter"))
bldObj.setUnNumberedFormat(fmtUnnumbered) bldObj.setUnNumberedFormat(self._build.getStr("headings.fmtUnnumbered"))
bldObj.setSceneFormat(fmtScene, hideScene) bldObj.setSceneFormat(
bldObj.setSectionFormat(fmtSection, hideSection) self._build.getStr("headings.fmtScene"),
self._build.getBool("headings.hideScene")
)
bldObj.setSectionFormat(
self._build.getStr("headings.fmtSection"),
self._build.getBool("headings.hideSection")
)
bldObj.setFont(textFont, textSize, textFixed) bldObj.setFont(fontFamily, textSize, textFixed)
bldObj.setJustify(justifyText) bldObj.setJustify(self._build.getBool("format.justifyText"))
bldObj.setLineHeight(lineHeight) bldObj.setLineHeight(self._build.getFloat("format.lineHeight"))
bldObj.setSynopsis(incSynopsis) bldObj.setSynopsis(self._build.getBool("text.includeSynopsis"))
bldObj.setComments(incComments) bldObj.setComments(self._build.getBool("text.includeComments"))
bldObj.setKeywords(incKeywords) bldObj.setKeywords(self._build.getBool("text.includeKeywords"))
bldObj.setBodyText(incBodyText) bldObj.setBodyText(self._build.getBool("text.includeBodyText"))
if isinstance(bldObj, ToHtml): if isinstance(bldObj, ToHtml):
bldObj.setStyles(htmlAddStyles) bldObj.setStyles(self._build.getBool("html.addStyles"))
bldObj.setReplaceUnicode(replaceUCode) bldObj.setReplaceUnicode(self._build.getBool("format.stripUnicode"))
if isinstance(bldObj, ToOdt): if isinstance(bldObj, ToOdt):
bldObj.setColourHeaders(odtAddColours) bldObj.setColourHeaders(self._build.getBool("odt.addColours"))
bldObj.setLanguage(buildLang) bldObj.setLanguage(buildLang)
filtered = self._build.buildItemFilter(self._project, withRoots=noteHeadings) filtered = self._build.buildItemFilter(
self._project, withRoots=self._build.getBool("text.addNoteHeadings")
)
return filtered return filtered