From c9601ae83b771684d36e4d71856e3c21463faff5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 Jan 2012 20:08:48 +0530 Subject: [PATCH] Build process checking for coffeescript --- setup/check.py | 24 +++++++++++++++---- src/calibre/ebooks/oeb/display/cfi.coffee | 10 +++++++- .../ebooks/oeb/display/test/index.html | 5 +++- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/setup/check.py b/setup/check.py index 9142de27c1..538f33289c 100644 --- a/setup/check.py +++ b/setup/check.py @@ -63,11 +63,14 @@ class Check(Command): for f in x[-1]: y = self.j(x[0], f) mtime = os.stat(y).st_mtime - if (f.endswith('.py') and f not in ('ptempfile.py', 'feedparser.py', + if cache.get(y, 0) == mtime: + continue + if (f.endswith('.py') and f not in ('feedparser.py', 'pyparsing.py', 'markdown.py') and - 'genshi' not in y and cache.get(y, 0) != mtime and 'prs500/driver.py' not in y): yield y, mtime + if f.endswith('.coffee'): + yield y, mtime for x in os.walk(self.j(self.d(self.SRC), 'recipes')): for f in x[-1]: @@ -84,9 +87,20 @@ class Check(Command): builtins = list(set_builtins(self.BUILTINS)) for f, mtime in self.get_files(cache): self.info('\tChecking', f) - w = check_for_python_errors(open(f, 'rb').read(), f) - if w: - self.report_errors(w) + errors = False + ext = os.path.splitext(f)[1] + if ext in {'.py', '.recipe'}: + w = check_for_python_errors(open(f, 'rb').read(), f) + if w: + errors = True + self.report_errors(w) + else: + try: + subprocess.check_call(['coffee', '-c', '-p', f], + stdout=open(os.devnull, 'wb')) + except: + errors = True + if errors: cPickle.dump(cache, open(self.CACHE, 'wb'), -1) subprocess.call(['gvim', '-f', f]) raise SystemExit(1) diff --git a/src/calibre/ebooks/oeb/display/cfi.coffee b/src/calibre/ebooks/oeb/display/cfi.coffee index 1bb2533485..511f8fa300 100644 --- a/src/calibre/ebooks/oeb/display/cfi.coffee +++ b/src/calibre/ebooks/oeb/display/cfi.coffee @@ -133,7 +133,15 @@ find_offset_for_point = (x, y, node, cdoc) -> class CanonicalFragmentIdentifier # This class is a namespace to expose CFI functions via the window.cfi - # object + # object. The three most important functions are: + # + # is_compatible(): Throws an error if the browser is not compatible with + # this script + # + # at(x, y): which maps a point to a CFI, if possible + # + # scroll_to(cfi): which scrolls the browser to a point corresponding to the + # given cfi, and returns the x and y co-ordinates of the point. constructor: () -> # {{{ this.CREATE_RANGE_ERR = "Your browser does not support the createRange function. Update it to a newer version." diff --git a/src/calibre/ebooks/oeb/display/test/index.html b/src/calibre/ebooks/oeb/display/test/index.html index afeae055a4..e5d8eea491 100644 --- a/src/calibre/ebooks/oeb/display/test/index.html +++ b/src/calibre/ebooks/oeb/display/test/index.html @@ -5,7 +5,10 @@