forked from tomchristie/mkautodoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_extension.py
122 lines (114 loc) 路 2.84 KB
/
test_extension.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
112
113
114
115
116
117
118
119
120
121
122
import markdown
from .assertions import assert_xml_equal
def test_docstring():
content = """
# Example
::: mocklib.example_function
:docstring:
"""
output = markdown.markdown(content, extensions=["mkautodoc"])
assert_xml_equal(
output,
"""
<h1>Example</h1>
<div class="autodoc">
<div class="autodoc-signature">
<code>
mocklib.
<strong>example_function</strong>
</code>
<span class="autodoc-punctuation">(</span>
<em class="autodoc-param">a</em>
<span class="autodoc-punctuation">, </span>
<em class="autodoc-param">b=None</em>
<span class="autodoc-punctuation">, </span>
<em class="autodoc-param">*args</em>
<span class="autodoc-punctuation">, </span>
<em class="autodoc-param">**kwargs</em>
<span class="autodoc-punctuation">)</span>
</div>
<div class="autodoc-docstring">
<p>
This is a function with a <em>docstring</em>.
</p>
</div>
</div>""",
)
def test_async_function():
content = """
::: mocklib.example_async_function
"""
output = markdown.markdown(content, extensions=["mkautodoc"])
assert_xml_equal(
output,
"""
<div class="autodoc">
<div class="autodoc-signature">
<em>async </em>
<code>
mocklib.
<strong>example_async_function</strong>
</code>
<span class="autodoc-punctuation">(</span>
<span class="autodoc-punctuation">)</span>
</div>
</div>""",
)
def test_members():
content = """
# Example
::: mocklib.ExampleClass
:docstring:
:members:
"""
output = markdown.markdown(content, extensions=["mkautodoc"])
assert_xml_equal(
output,
"""
<h1>Example</h1>
<div class="autodoc">
<div class="autodoc-signature">
<em>class </em>
<code>
mocklib.
<strong>ExampleClass</strong>
</code>
<span class="autodoc-punctuation">(</span>
<span class="autodoc-punctuation">)</span>
</div>
<div class="autodoc-docstring">
<p>
This is a class with a <em>docstring</em>.
</p>
</div>
<div class="autodoc-members">
<div class="autodoc-signature">
<code>
<strong>example_method</strong>
</code>
<span class="autodoc-punctuation">(</span>
<em class="autodoc-param">self</em>
<span class="autodoc-punctuation">, </span>
<em class="autodoc-param">a</em>
<span class="autodoc-punctuation">, </span>
<em class="autodoc-param">b=None</em>
<span class="autodoc-punctuation">)</span>
</div>
<div class="autodoc-docstring">
<p>
This is a method with a <em>docstring</em>.
</p>
</div>
<div class="autodoc-signature">
<code>
<strong>example_property</strong>
</code>
</div>
<div class="autodoc-docstring">
<p>
This is a property with a <em>docstring</em>.
</p>
</div>
</div>
</div>""",
)