mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 23:31:05 +07:00
PY-46321 Added Markdown code fence aliases for PyDocstring and Python
* PyDocstring: "pycon", "python-repl" * Python: "py", "python3" I've added the links to the documents describing popular references to `PyCodeFenceLanguageProvider`. GitOrigin-RevId: 6cafb15c9655434f5d69aa47eb7472b634364377
This commit is contained in:
committed by
intellij-monorepo-bot
parent
42327842df
commit
eaefde3c09
16
python/python-markdown/intellij.python.markdown.iml
Normal file
16
python/python-markdown/intellij.python.markdown.iml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="kotlin-stdlib-jdk8" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.markdown" />
|
||||
<orderEntry type="module" module-name="intellij.python.psi.impl" />
|
||||
<orderEntry type="module" module-name="intellij.python.psi" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,5 @@
|
||||
<idea-plugin>
|
||||
<extensions defaultExtensionNs="org.intellij.markdown">
|
||||
<fenceLanguageProvider implementation="com.jetbrains.python.markdown.PyCodeFenceLanguageProvider"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.jetbrains.python.markdown
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionParameters
|
||||
import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.lang.Language
|
||||
import com.jetbrains.python.PythonLanguage
|
||||
import com.jetbrains.python.documentation.doctest.PyDocstringLanguageDialect
|
||||
import org.intellij.plugins.markdown.injection.CodeFenceLanguageProvider
|
||||
|
||||
/**
|
||||
* Defines major Python dialects to use in Markdown code fence blocks.
|
||||
*
|
||||
* These dialects are listed as classes in [highlight.js][1] and in [Linguist][2] used by GitHub.
|
||||
*
|
||||
* [1]: https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md
|
||||
* [2]: https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
|
||||
*/
|
||||
class PyCodeFenceLanguageProvider : CodeFenceLanguageProvider {
|
||||
override fun getLanguageByInfoString(infoString: String): Language? =
|
||||
when (infoString.toLowerCase()) {
|
||||
"pycon", "python-repl" -> PyDocstringLanguageDialect.getInstance()
|
||||
"py", "python3" -> PythonLanguage.INSTANCE
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getCompletionVariantsForInfoString(parameters: CompletionParameters): List<LookupElement> = emptyList()
|
||||
}
|
||||
Reference in New Issue
Block a user