diff options
author | Gabi Davar <grizzly.nyo@gmail.com> | 2016-06-10 12:00:57 +0300 |
---|---|---|
committer | Gabi Davar <grizzly.nyo@gmail.com> | 2016-06-17 12:41:11 +0300 |
commit | c2ba7832e268a9e1cbd70a7bea431e39fe5ada7c (patch) | |
tree | 868a03e8addd72194024f50cf6527cecbddc9600 /sphinx/setup_command.py | |
parent | d4cdfc148b37a824832c732cbd0b08b098f75275 (diff) | |
download | sphinx-git-c2ba7832e268a9e1cbd70a7bea431e39fe5ada7c.tar.gz |
add --pdb support to setuptools command
Diffstat (limited to 'sphinx/setup_command.py')
-rw-r--r-- | sphinx/setup_command.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/sphinx/setup_command.py b/sphinx/setup_command.py index 128c1415c..0a29685a4 100644 --- a/sphinx/setup_command.py +++ b/sphinx/setup_command.py @@ -15,6 +15,8 @@ from __future__ import print_function import sys import os +import traceback + from distutils.cmd import Command from distutils.errors import DistutilsOptionError, DistutilsExecError @@ -78,11 +80,13 @@ class BuildDoc(Command): 'replacement for |today|'), ('link-index', 'i', 'Link index.html to the master doc'), ('copyright', None, 'The copyright string'), + ('pdb', None, 'Start pdb on exception'), ] boolean_options = ['fresh-env', 'all-files', 'link-index'] def initialize_options(self): self.fresh_env = self.all_files = False + self.pdb = False self.source_dir = self.build_dir = None self.builder = 'html' self.project = '' @@ -166,13 +170,20 @@ class BuildDoc(Command): raise DistutilsExecError( 'caused by %s builder.' % app.builder.name) except Exception as err: - from docutils.utils import SystemMessage - if isinstance(err, SystemMessage): - print(darkred('reST markup error:'), file=sys.stderr) - print(err.args[0].encode('ascii', 'backslashreplace'), + if self.pdb: + import pdb + print(darkred('Exception occurred while building, starting debugger:'), file=sys.stderr) + traceback.print_exc() + pdb.post_mortem(sys.exc_info()[2]) else: - raise + from docutils.utils import SystemMessage + if isinstance(err, SystemMessage): + print(darkred('reST markup error:'), file=sys.stderr) + print(err.args[0].encode('ascii', 'backslashreplace'), + file=sys.stderr) + else: + raise if self.link_index: src = app.config.master_doc + app.builder.out_suffix |