Process docstrings with Sphinx#

Processes docstrings with Sphinx. Can also be used as a commandline script:

python <text>


  • Tim Joseph Dumol (2009-09-29): initial version

sage.misc.sphinxify.sphinxify(docstring, format='html')#

Runs Sphinx on a docstring, and outputs the processed documentation.


  • docstring – string – a ReST-formatted docstring

  • format – string (optional, default ‘html’) – either ‘html’ or ‘text’


  • string – Sphinx-processed documentation, in either HTML or plain text format, depending on the value of format


sage: from sage.misc.sphinxify import sphinxify
sage: sphinxify('A test')
'<div class="docstring">\n    \n  <p>A test</p>\n\n\n</div>'
sage: sphinxify('**Testing**\n`monospace`')
'<div class="docstring"...<strong>Testing</strong>\n<span class="math...</p>\n\n\n</div>'
sage: sphinxify('`x=y`')
'<div class="docstring">\n    \n  <p><span class="math notranslate nohighlight">x=y</span></p>\n\n\n</div>'
sage: sphinxify('`x=y`', format='text')
sage: sphinxify(':math:`x=y`', format='text')