diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2009-09-25 18:50:30 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2009-09-25 18:50:30 +0000 |
| commit | 7eda7d5dcc48ded5db174f44e8d7cd9a7b84bff3 (patch) | |
| tree | b58e7aae2124085f4dbf4cafabdb87162ecfc9d5 /docutils | |
| parent | 614b6d4e3949d246282cd7fc68ad3da0ac78c017 (diff) | |
| download | docutils-7eda7d5dcc48ded5db174f44e8d7cd9a7b84bff3.tar.gz | |
Fix [ 2788716 ] DirectiveError now correctly reports source and line.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@6141 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
| -rw-r--r-- | docutils/HISTORY.txt | 1 | ||||
| -rw-r--r-- | docutils/RELEASE-NOTES.txt | 10 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/__init__.py | 14 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/states.py | 6 |
4 files changed, 24 insertions, 7 deletions
diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 428f933a1..db5286fbf 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -45,6 +45,7 @@ Changes Since 0.5 - Apply [ 2845002 ] let ``--no-raw`` disable raw *roles* too. - Fix [ 2831643 ] by renaming DirectiveError.message to DirectiveError.msg - Fix [ 2821266 ] --strict option works now like --halt=info. + - Fix [ 2788716 ] DirectiveError now correctly reports source and line. * reStructuredText: diff --git a/docutils/RELEASE-NOTES.txt b/docutils/RELEASE-NOTES.txt index 04cd20d5b..8bee3cb7f 100644 --- a/docutils/RELEASE-NOTES.txt +++ b/docutils/RELEASE-NOTES.txt @@ -26,6 +26,14 @@ Changes Since 0.5 Docutils 0.5 is the last version supporting Python 2.2, Docutils 0.6 requires Python 2.3 or newer. Also works with Python 3. +.. note:: + + The "newlatex" writer is orphaned. + + The recommended way to generate PDF output is to use either the + LaTeX2e writer or one of the alternatives listed at + http://docutils.sourceforge.net/docs/user/links.html#pdf. + * reStructuredText: - Allow length units for all length specifications. @@ -71,7 +79,7 @@ Changes Since 0.5 * manpage writer: - moved from sandbox to Doctutils core. - + Release 0.5 (2008-06-25) ======================== diff --git a/docutils/docutils/parsers/rst/__init__.py b/docutils/docutils/parsers/rst/__init__.py index 676be9f1e..64ef0b334 100644 --- a/docutils/docutils/parsers/rst/__init__.py +++ b/docutils/docutils/parsers/rst/__init__.py @@ -169,16 +169,18 @@ class DirectiveError(Exception): instead! """ - def __init__(self, level, message): + def __init__(self, level, message, source, line): """ Initialize with message `message`. `level` is a system message level. """ Exception.__init__(self) self.level = level self.msg = message + self.source = source + self.line = line -class Directive: +class Directive(object): """ Base class for reStructuredText directives. @@ -313,7 +315,13 @@ class Directive: You'd often use self.error(message) instead, which will generate an ERROR-level directive error. """ - return DirectiveError(level, message) + # source = self.state_machine.get_source(self.lineno - 1) + try: + (source, line) = self.state_machine.input_lines.info(self.lineno) + except IndexError: + source = self.state_machine.get_source(self.lineno - 1) + line = self.lineno + return DirectiveError(level, message, source, line) def debug(self, message): return self.directive_error(0, message) diff --git a/docutils/docutils/parsers/rst/states.py b/docutils/docutils/parsers/rst/states.py index 218adf474..687eb0baf 100644 --- a/docutils/docutils/parsers/rst/states.py +++ b/docutils/docutils/parsers/rst/states.py @@ -2060,9 +2060,9 @@ class Body(RSTState): content_offset, block_text, self, self.state_machine) try: result = directive_instance.run() - except docutils.parsers.rst.DirectiveError, directive_error: - msg_node = self.reporter.system_message(directive_error.level, - directive_error.msg) + except docutils.parsers.rst.DirectiveError, error: + msg_node = self.reporter.system_message(error.level, error.msg, + source=error.source, line=error.line) msg_node += nodes.literal_block(block_text, block_text) msg_node['line'] = lineno result = [msg_node] |
