`BuildEnvironment.set_warnfunc()` is now deprecated

This commit is contained in:
Takeshi KOMIYA committed 2017-01-23 21:52:31 +09:00
1 parent fd2b3ec529
commit c2f78b6870
3 files changed
+5 -15

No files matched your search

+1
View File
@@ -57,6 +57,7 @@ Deprecated
instead (as Sphinx does since 1.5.)
* ``Sphinx.status_iterator()` and ``Sphinx.old_status_iterator()`` is now
deprecated. Please use ``sphinx.util:status_iterator()`` intead.
* ``BuildEnvironment.set_warnfunc()`` is now deprecated
Release 1.5.3 (in development)
==============================
-2
View File
@@ -292,7 +292,6 @@ class Sphinx(object):
# type: (bool) -> None
if freshenv:
self.env = BuildEnvironment(self.srcdir, self.doctreedir, self.config)
self.env.set_warnfunc(self.warn)
self.env.find_files(self.config, self.buildername)
for domain in self.domains.keys():
self.env.domains[domain] = self.domains[domain](self.env)
@@ -301,7 +300,6 @@ class Sphinx(object):
logger.info(bold('loading pickled environment... '), nonl=True)
self.env = BuildEnvironment.frompickle(
self.srcdir, self.config, path.join(self.doctreedir, ENV_PICKLE_FILENAME))
self.env.set_warnfunc(self.warn)
self.env.init_managers()
self.env.domains = {}
for domain in self.domains.keys():
+4 -13
View File
@@ -16,6 +16,7 @@ import time
import types
import codecs
import fnmatch
import warnings
from os import path
from glob import glob
from collections import defaultdict
@@ -49,6 +50,7 @@ from sphinx.util.websupport import is_commentable
from sphinx.errors import SphinxError, ExtensionError
from sphinx.versioning import add_uids, merge_doctrees
from sphinx.transforms import SphinxContentsFilter
from sphinx.deprecation import RemovedInSphinx20Warning
from sphinx.environment.managers.indexentries import IndexEntries
from sphinx.environment.managers.toctree import Toctree
@@ -122,8 +124,6 @@ class BuildEnvironment(object):
def topickle(self, filename):
# type: (unicode) -> None
# remove unpicklable attributes
warnfunc = self._warnfunc
self.set_warnfunc(None)
values = self.config.values
del self.config.values
domains = self.domains
@@ -142,7 +142,6 @@ class BuildEnvironment(object):
self.attach_managers(managers)
self.domains = domains
self.config.values = values
self.set_warnfunc(warnfunc)
# --------- ENVIRONMENT INITIALIZATION -------------------------------------
@@ -272,8 +271,8 @@ class BuildEnvironment(object):
def set_warnfunc(self, func):
# type: (Callable) -> None
self._warnfunc = func
self.settings['warning_stream'] = WarningStream(func)
warnings.warn('env.set_warnfunc() is now deprecated. Use sphinx.util.logging instead.',
RemovedInSphinx20Warning)
def set_versioning_method(self, method, compare):
# type: (unicode, bool) -> None
@@ -639,12 +638,9 @@ class BuildEnvironment(object):
def read_process(docs):
# type: (List[unicode]) -> BuildEnvironment
self.app = app
self.warnings = [] # type: List[Tuple]
self.set_warnfunc(lambda *args, **kwargs: self.warnings.append((args, kwargs)))
for docname in docs:
self.read_doc(docname, app)
# allow pickling self to send it back
self.set_warnfunc(None)
del self.app
del self.domains
del self.config.values
@@ -653,13 +649,11 @@ class BuildEnvironment(object):
def merge(docs, otherenv):
# type: (List[unicode], BuildEnvironment) -> None
warnings.extend(otherenv.warnings)
self.merge_info_from(docs, otherenv, app)
tasks = ParallelTasks(nproc)
chunks = make_chunks(docnames, nproc)
warnings = [] # type: List[Tuple]
for chunk in status_iterator(chunks, 'reading sources... ', "purple",
len(chunks), self.app.verbosity):
tasks.add_task(read_process, chunk, merge)
@@ -668,9 +662,6 @@ class BuildEnvironment(object):
logger.info(bold('waiting for workers...'))
tasks.join()
for warning, kwargs in warnings:
self._warnfunc(*warning, **kwargs)
def check_dependents(self, already):
# type: (Set[unicode]) -> Iterator[unicode]
to_rewrite = (self.toctree.assign_section_numbers() + # type: ignore