Use sphinx within a serverless model

人走茶凉 提交于 2019-12-13 03:25:31

问题


I am currently using sphinx to automatically generate my documentation site from ReStructuredText files within a bitbucket repo.

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).

I was wondering whether it was possible to use sphinx in a programmatic way (e.g within a AWS Lambda or Azure Function)?

Thanks, John


回答1:


Instead of executing sphinx-build from the command line, you can generate output by using a sphinx.application.Sphinx object directly.

A basic example:

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()


来源:https://stackoverflow.com/questions/48839993/use-sphinx-within-a-serverless-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!