the*_*orn 20 python restructuredtext pep8 python-sphinx
我正在使用Sphinxdoc生成api文档,并且在编写docstring时遇到了pep8一致性问题.
如下所示,OWASP站点的链接在第105列结束,远远超过pep8规定的最大行长度
def handle_csrf(...):
"""The general recommendation by people in the know [OWASP]_, is
'to implement the Synchronizer Token Pattern (STP_)'.
.. [OWASP] The Open Web Application Security Project
(https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet)
.. _STP: http://www.corej2eepatterns.com/Design/PresoDesign.htm
"""
Run Code Online (Sandbox Code Playgroud)
有没有办法包装网址,同时仍然保持生成的文档中的URL?
插入反斜杠不起作用.
Emi*_*nov 10
反斜杠可以\
完成这项工作,但是会弄乱这个漂亮的缩进.
def handle_csrf():
"""The general recommendation by people in the know [OWASP]_, is
'to implement the Synchronizer Token Pattern (STP_)'.
.. [OWASP] The Open Web Application Security Project
(https://www.owasp.org/index.php/Cross-\
Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet)
.. _STP: http://www.corej2eepatterns.com/Design/PresoDesign.htm
"""
Run Code Online (Sandbox Code Playgroud)
结果(同样是长线):
>>> print handle_csrf.__doc__
The general recommendation by people in the know [OWASP]_, is
'to implement the Synchronizer Token Pattern (STP_)'.
.. [OWASP] The Open Web Application Security Project
(https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet)
.. _STP: http://www.corej2eepatterns.com/Design/PresoDesign.htm
Run Code Online (Sandbox Code Playgroud)
此外,PEP8是一个指南,而不是一个法律 - 这似乎是一个(罕见的)情况,可以忽略它.
展望一个问题,我想出了一个(N雅致?)工作围绕解决方案.
首先,这是我的文档字符串:
def ook():
"""The sound a monkey makes...
? `SQLAlchemy`_ used here.
"""
...
Run Code Online (Sandbox Code Playgroud)
第二,在第一个文件中,我定义了这个:
.. autofunction:: ook
.. _SQLAlchemy: http://www.sqlalchemy.org
Run Code Online (Sandbox Code Playgroud)
因此,当ook
记录时,SQLAlchemy
_链接工作.
归档时间: |
|
查看次数: |
3540 次 |
最近记录: |