forked from spyder-ide/docrepr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
111 lines (84 loc) · 2.29 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# -*- coding: utf-8 -*
"""
Simple fabric file to test oinspect output
"""
# Stdlib imports
import webbrowser
# 3rd party imports
from IPython.core.oinspect import Inspector, object_info
# Local imports
import oinspect as oi
import oinspect.sphinxify as spxy
# Main inspector instance
inspector = Inspector()
def _show_page(url):
webbrowser.open_new_tab(url)
def test_basic():
"""Test with an empty context"""
oinfo = object_info()
oinfo['docstring'] = 'A test'
url = spxy.rich_repr(oinfo)
_show_page(url)
def test_math():
"""Test a docstring with Latex on it"""
oinfo = object_info()
oinfo['docstring'] = 'This is some math :math:`a^2 = b^2 + c^2`'
url = spxy.rich_repr(oinfo)
_show_page(url)
def test_no_render_math():
"""Test a docstring with Latex on it but without rendering it"""
oinfo = object_info()
oinfo['docstring'] = 'This is a rational number :math:`\\frac{x}{y}`'
oi.options['render_math'] = False
url = spxy.rich_repr(oinfo)
_show_page(url)
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)
def test_collapse():
"""Test the collapse option"""
import numpy as np
oinfo = inspector.info(np.sin)
oinfo['name'] = 'sin'
oi.options['collapse_sections'] = True
url = spxy.rich_repr(oinfo)
_show_page(url)
def test_outline():
"""Test the outline option"""
import numpy as np
oinfo = inspector.info(np.sin)
oinfo['name'] = 'sin'
oi.options['outline'] = True
url = spxy.rich_repr(oinfo)
_show_page(url)
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['docstring'] = docstring
url = spxy.rich_repr(oinfo)
_show_page(url)
def test_docs_py():
"""Test the outline option"""
import subprocess as sp
oinfo = inspector.info(sp.Popen)
oinfo['name'] = 'Popen'
url = spxy.rich_repr(oinfo)
_show_page(url)
def test_all():
"""Run all tests"""
test_basic()
test_math()
test_no_render_math()
test_numpy_sin()
test_collapse()
test_outline()
test_plot()