From 338ea42ed942f4d01723fdc58ecec5d188beb507 Mon Sep 17 00:00:00 2001 From: Simon Ruggier Date: Thu, 27 Apr 2017 14:05:48 -0400 Subject: [PATCH] docstrings: fix "Sphinx param with type" pattern (#807) * docstrings: fix "Sphinx param with type" pattern Previously, the pattern only matched if the parameter description followed on the same line, like so: :param type foo: A param named foo. However, it's also valid for the parameter description to be wrapped onto the next line, like so: :param type foo: A param named foo. This change updates the pattern to match the second example as well, and adds a test to verify this behaviour. Fixes #806. * Add Simon Ruggier to the AUTHORS file --- AUTHORS.txt | 1 + jedi/evaluate/docstrings.py | 2 +- test/completion/docstring.py | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 48cb385f..b5619dcb 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -42,6 +42,7 @@ Cristi Burcă (@scribu) bstaint (@bstaint) Mathias Rav (@Mortal) Daniel Fiterman (@dfit99) +Simon Ruggier (@sruggier) Note: (@user) means a github user name. diff --git a/jedi/evaluate/docstrings.py b/jedi/evaluate/docstrings.py index 1b7db0da..788decb0 100644 --- a/jedi/evaluate/docstrings.py +++ b/jedi/evaluate/docstrings.py @@ -29,7 +29,7 @@ from jedi.evaluate.iterable import SequenceLiteralContext, FakeSequence DOCSTRING_PARAM_PATTERNS = [ r'\s*:type\s+%s:\s*([^\n]+)', # Sphinx - r'\s*:param\s+(\w+)\s+%s:[^\n]+', # Sphinx param with type + r'\s*:param\s+(\w+)\s+%s:[^\n]*', # Sphinx param with type r'\s*@type\s+%s:\s*([^\n]+)', # Epydoc ] diff --git a/test/completion/docstring.py b/test/completion/docstring.py index 338080a4..88db52d1 100644 --- a/test/completion/docstring.py +++ b/test/completion/docstring.py @@ -49,6 +49,17 @@ def sphinxy2(a, b, x): #? sphinxy2() + +def sphinxy_param_type_wrapped(a): + """ + :param str a: + Some description wrapped onto the next line with no space after the + colon. + """ + #? str() + a + + # local classes -> github #370 class ProgramNode(): pass