mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-17002 Suggest types inside unclosed parentheses in Google docstrings
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class GoogleCodeStyleDocString extends SectionBasedDocString {
|
||||
public static final Pattern SECTION_HEADER = Pattern.compile("^[ \t]*([\\w \t]+):[ \t]*$", Pattern.MULTILINE);
|
||||
private static final Pattern FIELD_NAME_AND_TYPE = Pattern.compile("^[ \t]*(.+?)[ \t]*\\([ \t]*(.*?)[ \t]*\\)[ \t]*$", Pattern.MULTILINE);
|
||||
private static final Pattern FIELD_NAME_AND_TYPE = Pattern.compile("^[ \t]*(.+?)[ \t]*\\([ \t]*(.*?)[ \t]*\\)?[ \t]*$", Pattern.MULTILINE);
|
||||
|
||||
public GoogleCodeStyleDocString(@NotNull Substring text) {
|
||||
super(text);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
def f():
|
||||
"""
|
||||
Args:
|
||||
x (str<caret>
|
||||
"""
|
||||
@@ -0,0 +1,6 @@
|
||||
def f(x, y):
|
||||
"""
|
||||
Args:
|
||||
x (Foo
|
||||
y (Bar : description
|
||||
"""
|
||||
@@ -378,6 +378,16 @@ public class PySectionBasedDocStringTest extends PyTestCase {
|
||||
"second line", firstExample.getDescription());
|
||||
}
|
||||
|
||||
// PY-17002
|
||||
public void testGoogleNoClosingParenthesisAfterParamType() {
|
||||
final GoogleCodeStyleDocString docString = findAndParseGoogleStyleDocString();
|
||||
assertSize(1, docString.getSections());
|
||||
final List<SectionField> params = docString.getSections().get(0).getFields();
|
||||
assertSize(2, params);
|
||||
assertEquals("Foo", params.get(0).getType());
|
||||
assertEquals("Bar", params.get(1).getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return super.getTestDataPath() + "/docstrings";
|
||||
|
||||
@@ -484,6 +484,18 @@ public class PythonCompletionTest extends PyTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
// PY-17002
|
||||
public void testParamTypeInGoogleDocstringWithoutClosingParenthesis() {
|
||||
runWithDocStringFormat(DocStringFormat.GOOGLE, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<String> variants = doTestByFile();
|
||||
assertNotNull(variants);
|
||||
assertSameElements(variants, "str", "basestring");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testPep328Completion() { // PY-3409
|
||||
myFixture.copyDirectoryToProject("pep328", "pep328");
|
||||
myFixture.configureByFile("pep328/package/subpackage1/moduleX.py");
|
||||
|
||||
Reference in New Issue
Block a user