排除斯芬克斯文学评论

2024-05-23 14:49:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着用sphinx来记录我的主程序。我不知道如何使用autodoc功能来利用literalinclude的功能,包括start-afterend-before。有人知道如何使用autodoc吗?我只能用它来记录一个类或一个类模块。你知道吗

主.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:

我可以用两种方法过滤整个程序。有没有办法排除从固定标记开始或在其他标记之间的特定行?像this example中的docstring?你知道吗

非常感谢你的帮助!你知道吗


Tags: pyimport功能记录thisstartlabelend