From 25f6234cf04baee0f6a2628aa64b7d7b84b53b84 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Thu, 1 Dec 2022 16:12:25 +0100 Subject: [PATCH] Add a new module for a document build class --- novelwriter/core/coretools.py | 1 + novelwriter/mbuild/__init__.py | 3 ++ novelwriter/mbuild/docbuild.py | 88 ++++++++++++++++++++++++++++++++++ novelwriter/tools/build.py | 2 +- 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 novelwriter/mbuild/__init__.py create mode 100644 novelwriter/mbuild/docbuild.py diff --git a/novelwriter/core/coretools.py b/novelwriter/core/coretools.py index 8434626d..970e5b42 100644 --- a/novelwriter/core/coretools.py +++ b/novelwriter/core/coretools.py @@ -6,6 +6,7 @@ A collection of tools to create and manipulate documents File History: Created: 2022-10-02 [2.0rc1] DocMerger Created: 2022-10-11 [2.0rc1] DocSplitter +Created: 2022-11-03 [2.0rc2] ProjectBuilder This file is a part of novelWriter Copyright 2018–2022, Veronica Berglyd Olsen diff --git a/novelwriter/mbuild/__init__.py b/novelwriter/mbuild/__init__.py new file mode 100644 index 00000000..5a2fd13d --- /dev/null +++ b/novelwriter/mbuild/__init__.py @@ -0,0 +1,3 @@ +""" +novelWriter – Manuscript Build Init File +""" diff --git a/novelwriter/mbuild/docbuild.py b/novelwriter/mbuild/docbuild.py new file mode 100644 index 00000000..cc9f8585 --- /dev/null +++ b/novelwriter/mbuild/docbuild.py @@ -0,0 +1,88 @@ +""" +novelWriter – Build Document Tool +================================= +A class to build one or more novelWriter files to a single document + +File History: +Created: 2022-12-01 [2.1b1] + +This file is a part of novelWriter +Copyright 2018–2022, Veronica Berglyd Olsen + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + +import logging + +logger = logging.getLogger(__name__) + + +class NWBuildDocument: + + def __init__(self, project): + + self._project = project + self._build = {} + self._documents = [] + + return + + ## + # Properties + ## + + @property + def buildLength(self): + return len(self._documents) + + ## + # Setters + ## + + def setBuildConfig(self, config): + """Set the build config dictionary. + """ + self._build = config + return + + def addDocument(self, tHandle): + """Add a document to the build queue. + """ + self._documents.append(tHandle) + return + + ## + # Methods + ## + + def buildOpenDocument(self, fileName, isFlat): + pass + + def buildHTML(self, fileName): + pass + + def buildMarkdown(self, fileName, mdFlavour): + pass + + ## + # Internal Functions + ## + + def _setupBuild(self, bldObj): + pass + + def _doBuild(self, tHandle): + pass + +# END Class NWBuildDocument diff --git a/novelwriter/tools/build.py b/novelwriter/tools/build.py index 4b2a940c..6879089a 100644 --- a/novelwriter/tools/build.py +++ b/novelwriter/tools/build.py @@ -682,7 +682,7 @@ class GuiBuildNovel(QDialog): return def _doBuild(self, bldObj, isPreview=False, doConvert=True): - """Rund the build with a specific build object. + """Run the build with a specific build object. """ tStart = int(time())