Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "fold all docstrings" command #4677

Closed
rchiodo opened this issue Aug 1, 2023 Discussed in #3933 · 9 comments
Closed

Add a "fold all docstrings" command #4677

rchiodo opened this issue Aug 1, 2023 Discussed in #3933 · 9 comments
Assignees
Labels
enhancement New feature or request fixed in next version (release) A fix has been implemented and will appear in an upcoming version

Comments

@rchiodo
Copy link
Contributor

rchiodo commented Aug 1, 2023

Discussed in #3933

Originally posted by jonasreiher December 8, 2022
Docstrings covering all input parameters, types and precise function/class descriptions can become quite long and get in the way of the actual code. Usually, you only need to look into them when writing them or when looking up a specific function/class and it would be preferable to have them folded most of the time. You can do this by clicking the arrow next to the line numbers for each of them. This becomes tedious for files with a lot of docstrings, though.

There exists the "fold all block comments" command in VS Code but docstrings are not considered as block comments since they have the same format as multi-line strings and you wouldn't want to fold them away (see microsoft/vscode-python#20330).
Proposal: a "fold all docstrings" command that, well, folds all docstrings, so multi-line strings that are the first item in a function/class definition.

Alternative proposal: classify all multi-line strings as block comments that are are not inside of a function call or variable assignment. This would be consistent with the "toggle block comment" command that wraps the selection in triple quotes. Creating a block comment like this but then not being able to fold it with "fold all block comments" seems contradictory.

@rchiodo rchiodo added the enhancement New feature or request label Aug 1, 2023
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Aug 1, 2023
@rchiodo rchiodo assigned rchiodo and unassigned debonte Aug 1, 2023
@rchiodo
Copy link
Contributor Author

rchiodo commented Aug 1, 2023

Thought this might be a good thing to do in the near future.

@excubo-jg
Copy link

Good to see that this nuisance is getting tackled. Here is a similar request from me in PTVS - it would be good if the solution were applicable in VS, too.

microsoft/PTVS#7412

@rchiodo
Copy link
Contributor Author

rchiodo commented Aug 2, 2023

Unfortunately, I believe PTVS would have to be done separately. The same commands don't apply to Visual Studio.

@starball5
Copy link

Historically related: microsoft/vscode-python#20330

Related on Stack Overflow: The "Fold All Block Comments" command doesn't work on Python docstrings in files with certain arrangements of import, where it was also discovered that interestingly, the Fold All Block Comments command does actually affect docstrings, but only under certain conditions which are not precisely known by me or the asker of that question. Not sure if that's intended or not.

@debonte debonte removed the needs repro Issue has not been reproduced yet label Aug 14, 2023
@rchiodo rchiodo added the P2 label Oct 12, 2023
@winoo19
Copy link

winoo19 commented Oct 7, 2024

I made a vscode extension to tackle this exact problem, as it was bugging me so much:
https://marketplace.visualstudio.com/items?itemName=DanielSanchez.docstring-fold-and-unfold

@StellaHuang95 StellaHuang95 removed the P2 label Oct 14, 2024
@bschnurr bschnurr added fixed in next version (main) A fix has been implemented and will appear in an upcoming version fixed in next version (release) A fix has been implemented and will appear in an upcoming version and removed fixed in next version (main) A fix has been implemented and will appear in an upcoming version labels Oct 21, 2024
@heejaechang
Copy link
Contributor

This issue has been fixed in prerelease version 2024.10.102, which we've just released. You can find the changelog here: CHANGELOG.md

@Diogo-Rossi
Copy link

I found this listed on the release notes but had to came here to find out it is "pre-release"

@debonte
Copy link
Contributor

debonte commented Nov 4, 2024

@Diogo-Rossi, sorry for the confusion. Our stable release was delayed due to a regression that we found late in the testing process. The stable release will probably ship today.

@debonte
Copy link
Contributor

debonte commented Nov 4, 2024

This feature is now available in stable release 2024.11.1, which we've just released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed in next version (release) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

9 participants