mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-16761 In Google code style requires section title to be capitalized, so "Args:" and "args:" don't clash
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package com.jetbrains.python.documentation;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.toolbox.Substring;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -120,8 +121,9 @@ public class GoogleCodeStyleDocString extends SectionBasedDocString {
|
||||
final Substring line = getLine(lineNum);
|
||||
final Matcher matcher = SECTION_HEADER.matcher(line);
|
||||
if (matcher.matches()) {
|
||||
@NonNls final Substring title = line.getMatcherGroup(matcher, 1).trim();
|
||||
if (SECTION_NAMES.contains(title.toString().toLowerCase())) {
|
||||
final Substring title = line.getMatcherGroup(matcher, 1).trim();
|
||||
@NonNls final String titleText = title.toString();
|
||||
if (StringUtil.isCapitalized(titleText) && SECTION_NAMES.contains(titleText.toLowerCase())) {
|
||||
return Pair.create(title, lineNum + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
def func(x, *args):
|
||||
"""
|
||||
Args:
|
||||
x:
|
||||
args:
|
||||
"""
|
||||
@@ -319,6 +319,15 @@ public class PySectionBasedDocStringTest extends PyTestCase {
|
||||
assertEquals("Something", returnSection.getFields().get(0).getType());
|
||||
}
|
||||
|
||||
public void testGoogleParamNamedLikeSection() {
|
||||
final GoogleCodeStyleDocString docString = findAndParseGoogleStyleDocString();
|
||||
assertSize(1, docString.getSections());
|
||||
final Section paramSection = docString.getSections().get(0);
|
||||
assertSize(2, paramSection.getFields());
|
||||
assertEquals("x", paramSection.getFields().get(0).getName());
|
||||
assertEquals("args", paramSection.getFields().get(1).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return super.getTestDataPath() + "/docstrings";
|
||||
|
||||
Reference in New Issue
Block a user