From 79a17fa4ef3d4f436ef401005efaf28eaef2b071 Mon Sep 17 00:00:00 2001 From: arigo Date: Wed, 14 Feb 2007 14:57:46 +0100 Subject: [PATCH] [svn r38828] Try harder to get the logic right to avoid regenerating html files for unmodified txts. --HG-- branch : trunk --- py/doc/confrest.py | 8 ++++++-- py/doc/conftest.py | 13 +++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/py/doc/confrest.py b/py/doc/confrest.py index 10f61e4fe..8132e7db8 100644 --- a/py/doc/confrest.py +++ b/py/doc/confrest.py @@ -126,12 +126,16 @@ class Project: def get_docpath(self): return get_docpath() + def get_htmloutputpath(self, txtpath): + docpath = self.get_docpath() + reloutputpath = txtpath.new(ext='.html').relto(self.mydir) + return docpath.join(reloutputpath) + def process(self, txtpath): encoding = self.encoding content = self.get_content(txtpath, encoding) docpath = self.get_docpath() - reloutputpath = txtpath.new(ext='.html').relto(self.mydir) - outputpath = docpath.join(reloutputpath) + outputpath = self.get_htmloutputpath(txtpath) stylesheet = self.stylesheet if isinstance(self.stylesheet, py.path.local): diff --git a/py/doc/conftest.py b/py/doc/conftest.py index 60b7c4191..142b4344b 100644 --- a/py/doc/conftest.py +++ b/py/doc/conftest.py @@ -73,7 +73,6 @@ def restcheck(path): localpath = path if hasattr(path, 'localpath'): localpath = path.localpath - _checkskip(localpath) checkdocutils() import docutils.utils @@ -82,11 +81,14 @@ def restcheck(path): for x in cur.parts(reverse=True): confrest = x.dirpath('confrest.py') if confrest.check(file=1): - confrest = confrest.pyimport() - confrest.Project().process(path) + confrest = confrest.pyimport() + project = confrest.Project() + _checkskip(path, project.get_htmloutputpath(path)) + project.process(path) break else: # defer to default processor + _checkskip(path) rest.process(path) except KeyboardInterrupt: raise @@ -94,10 +96,10 @@ def restcheck(path): # we assume docutils printed info on stdout py.test.fail("docutils processing failed, see captured stderr") -def _checkskip(lpath): +def _checkskip(lpath, htmlpath=None): if not option.forcegen: if lpath.ext == '.txt': - htmlpath = get_docpath().join(lpath.new(ext='.html').relto(mypath)) + htmlpath = htmlpath or lpath.new(ext='.html') if htmlpath.check(file=1) and htmlpath.mtime() >= lpath.mtime(): py.test.skip("html file is up to date, use --forcegen to regenerate") #return [] # no need to rebuild @@ -105,7 +107,6 @@ def _checkskip(lpath): class ReSTSyntaxTest(py.test.collect.Item): def run(self): mypath = self.fspath - _checkskip(mypath) restcheck(py.path.svnwc(mypath)) class DoctestText(py.test.collect.Item):