我尝试使用 pybuilder 创建一个 python 包,并想知道如何使用 sphinx 插件。我已经通过 sphinx-quickstart 启动了一个 sphinx 文档脚手架,并在 pybuilder 的 build.py 文件中激活了 sphinx 插件。
下面显示了我当前的 build.py:
# import required packages
from pybuilder.core import use_plugin, init
import os
import sys
import inspect
# import required plugins
use_plugin("python.core")
use_plugin("python.unittest")
use_plugin("python.install_dependencies")
use_plugin("python.flake8")
use_plugin("python.coverage")
use_plugin("python.distutils")
use_plugin("python.sphinx")
# define build attributes
name = "presentations"
version = "0.0.1"
license = "None"
default_task = ["analyze", "publish"]
@init
def set_properties(project):
# define unittest coverage properties
project.set_property("coverage_threshold_warn", 50)
project.set_property("coverage_break_build", True)
# define linting properties
project.set_property("flake8_break_build", False)
project.set_property("flake8_max_line_length", 120)
project.set_property("flake8_verbose_output", True)
# define documentation properties
project.set_property("sphinx_builder", "html")
__location__ = os.path.join(os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe())))
project.set_property("sphinx_config_path", os.path.join(__location__, '../docs'))
project.set_property("sphinx_source_dir", os.path.join(__location__, '../src'))
project.set_property("sphinx_output_dir", "_build/")
但是,当我运行 pyb 命令构建包时,pybuilder 不会生成所需的文档。我想,除了在 pybuilder 的 build.py 文件中的“analyze”和“publish”之外,我还没有定义另一个 default_task,以便在运行 pyb 命令时强制 pybuilder 执行 sphinx 插件。
用户awwsmm编写了一个非常有用的教程,介绍如何使用 pybuilder 管理你的 python 项目。他还确认,很难在线找到 pybuilder 的所有可用属性和属性的定义列表。不幸的是,对pybuilder 核心代码的建议搜索也对我没有帮助。
有谁知道如何处理这个问题?任何想法将不胜感激。
我正在使用 python (3.6.13)、pybuilder (0.11.17) 和 sphinx (4.0.2) 在 Windows 机器上编码。