mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#513: Allow giving non-local URIs for JavaScript files, e.g. in the JSMath extension.
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -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.
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user