#200: Added `Sphinx.add_stylesheet()`.

This commit is contained in:
Georg Brandl
2009-06-16 21:05:20 +02:00
parent 57514d06da
commit 812455e32c
5 changed files with 21 additions and 0 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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:

View File

@@ -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,

View File

@@ -101,6 +101,9 @@
<title>{{ title|striptags }}{{ titlesuffix }}</title>
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
{%- for cssfile in css_files %}
<link rel="stylesheet" href="{{ pathto('_static/' + cssfile, 1) }}" type="text/css" />
{%- endfor %}
{%- if not embedded %}
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {