Commits

masklinn committed 19526d0

Turns out Sphinx's add_stylesheet/add_javascript is not by-page, it's for the whole project

So there's no point in doing that lazily or anything, it just breaks stuff.

The setup needs to be performed on env-updated though, the BuildEnvironment is
not available yet during setup()

  • Participants
  • Parent commits ea75921

Comments (0)

Files changed (2)

patchqueue/__init__.py

 SERIES_KEY = 'series'
 
 def setup(app):
+    app.connect('env-updated', add_statics)
+
     app.add_directive('queue', Queue)
     app.add_directive('patch', Patch)
 
+def add_statics(app, env):
+    app.add_stylesheet('patchqueue.css')
+    app.add_javascript('patchqueue.js')
+    env.config.html_static_path.append(statics())
 
 statics = lambda *p: os.path.join(
     os.path.abspath(os.path.dirname(__file__)),
     'static', *p)
-def add_statics(env):
-    """ Adds styling for the 4 hook classes pq-patch, pq-section, pq-diff and
-    pq-file, as well as the scripting for toggling between the various content
-    panes of ``pq-patch``.
-
-    The output of each :rst:dir:`patch` is a tree with the shape::
-
-        .pq-patch
-            <file name>
-            .pq-section
-                code-block+
-            .pq-diff
-                code-block[diff]
-            .pq-file
-                code-block
-            <file name>
-            .pq-section
-                code-block+
-            .pq-diff
-                code-block[diff]
-            .pq-file
-                code-block
-            etc...
-    """
-    env.config.html_static_path.append(statics())
-    env.app.add_stylesheet('patchqueue.css')
-    env.app.add_javascript('patchqueue.js')
 
 class SphinxUI(object):
     verbose = False
         document = self.state.document
         env = document.settings.env
 
-        add_statics(env)
-
         relpath, series_file = env.relfn2path(self.arguments[0])
         patches_dir = os.path.dirname(series_file)
 
 
 setup(
     name='sphinx-patchqueue',
-    version='0.3.0',
+    version='0.3.1',
     packages = ['patchqueue'],
     package_data = {'patchqueue': ['static/*']},
     url='https://bitbucket.org/masklinn/sphinx-patchqueue',