diff --git a/tests/test_driver.py b/tests/test_driver.py index cc547fa..40bcf6c 100644 --- a/tests/test_driver.py +++ b/tests/test_driver.py @@ -424,7 +424,19 @@ class TestDriverScript(TestInventoryBase): tldp.driver.script(c, inv.all.values(), file=stdout) stdout.seek(0) data = stdout.read() - self.assertTrue(c.linuxdoc_sgml2html in data) + self.assertTrue('Published-HOWTO' in data) + + def test_script_no_pubdir(self): + c = self.config + c.script = True + stdout = io.StringIO() + self.add_published('New-HOWTO', example.ex_linuxdoc) + c.pubdir = None + inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir) + tldp.driver.script(c, inv.all.values(), file=stdout) + stdout.seek(0) + data = stdout.read() + self.assertTrue('New-HOWTO' in data) def test_run_script(self): self.add_published('Published-HOWTO', example.ex_linuxdoc) diff --git a/tldp/doctypes/common.py b/tldp/doctypes/common.py index cffe58b..73d46e2 100644 --- a/tldp/doctypes/common.py +++ b/tldp/doctypes/common.py @@ -87,6 +87,8 @@ class BaseDoctype(object): def build_precheck(self): classname = self.__class__.__name__ + if self.config.script: + return True for tool, validator in self.required.items(): thing = getattr(self.config, tool, None) logger.debug("%s, tool = %s, thing = %s", classname, tool, thing) @@ -282,7 +284,8 @@ class BaseDoctype(object): # - chdir to output dir # - copy source images/resources to output dir # - opwd = os.getcwd() + if not self.config.script: + opwd = os.getcwd() if not self.build_prepare(): return False @@ -301,7 +304,8 @@ class BaseDoctype(object): else: self.hook_build_failure() - os.chdir(opwd) + if not self.config.script: + os.chdir(opwd) return result diff --git a/tldp/driver.py b/tldp/driver.py index 2286443..7cc3424 100644 --- a/tldp/driver.py +++ b/tldp/driver.py @@ -245,7 +245,11 @@ def post_publish_cleanup(docs): def prepare_docs_script_mode(config, docs): for source in docs: if not source.output: - source.working = OutputDirectory.fromsource(config.pubdir, source) + fromsource = OutputDirectory.fromsource + if not config.pubdir: + source.working = fromsource(source.dirname, source) + else: + source.working = fromsource(config.pubdir, source) else: source.working = source.output return True, None