I would like to serve on a flask server an html page with reStructuredText using the sphinx readthedocs theme, rendered on-the-fly from an rst
file.
How can I import sphinx as a python module, and then use it together with the readthedocs theme and the input rst
string to obtain a string with the HTML rendered content?
This seems to be a standard task, but I have not found any example of such behaviour online. In particular, I would prefer to not first render it on the OS and then read the rendered html file into python, but to directly do this HTML python.
What I have so far using docutils
is
from docutils import core
from docutils.writers.html4css1 import Writer
def make_doc(raw_rst):
_w = Writer()
return core.publish_string(raw_rst, writer=_w)
and I would like to have the output HTML using the readthedocs theme.
If possible without a hack, I would also prefer to replace the used docutils
by sphinx
.