【发布时间】:2021-12-26 08:16:08
【问题描述】:
我在我的 vanilla Django 项目中添加了 Sphinx 自动文档。
vanilla Django 项目有一个我想保留的 DocString:
"""URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
但是,Sphinx 正在尝试处理它并给我以下错误:
/usr/src/app/porter/urls.py:docstring of porter.urls:5: WARNING: Definition list ends without a blank line; unexpected unindent.
/usr/src/app/porter/urls.py:docstring of porter.urls:7: WARNING: Unexpected indentation.
/usr/src/app/porter/urls.py:docstring of porter.urls:9: WARNING: Block quote ends without a blank line; unexpected unindent.
我如何告诉 Sphinx 按原样呈现文本(只是很长的描述)而不处理它?
【问题讨论】:
-
你应该更慷慨地使用空行。 sphinx-doc.org/en/master/usage/restructuredtext/…
-
你有错误解释
...ends without a blank line- 所以你应该添加空行。 -
感谢您的信息。我想添加行是唯一的方法。如果你们中的任何人想写点什么,我会接受它作为答案。再次感谢????
标签: python django python-sphinx restructuredtext