From 955263d15247b87631859452944a7dbebaab9a98 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Thu, 24 Sep 2015 17:35:49 +0300 Subject: [PATCH] Dump full stacktrace in idea.log for errors during docstring rendering --- python/helpers/google_formatter.py | 11 ++---- python/helpers/numpy_formatter.py | 11 ++---- python/helpers/rest_formatter.py | 36 ++++++++----------- .../PyStructuredDocstringFormatter.java | 3 +- 4 files changed, 22 insertions(+), 39 deletions(-) diff --git a/python/helpers/google_formatter.py b/python/helpers/google_formatter.py index 3d8e021385a1..296e8a2a0f53 100644 --- a/python/helpers/google_formatter.py +++ b/python/helpers/google_formatter.py @@ -1,19 +1,14 @@ import sys - -from sphinxcontrib.napoleon.docstring import GoogleDocstring +import textwrap import rest_formatter +from sphinxcontrib.napoleon.docstring import GoogleDocstring def main(text=None): - try: src = sys.stdin.read() if text is None else text - import textwrap rest_formatter.main(str(GoogleDocstring(textwrap.dedent(src)))) - except: - exc_type, exc_value, exc_traceback = sys.exc_info() - sys.stderr.write("Error calculating docstring: " + str(exc_value)) if __name__ == '__main__': - main() + main() diff --git a/python/helpers/numpy_formatter.py b/python/helpers/numpy_formatter.py index fbbe0237a60c..9a02e31a33bb 100644 --- a/python/helpers/numpy_formatter.py +++ b/python/helpers/numpy_formatter.py @@ -1,19 +1,14 @@ import sys - -from sphinxcontrib.napoleon.docstring import NumpyDocstring +import textwrap import rest_formatter +from sphinxcontrib.napoleon.docstring import NumpyDocstring def main(text=None): - try: src = sys.stdin.read() if text is None else text - import textwrap rest_formatter.main(str(NumpyDocstring(textwrap.dedent(src)))) - except: - exc_type, exc_value, exc_traceback = sys.exc_info() - sys.stderr.write("Error calculating docstring: " + str(exc_value)) if __name__ == '__main__': - main() + main() diff --git a/python/helpers/rest_formatter.py b/python/helpers/rest_formatter.py index 0004967b6b64..0802ca6d212b 100644 --- a/python/helpers/rest_formatter.py +++ b/python/helpers/rest_formatter.py @@ -210,34 +210,28 @@ def parse_docstring(docstring, errors, **options): def main(text=None): - try: - src = sys.stdin.read() if text is None else text + src = sys.stdin.read() if text is None else text - errors = [] + errors = [] - class EmptyLinker(DocstringLinker): - def translate_indexterm(self, indexterm): - return "" + class EmptyLinker(DocstringLinker): + def translate_indexterm(self, indexterm): + return "" - def translate_identifier_xref(self, identifier, label=None): - return identifier + def translate_identifier_xref(self, identifier, label=None): + return identifier - docstring = parse_docstring(src, errors) - html = docstring.to_html(EmptyLinker()) + docstring = parse_docstring(src, errors) + html = docstring.to_html(EmptyLinker()) - if errors and not html: - sys.stderr.write("Error parsing docstring:\n") - for error in errors: - sys.stderr.write(str(error) + "\n") - sys.exit(1) - - sys.stdout.write(html) - sys.stdout.flush() - except: - exc_type, exc_value, exc_traceback = sys.exc_info() - sys.stderr.write("Error calculating docstring: " + str(exc_value)) + if errors and not html: + sys.stderr.write("Error parsing docstring:\n") + for error in errors: + sys.stderr.write(str(error) + "\n") sys.exit(1) + sys.stdout.write(html) + sys.stdout.flush() if __name__ == '__main__': main() diff --git a/python/src/com/jetbrains/python/documentation/docstrings/PyStructuredDocstringFormatter.java b/python/src/com/jetbrains/python/documentation/docstrings/PyStructuredDocstringFormatter.java index aa509a33f1a2..80ffbf8852dc 100644 --- a/python/src/com/jetbrains/python/documentation/docstrings/PyStructuredDocstringFormatter.java +++ b/python/src/com/jetbrains/python/documentation/docstrings/PyStructuredDocstringFormatter.java @@ -130,8 +130,7 @@ public class PyStructuredDocstringFormatter { return null; } else if (output.getExitCode() != 0) { - final String error = "error when calculating docstring: " + output.getStderr(); - LOG.info(error); + LOG.info("error when calculating docstring: " + output.getStderr()); return null; } return output.getStdout();