mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Fix #2687: Uninstall sphinx directives and roles after build
This commit is contained in:
@@ -141,6 +141,7 @@ Bugs fixed
|
|||||||
* #1734: Could not translate the caption of toctree directive
|
* #1734: Could not translate the caption of toctree directive
|
||||||
* Could not translate the content of meta directive (ref: #1734)
|
* Could not translate the content of meta directive (ref: #1734)
|
||||||
* #2550: external links are opened in help viewer
|
* #2550: external links are opened in help viewer
|
||||||
|
* #2687: Running Sphinx multiple times produces 'already registered' warnings
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|||||||
+7
-5
@@ -23,6 +23,7 @@ from sphinx.errors import SphinxError
|
|||||||
from sphinx.application import Sphinx
|
from sphinx.application import Sphinx
|
||||||
from sphinx.util import Tee, format_exception_cut_frames, save_traceback
|
from sphinx.util import Tee, format_exception_cut_frames, save_traceback
|
||||||
from sphinx.util.console import red, nocolor, color_terminal
|
from sphinx.util.console import red, nocolor, color_terminal
|
||||||
|
from sphinx.util.docutils import docutils_namespace
|
||||||
from sphinx.util.osutil import abspath, fs_encoding
|
from sphinx.util.osutil import abspath, fs_encoding
|
||||||
from sphinx.util.pycompat import terminal_safe
|
from sphinx.util.pycompat import terminal_safe
|
||||||
|
|
||||||
@@ -288,11 +289,12 @@ def main(argv):
|
|||||||
|
|
||||||
app = None
|
app = None
|
||||||
try:
|
try:
|
||||||
app = Sphinx(srcdir, confdir, outdir, doctreedir, opts.builder,
|
with docutils_namespace():
|
||||||
confoverrides, status, warning, opts.freshenv,
|
app = Sphinx(srcdir, confdir, outdir, doctreedir, opts.builder,
|
||||||
opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
|
confoverrides, status, warning, opts.freshenv,
|
||||||
app.build(opts.force_all, filenames)
|
opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
|
||||||
return app.statuscode
|
app.build(opts.force_all, filenames)
|
||||||
|
return app.statuscode
|
||||||
except (Exception, KeyboardInterrupt) as exc:
|
except (Exception, KeyboardInterrupt) as exc:
|
||||||
handle_exception(app, opts, exc, error)
|
handle_exception(app, opts, exc, error)
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
+11
-9
@@ -23,6 +23,7 @@ from distutils.errors import DistutilsOptionError, DistutilsExecError
|
|||||||
from sphinx.application import Sphinx
|
from sphinx.application import Sphinx
|
||||||
from sphinx.cmdline import handle_exception
|
from sphinx.cmdline import handle_exception
|
||||||
from sphinx.util.console import nocolor, color_terminal
|
from sphinx.util.console import nocolor, color_terminal
|
||||||
|
from sphinx.util.docutils import docutils_namespace
|
||||||
from sphinx.util.osutil import abspath
|
from sphinx.util.osutil import abspath
|
||||||
|
|
||||||
|
|
||||||
@@ -165,15 +166,16 @@ class BuildDoc(Command):
|
|||||||
confoverrides['copyright'] = self.copyright
|
confoverrides['copyright'] = self.copyright
|
||||||
|
|
||||||
try:
|
try:
|
||||||
app = Sphinx(self.source_dir, self.config_dir,
|
with docutils_namespace():
|
||||||
self.builder_target_dir, self.doctree_dir,
|
app = Sphinx(self.source_dir, self.config_dir,
|
||||||
self.builder, confoverrides, status_stream,
|
self.builder_target_dir, self.doctree_dir,
|
||||||
freshenv=self.fresh_env,
|
self.builder, confoverrides, status_stream,
|
||||||
warningiserror=self.warning_is_error)
|
freshenv=self.fresh_env,
|
||||||
app.build(force_all=self.all_files)
|
warningiserror=self.warning_is_error)
|
||||||
if app.statuscode:
|
app.build(force_all=self.all_files)
|
||||||
raise DistutilsExecError(
|
if app.statuscode:
|
||||||
'caused by %s builder.' % app.builder.name)
|
raise DistutilsExecError(
|
||||||
|
'caused by %s builder.' % app.builder.name)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
handle_exception(app, self, exc, sys.stderr)
|
handle_exception(app, self, exc, sys.stderr)
|
||||||
if not self.pdb:
|
if not self.pdb:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
sphinx.util.docutils
|
||||||
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Utility functions for docutils.
|
||||||
|
|
||||||
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||||
|
:license: BSD, see LICENSE for details.
|
||||||
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
from copy import copy
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from docutils.parsers.rst import directives, roles
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def docutils_namespace():
|
||||||
|
"""Create namespace for reST parsers."""
|
||||||
|
try:
|
||||||
|
_directives = copy(directives._directives)
|
||||||
|
_roles = copy(roles._roles)
|
||||||
|
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
directives._directives = _directives
|
||||||
|
roles._roles = _roles
|
||||||
@@ -8,6 +8,8 @@
|
|||||||
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import codecs
|
import codecs
|
||||||
import posixpath
|
import posixpath
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user