summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-12-28 23:39:26 +0100
committerGeorg Brandl <georg@python.org>2008-12-28 23:39:26 +0100
commitc2f433988efc979a1d76e41d0ffc1ee33d2cda61 (patch)
tree1a10151ca466c8a4447931251c85946b7e8a123c
parent577a475e8cbb39e4b8ecf396e7507f18df91cff4 (diff)
downloadsphinx-c2f433988efc979a1d76e41d0ffc1ee33d2cda61.tar.gz
Some fixes and changelog entry after switch to Jinja2.
-rw-r--r--CHANGES5
-rw-r--r--sphinx/builders/__init__.py2
-rw-r--r--sphinx/builders/changes.py8
-rw-r--r--sphinx/jinja2glue.py (renamed from sphinx/_jinja2.py)26
-rw-r--r--sphinx/templates/changes/versionchanges.html2
5 files changed, 22 insertions, 21 deletions
diff --git a/CHANGES b/CHANGES
index d943d295..e5119355 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,11 @@ New features added
* Incompatible changes:
+ - Templating now requires the Jinja2 library, which is an enhanced
+ version of the old Jinja1 engine. Since the syntax and semantic
+ is largely the same, very few fixes should be necessary in
+ custom templates.
+
- The ``autodoc_skip_member`` event now also gets to decide
whether to skip members whose name starts with underscores.
Previously, these members were always automatically skipped.
diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py
index cb2f51f7..07b1657a 100644
--- a/sphinx/builders/__init__.py
+++ b/sphinx/builders/__init__.py
@@ -80,7 +80,7 @@ class Builder(object):
self.templates = self.app.import_object(
self.config.template_bridge, 'template_bridge setting')()
else:
- from sphinx._jinja2 import BuiltinTemplates
+ from sphinx.jinja2glue import BuiltinTemplates
self.templates = BuiltinTemplates()
self.templates.init(self)
diff --git a/sphinx/builders/changes.py b/sphinx/builders/changes.py
index 8665b6e7..047b0155 100644
--- a/sphinx/builders/changes.py
+++ b/sphinx/builders/changes.py
@@ -87,12 +87,12 @@ class ChangesBuilder(Builder):
'otherchanges': sorted(otherchanges.iteritems()),
'show_sphinx': self.config.html_show_sphinx,
}
- f = open(path.join(self.outdir, 'index.html'), 'w')
+ f = codecs.open(path.join(self.outdir, 'index.html'), 'w', 'utf8')
try:
f.write(self.templates.render('changes/frameset.html', ctx))
finally:
f.close()
- f = open(path.join(self.outdir, 'changes.html'), 'w')
+ f = codecs.open(path.join(self.outdir, 'changes.html'), 'w', 'utf8')
try:
f.write(self.templates.render('changes/versionchanges.html', ctx))
finally:
@@ -112,11 +112,11 @@ class ChangesBuilder(Builder):
self.info(bold('copying source files...'))
for docname in self.env.all_docs:
- f = open(self.env.doc2path(docname))
+ f = codecs.open(self.env.doc2path(docname), 'r', 'latin1')
lines = f.readlines()
targetfn = path.join(self.outdir, 'rst', os_path(docname)) + '.html'
ensuredir(path.dirname(targetfn))
- f = codecs.open(targetfn, 'w', 'utf8')
+ f = codecs.open(targetfn, 'w', 'latin1')
try:
text = ''.join(hl(i+1, line) for (i, line) in enumerate(lines))
ctx = {'filename': self.env.doc2path(docname, None), 'text': text}
diff --git a/sphinx/_jinja2.py b/sphinx/jinja2glue.py
index a6f23e28..996df70b 100644
--- a/sphinx/_jinja2.py
+++ b/sphinx/jinja2glue.py
@@ -1,15 +1,12 @@
# -*- coding: utf-8 -*-
-
"""
- sphinx._jinja2
- ==============
+ sphinx.jinja2glue
+ ~~~~~~~~~~~~~~~~~
- Glue code for jinja2.
+ Glue code for the jinja2 templating engine.
- :author: Sebastian Wiesner
- :contact: basti.wiesner@gmx.net
- :copyright: 2008 by Sebastian Wiesner
- :license: MIT
+ :copyright: 2008 by Sebastian Wiesner.
+ :license: BSD, see LICENSE for details.
"""
import codecs
@@ -28,17 +25,16 @@ class SphinxLoader(jinja2.BaseLoader):
def __init__(self, basepath, extpaths, encoding='utf-8'):
"""
- Creates a new loader for sphinx.
+ Create a new loader for sphinx.
- ``extpaths`` is a list of directories, which provide additional
- templates to sphinx.
+ *extpaths* is a list of directories, which provide additional templates
+ to sphinx.
- ``encoding`` is used to decode the templates into unicode strings.
+ *encoding* is used to decode the templates into unicode strings.
Defaults to utf-8.
- If ``basepath`` is set, this path is used to load sphinx core
- templates. If False, these templates are loaded from the sphinx
- package.
+ If *basepath* is set, this path is used to load sphinx core templates.
+ If False, these templates are loaded from the sphinx package.
"""
self.core_loader = jinja2.FileSystemLoader(basepath)
self.all_loaders = jinja2.ChoiceLoader(
diff --git a/sphinx/templates/changes/versionchanges.html b/sphinx/templates/changes/versionchanges.html
index 14d5efd3..09651bf1 100644
--- a/sphinx/templates/changes/versionchanges.html
+++ b/sphinx/templates/changes/versionchanges.html
@@ -1,4 +1,4 @@
-{% macro entries changes %}
+{% macro entries(changes) %}
<ul>{% for entry, docname, lineno in changes %}
<li><a href="rst/{{ docname }}.html#L{{ lineno-10 }}" target="src">{{ entry }}</a></li>
{% endfor %}</ul>