python-2.7 - 生成代码文档时如何排除意外缩进警告的原因?

标签 python-2.7 windows-10 python-sphinx restructuredtext msys2

有问题的文档代码位于方法的开头:

"""
Gtk.EventBox::button-release-event signal handler.
:param widget: The clicked widget (The Gtk.EventBox).
:param event: Gdk.EventButton object with information regarding
       the event.
:param user_data: The Gtk.LinkButton that should be opened when
       the Gtk.EventBox is clicked.
:return: None
"""

警告是:
C:/msys64/home/hope/python+gtk/test/main.py:docstring of main.Builder.advertisem
ent_clicked:4: WARNING: Unexpected indentation.
C:/msys64/home/hope/python+gtk/test/main.py:docstring of main.Builder.advertisem
ent_clicked:5: WARNING: Block quote ends without a blank line; unexpected uninde
nt.

可以采取哪些措施来消除这些警告及其原因?

最佳答案

只需在方法的摘要描述之后,参数描述之前添加一个空行:

"""
Gtk.EventBox::button-release-event signal handler.

:param widget: The clicked widget (The Gtk.EventBox).
:param event: Gdk.EventButton object with information regarding
       the event.
:param user_data: The Gtk.LinkButton that should be opened when
       the Gtk.EventBox is clicked.
:return: None
"""

Here你可以找到这个建议:

If you get a Sphinx build error that says “Unexpected indentation,” it is probably because Sphinx is expecting a blank line, such as after a literal text block. Your line may have wrapped and confused Sphinx. In this case, try pulling the text up to the previous line even if it extends out past the margin of your window. Or, you could press Enter to go to the next line, but be sure to indent the text on the new line.

关于python-2.7 - 生成代码文档时如何排除意外缩进警告的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45880348/

相关文章:

c# - UWP 窗口内容不随窗口调整大小

listview - 在 Outlook 邮件应用程序等 Windows 10 UWP 应用程序中创建 SwipeListView

powershell - 纠缠 v5.1 : Should -Throw with message containing square-brackets fails

python - 如何在狮身人面像中启用数学?

python - 在 Python 2.7 中分解来自 Gstreamer 的音频流

python - 为什么 list(xrange) 比 range() 慢?

python-2.7 - 命令 "python setup.py egg_info"失败,PATH/psycopg2 中的错误代码为 1

python - 如何调整 Python Sphinx 以获得良好的网站搜索结果?

使用 python-Shinx 在重组文本中并排显示图像和目录

python - 正则表达式总是给出 None