Search in sources :

Example 1 with PyDocumentationSettings

use of com.jetbrains.python.documentation.PyDocumentationSettings in project intellij-community by JetBrains.

the class PyQuickDocTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    // the provider is stateless, can be reused, as in real life
    myProvider = new PythonDocumentationProvider();
    final PyDocumentationSettings documentationSettings = PyDocumentationSettings.getInstance(myFixture.getModule());
    myFormat = documentationSettings.getFormat();
    documentationSettings.setFormat(DocStringFormat.PLAIN);
}
Also used : PythonDocumentationProvider(com.jetbrains.python.documentation.PythonDocumentationProvider) PyDocumentationSettings(com.jetbrains.python.documentation.PyDocumentationSettings)

Example 2 with PyDocumentationSettings

use of com.jetbrains.python.documentation.PyDocumentationSettings in project intellij-community by JetBrains.

the class PySmartEnterTest method testDocRest.

public void testDocRest() {
    CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
    boolean oldStubOnEnter = codeInsightSettings.JAVADOC_STUB_ON_ENTER;
    codeInsightSettings.JAVADOC_STUB_ON_ENTER = true;
    PyDocumentationSettings documentationSettings = PyDocumentationSettings.getInstance(myFixture.getModule());
    documentationSettings.setFormat(DocStringFormat.REST);
    try {
        doTest();
    } finally {
        documentationSettings.setFormat(DocStringFormat.PLAIN);
        codeInsightSettings.JAVADOC_STUB_ON_ENTER = oldStubOnEnter;
    }
}
Also used : CodeInsightSettings(com.intellij.codeInsight.CodeInsightSettings) PyCodeInsightSettings(com.jetbrains.python.codeInsight.PyCodeInsightSettings) PyDocumentationSettings(com.jetbrains.python.documentation.PyDocumentationSettings)

Example 3 with PyDocumentationSettings

use of com.jetbrains.python.documentation.PyDocumentationSettings in project intellij-community by JetBrains.

the class PythonCompletionTest method testEpydocTags.

public void testEpydocTags() {
    final PyDocumentationSettings settings = PyDocumentationSettings.getInstance(myFixture.getModule());
    settings.setFormat(DocStringFormat.EPYTEXT);
    try {
        myFixture.configureByFile("epydocTags.py");
        myFixture.completeBasic();
        final List<String> lookupElementStrings = myFixture.getLookupElementStrings();
        assertNotNull(lookupElementStrings);
        assertTrue(lookupElementStrings.contains("@param"));
    } finally {
        settings.setFormat(DocStringFormat.PLAIN);
    }
}
Also used : PyDocumentationSettings(com.jetbrains.python.documentation.PyDocumentationSettings)

Example 4 with PyDocumentationSettings

use of com.jetbrains.python.documentation.PyDocumentationSettings in project intellij-community by JetBrains.

the class PythonCompletionTest method testIdentifiersInPlainDocstring.

public void testIdentifiersInPlainDocstring() {
    final PyDocumentationSettings settings = PyDocumentationSettings.getInstance(myFixture.getModule());
    settings.setFormat(DocStringFormat.PLAIN);
    myFixture.configureByFile("identifiersInPlainDocstring.py");
    final LookupElement[] elements = myFixture.completeBasic();
    assertNotNull(elements);
    assertContainsElements(Lists.newArrayList(elements), LookupElementBuilder.create("bar").withAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE));
}
Also used : PyDocumentationSettings(com.jetbrains.python.documentation.PyDocumentationSettings) LookupElement(com.intellij.codeInsight.lookup.LookupElement)

Example 5 with PyDocumentationSettings

use of com.jetbrains.python.documentation.PyDocumentationSettings in project intellij-community by JetBrains.

the class DocStringUtil method getConfiguredDocStringFormat.

/**
   * @param anchor PSI element that will be used to retrieve docstring format from the containing file or the project module
   * @return docstring format configured for file or module containing given anchor PSI element
   * @see PyDocumentationSettings#getFormatForFile(PsiFile)
   */
@Nullable
public static DocStringFormat getConfiguredDocStringFormat(@NotNull PsiElement anchor) {
    final Module module = getModuleForElement(anchor);
    if (module == null) {
        return null;
    }
    final PyDocumentationSettings settings = PyDocumentationSettings.getInstance(module);
    return settings.getFormatForFile(anchor.getContainingFile());
}
Also used : Module(com.intellij.openapi.module.Module) PyDocumentationSettings(com.jetbrains.python.documentation.PyDocumentationSettings) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PyDocumentationSettings (com.jetbrains.python.documentation.PyDocumentationSettings)14 CodeInsightSettings (com.intellij.codeInsight.CodeInsightSettings)3 PyCodeInsightSettings (com.jetbrains.python.codeInsight.PyCodeInsightSettings)3 DocStringFormat (com.jetbrains.python.documentation.docstrings.DocStringFormat)2 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 ModalityState (com.intellij.openapi.application.ModalityState)1 Module (com.intellij.openapi.module.Module)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 PythonDocumentationProvider (com.jetbrains.python.documentation.PythonDocumentationProvider)1 PythonSdkType (com.jetbrains.python.sdk.PythonSdkType)1 Collection (java.util.Collection)1 List (java.util.List)1 Nullable (org.jetbrains.annotations.Nullable)1