Edit docstring as restructuredText (rst) fragment?
As I'm writing the docstring for a class, I notice the docstring is getting long and the muted text is harder to read, so I remember I can use the language injection feature to pop out the docstring into separate editor.
The first problem is that I cannot find reStructuredText in the list of languages to inject. Reading the docs, I come to the erroneous conclusion that I can set the language to "plain text" and use "suffix=.rst" to maybe convince it to open the fragment as rST.
Obviously, this isn't going to work in the end because that's not what "suffix" is used for, but I run into a more fundamental issue: How do I inject "plain text" with the "# language=..." directive?
I've searched here, Youtrack and the Internet at large and found no examples, but I've tried "plain", "text, "plain_text", "plain-text", "plaintext", '"plain text"' and "" (i.e., "language= ...") and none seem to work.
(I am judging "working" by changing it to something bogus like "sql", pressing Alt-Enter to see "Edit SQL Fragment", then changing it to the variation of "plain text", Alt-Enter again to see if there is an "Edit ... Fragment", which there never is.)
Finally: I found a plugin that enables overriding the language for an open file, so I can now manually mark my docstring as plain text, edit the fragment, then manually set it to "Rest language" (which seems to be rST). (https://plugins.jetbrains.com/plugin/7404-override-file-language)
AH-HAH: I can use # language=rst and I immediately get "Edit Rest language Fragment"! And I can (correctly) use prefix=" " so that the first line has the same indentation as the rest.
Please sign in to leave a comment.
Hi Wil! I created a feature request based on your feedback: PY-24441.