Exemplo n.º 1
0
def html_markup(s):
    from sagenb.misc.sphinxify import sphinxify, is_sphinx_markup

    if is_sphinx_markup(s):
        try:
            return sphinxify(s)
        except:
            pass
    # Not in ReST format, so use docutils
    # to process the preamble ("**File:**" etc.)  and put
    # everything else in a <pre> block.
    i = s.find("**Docstring:**")
    if i != -1:
        preamble = s[:i+14]
        from docutils.core import publish_parts
        preamble = publish_parts(s[:i+14], writer_name='html')['body']
        s = s[i+14:]
    else:
        preamble = ""
    return '<div class="docstring">' + preamble + '<pre>' + s + '</pre></div>'
Exemplo n.º 2
0
    s += '**Definition:** %s'%sageinspect.sage_getdef(obj, obj_name)
    s += newline
    s += '**Docstring:**'
    s += newline
    s += sageinspect.sage_getdoc(obj, obj_name)
    s = s.rstrip()
    return html_markup(s)

def html_markup(s):
    try:
        from sagenb.misc.sphinxify import sphinxify, is_sphinx_markup
    except ImportError, msg:
        # sphinx not available
        def is_sphinx_markup(s): return False

    if is_sphinx_markup(s):
        try:
            return sphinxify(s)
        except:
            pass
    # Not in ReST format, so use docutils
    # to process the preamble ("**File:**" etc.)  and put
    # everything else in a <pre> block.
    i = s.find("**Docstring:**")
    if i != -1:
        preamble = s[:i+14]
        from docutils.core import publish_parts
        preamble = publish_parts(s[:i+14], writer_name='html')['body']
        s = s[i+14:]
    else:
        preamble = ""