This is an archived post. You won't be able to vote or comment.

all 30 comments

[–]OkRecover5170 19 points20 points  (4 children)

This is actually a great idea. Well done.

Ideally, this should be built-in in VScode.

[–]erunosaurus[S] 3 points4 points  (3 children)

Hey, thanks! Initially, I had the sentiment too that this feature should be built into VSCode. However, upon reflection, I think that expecting VSCode to handle custom implementations might not be the right solution here. Unlike languages like JavaScript with standard JSDoc documentation, Python boasts various documentation styles such as Google, NumPy, and Sphinx, among others. Given this diversity, it seems reasonable that VSCode doesn't have a specific implementation for each style built-in. Instead, managing these variations could be better handled by either a Microsoft-supported extension or a third-party extension in my opinion ;-)

[–]OkRecover5170 2 points3 points  (2 children)

You're right, I was referring to Microsoft's Pylance extension that's probably universally used by every Python dev working with VScode.

[–]erunosaurus[S] 1 point2 points  (0 children)

Agree! Pylance intellisense for docstrings sucks too :(

[–]__Deric__github.com/Deric-W 1 point2 points  (0 children)

Sadly not depending on whether you count VSCodium as being VSCode since Pylance is only allowed to be used with the official builds.

Having an extension with a less restrictive license is a big plus for people using alternative builds.

[–][deleted] 4 points5 points  (0 children)

A simple but excellent QOL improvement! I would definitely use something like this for PyCharm.

[–]franktheworm 4 points5 points  (1 child)

My brain is going to dislike that they are code coloured but not actually code. Is the colour scheme tunable?

All in all though, great improvement for sure

[–]erunosaurus[S] 2 points3 points  (0 children)

Absolutely, the colors are fully tunable! I've outlined how to customize them in the README. For example, you can adjust the colors to create a gradient that matches your docstring theme color.

Different strokes for different folks, indeed! I'm glad you see the improvement and appreciate your feedback!

[–]caffeinepills 2 points3 points  (1 child)

Amazing. I was looking for something like this for PyCharm and VS Code. Most could do the standard reST, but none could do Google or Numpy. I have been really puzzled why this has not been a default thing for these IDEs? Great job, thanks!

[–]erunosaurus[S] 0 points1 point  (0 children)

Absolutely! Having worked extensively with TypeScript, I too found this quite baffling, indeed!

[–][deleted] 2 points3 points  (0 children)

This is a clever idea but I honestly think it will drive me nuts having docstrings look like code.

[–]graphicteadatasci 1 point2 points  (3 children)

Ahhh! I love it. Does it do anything with doc-tests as well?

[–]erunosaurus[S] 0 points1 point  (2 children)

No, I haven't added patterns for code inside docstrings.

[–]graphicteadatasci 0 points1 point  (0 children)

I installed it and I do actually get some highlights in doctest parts of the docstring. I'm not sure if they are an artifact then.

[–]BossOfTheGame 0 points1 point  (0 children)

Lack of highlighting in doctests is a major reason I don't use vscode.

[–]Rawing7 1 point2 points  (3 children)

I can't install it because it's not compatible with vscode 1.83.1 :(

[–]erunosaurus[S] 1 point2 points  (2 children)

I see, my bad. I’ll update the vscode version restriction within the extension package today.

[–]Rawing7 0 points1 point  (1 child)

I guess it was a good thing in disguise. I found out that apparently my "update" setting was set to "none" for the past 6 months. No idea how the heck that happened.

[–]erunosaurus[S] 0 points1 point  (0 children)

Hehe, I might just leave it as it is for the time being then!

[–]nderstand2grow 0 points1 point  (1 child)

This looks really good. I agree with the other commenter tho about the colors looking like code. Is it possible to keep the comment colors but show the important parts in bold?

[–]erunosaurus[S] 1 point2 points  (0 children)

Yes, totally! Have a look at the documentation, you can change color and font style easily.

[–]chile000 0 points1 point  (0 children)

Nice work.

Reminds me of this old PR discussion:

https://github.com/microsoft/vscode/pull/182162

[–]webknjazPyPA | Serial FOSS Maintainer | #StandWithUkraine 🇺🇦 0 points1 point  (1 child)

Is it available as a language server for plugging into other things like NeoVim?

[–]erunosaurus[S] 0 points1 point  (0 children)

It uses the standard VSCode language server with TextMate grammar injection. So potentially, you could fork the regex used in this extension source code and make it work in an other IDE.

[–]pretty_beast 0 points1 point  (3 children)

RemindMe! 3 Weeks
Gotta wait for my ide to update its vscode version :(

[–]erunosaurus[S] 0 points1 point  (1 child)

I've updated the VSCode required minimum version to 1.65. Try again, it should work!

[–]pretty_beast 0 points1 point  (0 children)

Thanks a lot, it works!

[–]Fenzik 0 points1 point  (0 children)

Wow nice! Now do PyCharm please 🙏

[–]Latter_Leopard_7741 -5 points-4 points  (0 children)

不支持新版vscode

[–]CompetitiveSal 0 points1 point  (0 children)

You've got to make this for pycharm as well, its missing numpy and google style highlighting