Ejemplo n.º 1
0
def test_numpy_sin():
    """Test for numpy.sin docstring"""
    import numpy as np
    oinfo = inspector.info(np.sin)
    oinfo['name'] = 'sin'
    url = spxy.rich_repr(oinfo)
    _show_page(url)
Ejemplo n.º 2
0
def test_math():
    """Test a docstring with Latex on it"""
    oinfo = object_info()
    oinfo['name'] = 'Foo'
    oinfo['docstring'] = 'This is some math :math:`a^2 = b^2 + c^2`'
    url = spxy.rich_repr(oinfo)
    _show_page(url)
Ejemplo n.º 3
0
def test_docs_py():
    """Test linking to docs.python.org"""
    import subprocess as sp
    oinfo = inspector.info(sp.Popen)
    oinfo['name'] = 'Popen'
    url = spxy.rich_repr(oinfo)
    _show_page(url)
Ejemplo n.º 4
0
def test_outline():
    """Test the outline option"""
    import numpy as np
    oinfo = inspector.info(np.sin)
    oinfo['name'] = 'sin'
    dr.options['outline'] = True
    url = spxy.rich_repr(oinfo)
    _show_page(url)
Ejemplo n.º 5
0
def test_collapse():
    """Test the collapse option"""
    import numpy as np
    oinfo = inspector.info(np.sin)
    oinfo['name'] = 'sin'
    dr.options['collapse_sections'] = True
    url = spxy.rich_repr(oinfo)
    _show_page(url)
Ejemplo n.º 6
0
def test_no_render_math():
    """Test a docstring with Latex on it but without rendering it"""
    oinfo = object_info()
    oinfo['name'] = 'Foo'
    oinfo['docstring'] = 'This is a rational number :math:`\\frac{x}{y}`'
    dr.options['render_math'] = False
    url = spxy.rich_repr(oinfo)
    _show_page(url)
Ejemplo n.º 7
0
def test_basic():
    """Test with an empty context"""
    oinfo = object_info()
    oinfo['name'] = 'Foo'
    oinfo['argspec'] = {}
    oinfo['docstring'] = 'A test'
    oinfo['type_name'] = 'Function'
    url = spxy.rich_repr(oinfo)
    _show_page(url)
Ejemplo n.º 8
0
def test_plot():
    """Test the outline option"""
    docstring = """
.. plot::

   >>> import matplotlib.pyplot as plt
   >>> plt.plot([1,2,3], [4,5,6])
"""
    oinfo = object_info()
    oinfo['name'] = 'Foo'
    oinfo['docstring'] = docstring
    url = spxy.rich_repr(oinfo)
    _show_page(url)
Ejemplo n.º 9
0
def doc(fn):
    oinfo = Inspector().info(fn)
    url = sphinxify.rich_repr(oinfo)
    try:
        oinfo['name'] = fn.__name__
    except AttributeError:
        oinfo['name'] = repr(fn)
    new_url = os.path.dirname(url) + '/' + oinfo['name'] + '.html'
    url = copyfile(url, new_url)
    url = 'file://' + url
    url_str = url
    print(url_str)
    # Popen(['chromium-browser', '--app=' + url_str],
    #       stderr=PIPE, stdout=PIPE)
    Popen(['/usr/bin/google-chrome', url_str],
          stderr=PIPE, stdout=PIPE)
Ejemplo n.º 10
0
def test_empty_oinfo():
    """Test with totally empty oinfo"""
    oinfo = object_info()
    url = spxy.rich_repr(oinfo)
    _show_page(url)
Ejemplo n.º 11
0
def test_no_doc():
    oinfo = object_info()
    oinfo['docstring'] = '<no docstring>'
    url = spxy.rich_repr(oinfo)
    _show_page(url)