Ask Your Question
1

Is it possible to add a second Edge Marker and wrap docstring?

asked 2021-05-15 08:20:47 -0500

gemisigo gravatar image

updated 2021-05-18 07:20:43 -0500

PEP 8 suggests statement lines should be limited to 79 characters and lines with comments and docstrings to 72 characters. In Preferences > Editor > Line Wrapping I can set a single Edge Marker that shows where that column is in the editor. There's also a setting Reformatting Wrap Column that can be set to a value different from the Edge Marker. So at first, I thought I'm out of luck, either my code will be wrapped at column 72 or my docstrings will be wrapped at column 79. But then came the surprise, the docstrings weren't wrapped. I mean they weren't wrapped at all. I had to do that manually.

Is there a way to turn on docstring wrapping at a user-configurable column? And if there's none, is it possible to add a second Edge Marker to have at least a visual crutch?

edit retag flag offensive close merge delete

Comments

Text wrapping occurs when you use Source > Rewrap text. Are docstrings wrapped when you use this?

Wingware Support gravatar image Wingware Support  ( 2021-05-17 10:29:49 -0500 )edit

Very strange things happen. I thought that having the auto-formatting set to Whole Files Before Save would format the whole file. But it seems docstrings are excluded. Which indeed does make some sense as the user might not want those to be formatted. Nevertheless, it isn't consistent. For example, none of the comments are wrapped (neither on save nor when using Source > Rewrap text). On the other hand, when using Rewrap text, some of the stuff are wrapped, some aren't. If I move the cursor to the line that should be wrapped it will be. But if I select a larger portion of text wrapping either happens or it does not. I guess I'm not exactly aware of how that is expected to work.

The list of strange:

(more)
gemisigo gravatar image gemisigo  ( 2021-05-17 13:56:53 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-17 14:07:57 -0500

updated 2021-05-17 14:08:52 -0500

Rewrap Text just applies to the current line or selection, not the whole file. Reformatting is different and can be done automatically from the Source > Reformatting menu items or using the Editor > Auto-formatting preferences. Reformatting runs pep8, black, or yapf to do the reformatting and it does way more than just rewrapping lines. My sense is you may be looking for reformatting and not just rewrapping.

BTW in your first link above Wing is arguably doing the wrong thing. I wouldn't expect the \ after return like that.

edit flag offensive delete link more

Comments

I have auto-formatting turned on and triggered by saving the file, that's why I was surprised it didn't format docstrings to comply with PEP8:

For flowing long blocks of text with fewer structural restrictions (docstrings or comments), the line length should be limited to 72 characters.

In this video here I had also anticipated it to reformat lines 27, 29, and 30 (and all the comments as well) after saving the file, but they were left unchanged. Applying the Rewrap Text to those lines does reformat them as auto-formatting should have but I guess that's not the same.

gemisigo gravatar image gemisigo  ( 2021-05-17 16:18:07 -0500 )edit

You may want to try one of the other reformatters. Wing is just running pep8, black, or yapf so it ends up doing whatever those do by default. I've also noticed pep8 doesn't always do what pep8 says, although I'm not sure why. And yes Rewrap Text is our own implementation of wrapping so is different than what auto-reformat does.

Wingware Support gravatar image Wingware Support  ( 2021-05-17 19:51:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-05-15 08:20:47 -0500

Seen: 56 times

Last updated: May 18