use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.Section in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method testNumpyEmptySectionIndent.
public void testNumpyEmptySectionIndent() {
final NumpyDocString docString = findAndParseNumpyStyleDocString();
assertSize(3, docString.getSections());
final Section paramSection = docString.getSections().get(0);
assertEquals("parameters", paramSection.getNormalizedTitle());
assertSize(2, paramSection.getFields());
final Section exampleSection = docString.getSections().get(1);
assertSize(1, exampleSection.getFields());
assertEquals("First sentence.\n" + "Second sentence.", exampleSection.getFields().get(0).getDescription());
final Section returnSection = docString.getSections().get(2);
assertSize(1, returnSection.getFields());
assertEquals("Something", returnSection.getFields().get(0).getType());
}
use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.Section in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method testGoogleMandatoryIndentationInsideSection.
// PY-16991
public void testGoogleMandatoryIndentationInsideSection() {
final GoogleCodeStyleDocString docString = findAndParseGoogleStyleDocString();
assertSize(3, docString.getSections());
assertEmpty(docString.getSections().get(0).getFields());
assertSize(1, docString.getSections().get(1).getFields());
final Section thirdSection = docString.getSections().get(2);
assertSize(1, thirdSection.getFields());
final SectionField firstExample = thirdSection.getFields().get(0);
assertEmpty(firstExample.getName());
assertEmpty(firstExample.getType());
assertEquals("first line\n" + "second line", firstExample.getDescription());
}
use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.Section in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method testNestedIndentation.
public void testNestedIndentation() {
final GoogleCodeStyleDocString docString = findAndParseGoogleStyleDocString();
assertSize(1, docString.getSections());
final Section section1 = docString.getSections().get(0);
assertEquals("parameters", section1.getNormalizedTitle());
assertSize(1, section1.getFields());
final SectionField param1 = section1.getFields().get(0);
assertEquals("x", param1.getName());
assertEquals("int", param1.getType());
assertEquals("first line of the description\n" + "second line\n" + " third line\n" + "\n" + "Example::\n" + "\n" + " assert func(42) is None", param1.getDescription());
}
use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.Section in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method testGoogleReturnTypeNoDescription.
public void testGoogleReturnTypeNoDescription() {
final GoogleCodeStyleDocString docString = findAndParseGoogleStyleDocString();
assertSize(1, docString.getSections());
final Section returnSection = docString.getSections().get(0);
assertEquals("returns", returnSection.getNormalizedTitle());
assertSize(1, returnSection.getFields());
final SectionField return1 = returnSection.getFields().get(0);
assertEmpty(return1.getName());
assertEmpty(return1.getDescription());
assertEquals("object", return1.getType());
assertNotNull(return1.getTypeAsSubstring());
assertEquals(20, return1.getTypeAsSubstring().getStartOffset());
assertEquals(26, return1.getTypeAsSubstring().getEndOffset());
}
use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.Section in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method testNumpyMultipleReturns.
public void testNumpyMultipleReturns() {
final NumpyDocString docString = findAndParseNumpyStyleDocString();
assertSize(1, docString.getSections());
final Section returnSection = docString.getSections().get(0);
assertSize(2, returnSection.getFields());
}
Aggregations