mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#200: Added `Sphinx.add_stylesheet()`.
This commit is contained in:
2
CHANGES
2
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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user