I have tried this code:
from docutils.core import publish_string
text = publish_string(open(file_path, 'r').read(), writer_name='html')
But it says:
<p>Unknown directive type "toctree".</p>
So it won't work with some specific sphinx directives.
What is the easiest way to do same stuff for sphinx RST files?
upd. Seems like it must be:
sphinx-build -b singlehtml -D extensions='sphinx.ext.autodoc' -D master_doc='index' -C /mypath/docs .
How can I call that from Python code instead of console?
Here is what i wanted to do:
import sphinx
args = ". -b singlehtml -D extensions=sphinx.ext.autodoc -D master_doc=index -C /tmp/doc /tmp/out"
sphinx.main(args.split())
result = open('/tmp/out/index.html', 'r')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With