首页 > 解决方案 > 从 Sphinx 文字中排除注释包括

问题描述

我尝试使用 sphinx 记录我的主程序。我不知道如何使用这些autodoc功能来利用literalincludeincludestart-afterend-before. 有人知道如何使用 autodoc 做到这一点吗?我只能用它来记录一个类或一个类模块。

Main.py [待记录]

#Label_BasicLibraries_Start
IGNORE: 
This libraries are imported basic libraries.
IGNORE:
import time
import json
import urllib.parse
import random

from functools import reduce
import os.path
#Label_BasicLibraries_End

这是我目前正在使用的代码:

Title Example
=======================================================
This is beautiful code.

.. literalinclude:: Main.py
  :language: python
  :start-after: #Label_BasicLibraries_Start
  :end-before: #Label_BasicLibraries_End
  :linenos:

我可以使用这两种方法来过滤整个程序。有没有办法排除以固定标记开头或其他标记之间的特定行?就像在这个文档字符串的例子中一样?

非常感谢您的帮助!

标签: pythonpython-sphinx

解决方案


推荐阅读