-
Notifications
You must be signed in to change notification settings - Fork 15
/
test_extension.py
54 lines (46 loc) 路 2.57 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
import markdown
def test_docstring():
content = """
# Example
::: mocklib.example_function
:docstring:
"""
output = markdown.markdown(content, extensions=["mkautodoc"])
assert output.splitlines() == [
"<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 output.splitlines() == [
'<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 output.splitlines() == [
"<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>",
]