diff options
| author | Georg Brandl <georg@python.org> | 2010-08-25 10:26:15 +0000 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2010-08-25 10:26:15 +0000 |
| commit | 1fcacc70b7a1e5e341dd211c1c5fa99c4d91d926 (patch) | |
| tree | 3088e87f2efc19ea25631d45c17f200e8706c11d | |
| parent | 2fc131460c32f80df34dd14a54435da1caffa511 (diff) | |
| download | sphinx-1fcacc70b7a1e5e341dd211c1c5fa99c4d91d926.tar.gz | |
#513: Allow giving non-local URIs for JavaScript files, e.g. in the JSMath extension.
| -rw-r--r-- | CHANGES | 3 | ||||
| -rw-r--r-- | doc/ext/appapi.rst | 3 | ||||
| -rw-r--r-- | sphinx/application.py | 7 | ||||
| -rw-r--r-- | sphinx/builders/html.py | 5 | ||||
| -rw-r--r-- | tests/root/conf.py | 1 | ||||
| -rw-r--r-- | tests/test_build_html.py | 2 |
6 files changed, 17 insertions, 4 deletions
@@ -1,6 +1,9 @@ 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. diff --git a/doc/ext/appapi.rst b/doc/ext/appapi.rst index 2717c6a8..8f2a779b 100644 --- a/doc/ext/appapi.rst +++ b/doc/ext/appapi.rst @@ -246,7 +246,8 @@ the following public API: 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 ``http://example.org/foo.js``, is also supported. .. versionadded:: 0.5 diff --git a/sphinx/application.py b/sphinx/application.py index 97778d3f..11f887da 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -456,8 +456,11 @@ class Sphinx(object): def add_javascript(self, filename): from sphinx.builders.html 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 sphinx.builders.html import StandaloneHTMLBuilder diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 8d96c146..951f516d 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -678,7 +678,10 @@ class StandaloneHTMLBuilder(Builder): def pathto(otheruri, resource=False, baseuri=self.get_target_uri(pagename)): - 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 diff --git a/tests/root/conf.py b/tests/root/conf.py index 2b6d6a9a..a50029e5 100644 --- a/tests/root/conf.py +++ b/tests/root/conf.py @@ -91,3 +91,4 @@ def setup(app): app.add_directive('clsdir', ClassDirective) app.add_object_type('userdesc', 'userdescrole', '%s (userdesc)', userdesc_parse, objname='user desc') + app.add_javascript('file://moo.js') diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 01959278..991c9a30 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -205,6 +205,8 @@ HTML_XPATH = { (".//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"), |
