Process docstrings with Sphinx#

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

python sphinxify.py <text>

AUTHORS:

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

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

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

INPUT:

  • docstring – string; a ReST-formatted docstring

  • format – string (default: ‘html’); either ‘html’ or ‘text’

OUTPUT:

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

EXAMPLES:

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