开发扩展概述

本页包含有关开发Sphinx扩展的一般信息。

使一个扩展依赖于另一个扩展

有时您的扩展依赖于另一个Sphinx扩展的功能。大多数Sphinx扩展在项目的:文件中激活:`配置文件`文件,但作为扩展开发人员不能使用此文件。

To ensure that another extension is activated as a part of your own extension, use the sphinx.application.Sphinx.setup_extension() method. This will activate another extension at run-time, ensuring that you have access to its functionality.

例如,以下代码激活“recommonmark”扩展:

def setup(app):
    app.setup_extension("recommonmark")

备注

由于您的扩展将依赖于另一个扩展,请确保将它作为扩展的安装要求的一部分。