Commits

jacobmason committed da15dcb

an even nicer build directory

  • Participants
  • Parent commits 1d6aab0

Comments (0)

Files changed (2)

sphinx/builders/websupport.py

         # if there is a source file, copy the source file for the
         # "show source" link
         if ctx.get('sourcename'):
-            source_name = path.join(self.outdir, self.app.staticdir,
+            source_name = path.join(self.app.builddir, self.app.staticdir,
                                     '_sources',  os_path(ctx['sourcename']))
             ensuredir(path.dirname(source_name))
             copyfile(self.env.doc2path(pagename), source_name)
     def handle_finish(self):
         StandaloneHTMLBuilder.handle_finish(self)
         shutil.move(path.join(self.outdir, '_images'),
-                    path.join(self.outdir, self.app.staticdir, '_images'))
+                    path.join(self.app.builddir, self.app.staticdir,
+                              '_images'))
         shutil.move(path.join(self.outdir, '_static'),
-                    path.join(self.outdir, self.app.staticdir, '_static'))
+                    path.join(self.app.builddir, self.app.staticdir,
+                              '_static'))
 
     def dump_search_index(self):
         self.indexer.finish_indexing()

sphinx/websupport/__init__.py

 class WebSupportApp(Sphinx):
     def __init__(self, *args, **kwargs):
         self.staticdir = kwargs.pop('staticdir', None)
+        self.builddir = kwargs.pop('builddir', None)
         self.search = kwargs.pop('search', None)
         self.storage = kwargs.pop('storage', None)
         Sphinx.__init__(self, *args, **kwargs)
     """The main API class for the web support package. All interactions
     with the web support package should occur through this class.
     """
-    def __init__(self, srcdir='', outdir='', datadir='', search=None,
+    def __init__(self, srcdir='', builddir='', datadir='', search=None,
                  storage=None, status=sys.stdout, warning=sys.stderr,
                  moderation_callback=None, staticdir='static',
                  docroot=''):
         self.srcdir = srcdir
-        self.outdir = outdir or datadir
+        self.builddir = builddir
+        self.outdir = path.join(builddir, 'data')
+        self.datadir = datadir or self.outdir
         self.staticdir = staticdir.strip('/')
+        self.docroot = docroot.strip('/')
         self.status = status
         self.warning = warning
-        self.docroot = docroot.strip('/')
         self.moderation_callback = moderation_callback
 
         self._init_templating()
             from sphinx.websupport.storage.sqlalchemystorage \
                 import SQLAlchemyStorage
             from sqlalchemy import create_engine
-            db_path = path.join(self.outdir, 'db', 'websupport.db')
+            db_path = path.join(self.datadir, 'db', 'websupport.db')
             ensuredir(path.dirname(db_path))
             uri = storage or 'sqlite:///%s' % db_path
             engine = create_engine(uri)
             mod, cls = search_adapters[search or 'null']
             mod = 'sphinx.websupport.search.' + mod
             SearchClass = getattr(__import__(mod, None, None, [cls]), cls)
-            search_path = path.join(self.outdir, 'search')
+            search_path = path.join(self.datadir, 'search')
             self.search = SearchClass(search_path)
         self.results_template = \
             self.template_env.get_template('searchresults.html')
                             self.outdir, doctreedir, 'websupport',
                             search=self.search, status=self.status, 
                             warning=self.warning, storage=self.storage,
-                            staticdir=self.staticdir)
+                            staticdir=self.staticdir, builddir=self.builddir)
 
         self.storage.pre_build()
         app.build()
 
         :param docname: the name of the document to load.
         """
-        infilename = path.join(self.outdir, 'pickles', docname + '.fpickle')
+        infilename = path.join(self.datadir, 'pickles', docname + '.fpickle')
 
         try:
             f = open(infilename, 'rb')