简体   繁体   English

如何在PyCharm中格式化多行TODO注释?

[英]How do I format a multi-line TODO comment in PyCharm?

I want to add a multi-line TODO comment to my PyCharm project. 我想在我的PyCharm项目中添加多行TODO注释。

# TODO: Multiple errors can be wrapped inside an exception.
#       WfcApiException should do recursive error checking to locate
#       and store an arbitrary number of nested errors.

Unfortunately, PyCharm only recognizes the first line as a TODO comment. 不幸的是,PyCharm只将第一行识别为TODO评论。 Any following lines are viewed as standard Python comments. 以下任何行都被视为标准Python注释。

尝试在PyCharm中的多行TODO语句失败

What is the correct way to format a multi-line TODO comment in PyCharm? 在PyCharm中格式化多行TODO注释的正确方法是什么?

Pycharm 2018.3 does support multiline todo, yay! Pycharm 2018.3确实支持多行待办事项,耶!

https://youtu.be/5gJ7_3wCfUk?t=65 https://youtu.be/5gJ7_3wCfUk?t=65

https://blog.jetbrains.com/pycharm/2018/11/pycharm-2018-3-out-now/ https://blog.jetbrains.com/pycharm/2018/11/pycharm-2018-3-out-now/

So, using your TODO comment: 所以,使用你的TODO评论:

# TODO: Multiple errors can be wrapped inside an exception.
#       WfcApiException should do recursive error checking to locate
#       and store an arbitrary number of nested errors.

yields: 收益率:

在此输入图像描述

Actually, you only need to indent the following lines one character to the right of the TODO so this would be just on the limit from being detected: 实际上,你只需要在TODO右边的一个字符下面缩进以下行,这样就可以检测出来了:

在此输入图像描述

And the todo is captured as a single item, of course: 并且todo被捕获为单个项目,当然:

在此输入图像描述

Update: It appears JetBrains added this feature, see payala's answer 更新:看来JetBrains添加了此功能,请参阅payala的回答

PyCharm does not support multi-line TODOs, one alternative option would be to use a multi line string PyCharm 支持多行TODO,另一种选择是使用多行字符串

'''
TODO foobar
foobar
'''

This won't have the TODO highlighting like # TODO foo , but it will stand out from the rest of your code with the string highlighting. 这将不会像# TODO foo那样突出显示# TODO foo ,但它会突出显示字符串突出显示的其余代码。

You could also try 你也可以试试

# TODO -----------------
# TODO  foobar this
# TODO  comment 
# TODO  comment
# TODO  comment
# TODO ------------------

If you have a particularly chunky and important TODO note. 如果你有一个特别厚实和重要的TODO笔记。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM