Ticket #7384: trac_7384-sphinxify-docstrings.patch

File trac_7384-sphinxify-docstrings.patch, 2.4 KB (added by timdumol, 11 years ago)

Fixed the doctests

  • sagenb/misc/sphinxify.py

    # HG changeset patch
    # User Tim Dumol <tim@timdumol.com>
    # Date 1257283130 -28800
    # Node ID 50ac73467de3a933a77a85513dff5a867a2f46a1
    # Parent  29ae8520f55147565f0c1996e6882d948722e75e
    #7384 SageNB -- Fix sphinxify's doctests. Tim Dumol.
    
    diff -r 29ae8520f551 -r 50ac73467de3 sagenb/misc/sphinxify.py
    a b  
    1 #!/usr/bin/python
     1#!/usr/bin/env python
    22r"""
    33Process docstrings with Sphinx
    44
    55Processes docstrings with Sphinx. Can also be used as a commandline script:
    66
    7 $ python sphinxify.py <text>
     7``python sphinxify.py <text>``
    88
    99AUTHORS:
    1010
    1111- Tim Joseph Dumol (2009-09-29): initial version
    12 
     12"""
    1313#**************************************************
    1414# Copyright (C) 2009 Tim Dumol <tim@timdumol.com>
    1515#
    1616# Distributed under the terms of the BSD License
    1717#**************************************************
    18 """
    1918import os, hashlib, re, shutil
    2019from tempfile import mkdtemp
    2120
     
    3534    return ("`" in docstring or "::" in docstring)
    3635
    3736def sphinxify(docstring):
    38     """
     37    r"""
    3938    Runs Sphinx on a docstring, and outputs the processed documentation.
    4039
    4140    INPUT:
     
    4948    EXAMPLES::
    5049
    5150        sage: from sagenb.misc.sphinxify import sphinxify
    52         sage: sphinxify('Foobar')
    53         '\n<div class="docstring">\n    \n  \n  <p>Foobar</p>\n\n\n</div>'
     51        sage: sphinxify('A test')
     52        '\n<div class="docstring">\n    \n  <p>A test</p>\n\n\n</div>'
    5453        sage: sphinxify('**Testing**\n`monospace`')
    55         '\n<div class="docstring"...<strong>Testing</strong>\n<img..." alt="monospace" /></p>\n\n\n</div>'
     54        '\n<div class="docstring"...<strong>Testing</strong>\n<span class="math"...</p>\n\n\n</div>'
    5655    """
    5756    tmpdir = mkdtemp()
    5857    docstring_hash = hashlib.md5(docstring).hexdigest()
     
    108107    return new_html
    109108
    110109def generate_configuration(directory):
    111     """
     110    r"""
    112111    Generates Sphinx configuration at ``directory``.
    113112
    114113    EXAMPLES::
     
    118117        sage: tmpdir = tempfile.mkdtemp()
    119118        sage: generate_configuration(tmpdir)
    120119        sage: open(os.path.join(tmpdir, 'conf.py')).read()
    121         '\nextensions =...templates_path...NestedClass\n    '
     120        '\n...extensions =...templates_path...source = False\n...'
    122121    """
    123122    conf = r'''
    124123###########################################################