在无服务器模型中使用 sphinx [英] Use sphinx within a serverless model
问题描述
我目前正在使用 sphinx 从 bitbucket 存储库中的 ReStructuredText 文件自动生成我的文档站点.
I am currently using sphinx to automatically generate my documentation site from ReStructuredText files within a bitbucket repo.
这当然都是内部管理/托管的,但我一直在思考是否可以将其切换为更无服务器的模型,使用 FaaS 生成站点,然后使用基于云的站点托管进行实际托管(例如 S3 静态站点托管).
This is of course all managed/hosted internally but I have been thinking more and more about whether I could switch this out for a more serverless model, using FaaS to generate the site and then a cloud based site hosting for the actual hosting (e.g S3 static site hosting).
我想知道是否可以以编程方式(例如在 AWS Lambda 或 Azure 函数中)使用 sphinx?
I was wondering whether it was possible to use sphinx in a programmatic way (e.g within a AWS Lambda or Azure Function)?
谢谢,约翰
推荐答案
而不是执行 sphinx-build
从命令行,您可以使用 sphinx.application.Sphinx
对象.
Instead of executing sphinx-build
from the command line, you can generate output by using a sphinx.application.Sphinx
object directly.
一个基本的例子:
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()
这篇关于在无服务器模型中使用 sphinx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!