diff options
Diffstat (limited to 'sphinx/builders/changes.py')
-rw-r--r-- | sphinx/builders/changes.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/sphinx/builders/changes.py b/sphinx/builders/changes.py index 3f9bffa0d..888a011da 100644 --- a/sphinx/builders/changes.py +++ b/sphinx/builders/changes.py @@ -9,12 +9,9 @@ :license: BSD, see LICENSE for details. """ -import codecs from os import path from typing import cast -from six import iteritems - from sphinx import package_dir from sphinx.builders import Builder from sphinx.domains.changeset import ChangeSetDomain @@ -109,15 +106,17 @@ class ChangesBuilder(Builder): 'version': version, 'docstitle': self.config.html_title, 'shorttitle': self.config.html_short_title, - 'libchanges': sorted(iteritems(libchanges)), + 'libchanges': sorted(libchanges.items()), 'apichanges': sorted(apichanges), - 'otherchanges': sorted(iteritems(otherchanges)), + 'otherchanges': sorted(otherchanges.items()), 'show_copyright': self.config.html_show_copyright, 'show_sphinx': self.config.html_show_sphinx, } - with codecs.open(path.join(self.outdir, 'index.html'), 'w', 'utf8') as f: # type: ignore # NOQA + with open(path.join(self.outdir, 'index.html'), 'w', # type: ignore + encoding='utf8') as f: f.write(self.templates.render('changes/frameset.html', ctx)) - with codecs.open(path.join(self.outdir, 'changes.html'), 'w', 'utf8') as f: # type: ignore # NOQA + with open(path.join(self.outdir, 'changes.html'), 'w', # type: ignore + encoding='utf8') as f: f.write(self.templates.render('changes/versionchanges.html', ctx)) hltext = ['.. versionadded:: %s' % version, @@ -135,8 +134,8 @@ class ChangesBuilder(Builder): logger.info(bold(__('copying source files...'))) for docname in self.env.all_docs: - with codecs.open(self.env.doc2path(docname), 'r', # type: ignore - self.env.config.source_encoding) as f: + with open(self.env.doc2path(docname), 'r', # type: ignore + encoding=self.env.config.source_encoding) as f: try: lines = f.readlines() except UnicodeDecodeError: @@ -144,7 +143,7 @@ class ChangesBuilder(Builder): continue targetfn = path.join(self.outdir, 'rst', os_path(docname)) + '.html' ensuredir(path.dirname(targetfn)) - with codecs.open(targetfn, 'w', 'utf-8') as f: # type: ignore + with open(targetfn, 'w', encoding='utf-8') as f: # type: ignore text = ''.join(hl(i + 1, line) for (i, line) in enumerate(lines)) ctx = { 'filename': self.env.doc2path(docname, None), @@ -152,7 +151,7 @@ class ChangesBuilder(Builder): } f.write(self.templates.render('changes/rstsource.html', ctx)) themectx = dict(('theme_' + key, val) for (key, val) in - iteritems(self.theme.get_options({}))) + self.theme.get_options({}).items()) copy_asset_file(path.join(package_dir, 'themes', 'default', 'static', 'default.css_t'), self.outdir, context=themectx, renderer=self.templates) copy_asset_file(path.join(package_dir, 'themes', 'basic', 'static', 'basic.css'), |