Georg Brandl  committed f03bf97

#513: Allow giving non-local URIs for JavaScript files, e.g. in the JSMath extension.

  • Participants
  • Parent commits 45f2780

Comments (0)

Files changed (6)

 Release 1.0.4 (in development)
+* #513: Allow giving non-local URIs for JavaScript files, e.g.
+  in the JSMath extension.
 * #512: Fix traceback when ``intersphinx_mapping`` is empty.

File doc/ext/appapi.rst

    Add *filename* to the list of JavaScript files that the default HTML template
    will include.  The filename must be relative to the HTML static path, see
-   :confval:`the docs for the config value <html_static_path>`.
+   :confval:`the docs for the config value <html_static_path>`.  A full URI with
+   scheme, like ````, is also supported.
    .. versionadded:: 0.5

File sphinx/

     def add_javascript(self, filename):
         from import StandaloneHTMLBuilder
-        StandaloneHTMLBuilder.script_files.append(
-            posixpath.join('_static', filename))
+        if '://' in filename:
+            StandaloneHTMLBuilder.script_files.append(filename)
+        else:
+            StandaloneHTMLBuilder.script_files.append(
+                posixpath.join('_static', filename))
     def add_stylesheet(self, filename):
         from import StandaloneHTMLBuilder

File sphinx/builders/

         def pathto(otheruri, resource=False,
-            if not resource:
+            if resource and '://' in otheruri:
+                # allow non-local resources given by scheme
+                return otheruri
+            elif not resource:
                 otheruri = self.get_target_uri(otheruri)
             uri = relative_uri(baseuri, otheruri) or '#'
             return uri

File tests/root/

     app.add_directive('clsdir', ClassDirective)
     app.add_object_type('userdesc', 'userdescrole', '%s (userdesc)',
                         userdesc_parse, objname='user desc')
+    app.add_javascript('file://moo.js')

File tests/

         (".//li/a[@href='search.html']/em", 'Search Page'),
         # custom sidebar only for contents
         (".//h4", 'Contents sidebar'),
+        # custom JavaScript
+        (".//script[@src='file://moo.js']", ''),
     'bom.html': [
         (".//title", " File with UTF-8 BOM"),