在无服务器模型中使用sphinx

时间:2018-02-17 09:49:05

标签: python-sphinx restructuredtext serverless docutils serverless-architecture

我目前正在使用sphinx从bitbucket repo中的ReStructuredText文件自动生成我的文档站点。

这当然都是内部托管/托管的,但我一直在思考是否可以将其转换为更无服务器的模型,使用FaaS生成网站,然后使用基于云的网站托管实际托管(例如S3静态站点托管)。

我想知道是否可以以编程方式使用sphinx(例如在AWS Lambda或Azure Function中)?

谢谢, 约翰

1 个答案:

答案 0 :(得分:0)

您可以直接使用sphinx-build对象生成输出,而不是从命令行执行sphinx.application.Sphinx

一个基本的例子:

import os
from sphinx.application import Sphinx

# Main arguments 
srcdir = "/path/to/source"
confdir = srcdir
builddir = os.path.join(srcdir, "_build")
doctreedir = os.path.join(builddir, "doctrees")
builder = "html"

# Create the Sphinx application object
app = Sphinx(srcdir, confdir, builddir, doctreedir, builder)

# Run the build
app.build()