*/
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);
--- /dev/null
+def f():
+ """
+ Args:
+ x (str<caret>
+ """
\ No newline at end of file
--- /dev/null
+def f(x, y):
+ """
+ Args:
+ x (Foo
+ y (Bar : description
+ """
\ No newline at end of file
"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";
});
}
+ // 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");