Ticket #7384: trac_7384-sphinxify-docstrings_v2.patch

File trac_7384-sphinxify-docstrings_v2.patch, 2.5 KB (added by mpatel, 11 years ago)

Update doctest outputs. Apply only this patch.

  • sagenb/misc/sphinxify.py

    # HG changeset patch
    # User Tim Dumol <tim@timdumol.com>
    # Date 1257283130 -28800
    # Node ID cab5f6b0a6e462c9c35af41307843fdf7bb61c8f
    # Parent  e4371d4fc866178990dcd64cb515b65fe8e5ab51
    #7384 SageNB -- Fix sphinxify's doctests. Tim Dumol.
    
    diff --git a/sagenb/misc/sphinxify.py b/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
    def is_sphinx_markup(docstring): 
    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:
    def sphinxify(docstring): 
    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        '<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        '<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()
    def sphinxify(docstring): 
    112111    return new_html
    113112
    114113def generate_configuration(directory):
    115     """
     114    r"""
    116115    Generates Sphinx configuration at ``directory``.
    117116
    118117    EXAMPLES::
    def generate_configuration(directory): 
    122121        sage: tmpdir = tempfile.mkdtemp()
    123122        sage: generate_configuration(tmpdir)
    124123        sage: open(os.path.join(tmpdir, 'conf.py')).read()
    125         '\nextensions =...templates_path...NestedClass\n    '
     124        '\n...extensions =...templates_path...source = False\n...'
    126125    """
    127126    conf = r'''
    128127###########################################################