diff --git a/CHANGES b/CHANGES index ce7811196..049d981bb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ Release 1.0 (in development) ============================ +* #200: Added ``Sphinx.add_stylesheet()``. + * Added ``titlesonly`` option to ``toctree`` directive. * Removed the deprecated ``sphinx.builder`` module. diff --git a/doc/ext/appapi.rst b/doc/ext/appapi.rst index 6864d6bac..0a3dae8fb 100644 --- a/doc/ext/appapi.rst +++ b/doc/ext/appapi.rst @@ -205,6 +205,14 @@ the following public API: .. versionadded:: 0.5 +.. method:: Sphinx.add_stylesheet(filename) + + Add *filename* to the list of CSS files that the default HTML template will + include. Like for :meth:`add_javascript`, the filename must be relative to + the HTML static path. + + .. versionadded:: 1.0 + .. method:: Sphinx.add_lexer(alias, lexer) Use *lexer*, which must be an instance of a Pygments lexer class, to diff --git a/sphinx/application.py b/sphinx/application.py index 7e926e572..b9c56d9f3 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -323,6 +323,11 @@ class Sphinx(object): StandaloneHTMLBuilder.script_files.append( posixpath.join('_static', filename)) + def add_stylesheet(self, filename): + from sphinx.builders.html import StandaloneHTMLBuilder + StandaloneHTMLBuilder.css_files.append( + posixpath.join('_static', filename)) + def add_lexer(self, alias, lexer): from sphinx.highlighting import lexers if lexers is None: diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 1edfd7231..0fc652a04 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -71,6 +71,8 @@ class StandaloneHTMLBuilder(Builder): # This is a class attribute because it is mutated by Sphinx.add_javascript. script_files = ['_static/jquery.js', '_static/doctools.js'] + # Dito for this one. + css_files = [] # cached publisher object for snippets _publisher = None @@ -264,6 +266,7 @@ class StandaloneHTMLBuilder(Builder): show_source = self.config.html_show_sourcelink, file_suffix = self.out_suffix, script_files = self.script_files, + css_files = self.css_files, sphinx_version = __version__, style = stylename, rellinks = rellinks, diff --git a/sphinx/themes/basic/layout.html b/sphinx/themes/basic/layout.html index 5aaaeff28..dfee95ad5 100644 --- a/sphinx/themes/basic/layout.html +++ b/sphinx/themes/basic/layout.html @@ -101,6 +101,9 @@