assassinlike commited on
Commit
3a9ec6a
·
verified ·
1 Parent(s): f636ac7

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser-0.17.0.dist-info/licenses/LICENSE.md +21 -0
  2. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/__init__.cpython-311.pyc +0 -0
  3. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/attrdoc.cpython-311.pyc +0 -0
  4. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/common.cpython-311.pyc +0 -0
  5. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/epydoc.cpython-311.pyc +0 -0
  6. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/google.cpython-311.pyc +0 -0
  7. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/numpydoc.cpython-311.pyc +0 -0
  8. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/parser.cpython-311.pyc +0 -0
  9. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/rest.cpython-311.pyc +0 -0
  10. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/util.cpython-311.pyc +0 -0
  11. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__init__.py +1 -0
  12. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/__init__.cpython-311.pyc +0 -0
  13. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/_pydoctor.cpython-311.pyc +0 -0
  14. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_epydoc.cpython-311.pyc +0 -0
  15. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_google.cpython-311.pyc +0 -0
  16. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_numpydoc.cpython-311.pyc +0 -0
  17. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_parse_from_object.cpython-311.pyc +0 -0
  18. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_parser.cpython-311.pyc +0 -0
  19. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_rest.cpython-311.pyc +0 -0
  20. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_util.cpython-311.pyc +0 -0
  21. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/_pydoctor.py +22 -0
  22. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_epydoc.py +724 -0
  23. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_google.py +1000 -0
  24. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_numpydoc.py +1088 -0
  25. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_parse_from_object.py +110 -0
  26. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_parser.py +223 -0
  27. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_rest.py +542 -0
  28. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_util.py +64 -0
  29. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/__init__.cpython-311.pyc +0 -0
  30. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/__main__.cpython-311.pyc +0 -0
  31. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/_options.cpython-311.pyc +0 -0
  32. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/appsettings.cpython-311.pyc +0 -0
  33. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/audit.cpython-311.pyc +0 -0
  34. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/bbox.cpython-311.pyc +0 -0
  35. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/blkrefs.cpython-311.pyc +0 -0
  36. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/colors.cpython-311.pyc +0 -0
  37. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/commands.cpython-311.pyc +0 -0
  38. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/comments.cpython-311.pyc +0 -0
  39. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/disassemble.cpython-311.pyc +0 -0
  40. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/document.cpython-311.pyc +0 -0
  41. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/dwginfo.cpython-311.pyc +0 -0
  42. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/dynblkhelper.cpython-311.pyc +0 -0
  43. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/edgeminer.cpython-311.pyc +0 -0
  44. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/edgesmith.cpython-311.pyc +0 -0
  45. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/entitydb.cpython-311.pyc +0 -0
  46. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/enums.cpython-311.pyc +0 -0
  47. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/explode.cpython-311.pyc +0 -0
  48. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/eztypes.cpython-311.pyc +0 -0
  49. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/filemanagement.cpython-311.pyc +0 -0
  50. data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/gfxattribs.cpython-311.pyc +0 -0
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser-0.17.0.dist-info/licenses/LICENSE.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Marcin Kurczewski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (912 Bytes). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/attrdoc.cpython-311.pyc ADDED
Binary file (6.99 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/common.cpython-311.pyc ADDED
Binary file (11.6 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/epydoc.cpython-311.pyc ADDED
Binary file (11.5 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/google.cpython-311.pyc ADDED
Binary file (20.1 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/numpydoc.cpython-311.pyc ADDED
Binary file (26.7 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/parser.cpython-311.pyc ADDED
Binary file (4.27 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/rest.cpython-311.pyc ADDED
Binary file (11.7 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/__pycache__/util.cpython-311.pyc ADDED
Binary file (6.36 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """Tests for docstring parser."""
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (254 Bytes). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/_pydoctor.cpython-311.pyc ADDED
Binary file (1.6 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_epydoc.cpython-311.pyc ADDED
Binary file (18.4 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_google.cpython-311.pyc ADDED
Binary file (29.8 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_numpydoc.cpython-311.pyc ADDED
Binary file (29.3 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_parse_from_object.cpython-311.pyc ADDED
Binary file (6.41 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_parser.cpython-311.pyc ADDED
Binary file (8.98 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_rest.cpython-311.pyc ADDED
Binary file (18 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/__pycache__/test_util.cpython-311.pyc ADDED
Binary file (2.49 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/_pydoctor.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Private pydoctor customization code in order to exclude the package
2
+ docstring_parser.tests from the API documentation. Based on Twisted code.
3
+ """
4
+
5
+ # pylint: disable=invalid-name
6
+
7
+ try:
8
+ from pydoctor.model import Documentable, PrivacyClass, System
9
+ except ImportError:
10
+ pass
11
+ else:
12
+
13
+ class HidesTestsPydoctorSystem(System):
14
+ """A PyDoctor "system" used to generate the docs."""
15
+
16
+ def privacyClass(self, documentable: Documentable) -> PrivacyClass:
17
+ """Report the privacy level for an object. Hide the module
18
+ 'docstring_parser.tests'.
19
+ """
20
+ if documentable.fullName().startswith("docstring_parser.tests"):
21
+ return PrivacyClass.HIDDEN
22
+ return super().privacyClass(documentable)
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_epydoc.py ADDED
@@ -0,0 +1,724 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for epydoc-style docstring routines."""
2
+
3
+ import typing as T
4
+
5
+ import pytest
6
+ from docstring_parser.common import ParseError, RenderingStyle
7
+ from docstring_parser.epydoc import compose, parse
8
+
9
+
10
+ @pytest.mark.parametrize(
11
+ "source, expected",
12
+ [
13
+ ("", None),
14
+ ("\n", None),
15
+ ("Short description", "Short description"),
16
+ ("\nShort description\n", "Short description"),
17
+ ("\n Short description\n", "Short description"),
18
+ ],
19
+ )
20
+ def test_short_description(source: str, expected: str) -> None:
21
+ """Test parsing short description."""
22
+ docstring = parse(source)
23
+ assert docstring.short_description == expected
24
+ assert docstring.long_description is None
25
+ assert not docstring.meta
26
+
27
+
28
+ @pytest.mark.parametrize(
29
+ "source, expected_short_desc, expected_long_desc, expected_blank",
30
+ [
31
+ (
32
+ "Short description\n\nLong description",
33
+ "Short description",
34
+ "Long description",
35
+ True,
36
+ ),
37
+ (
38
+ """
39
+ Short description
40
+
41
+ Long description
42
+ """,
43
+ "Short description",
44
+ "Long description",
45
+ True,
46
+ ),
47
+ (
48
+ """
49
+ Short description
50
+
51
+ Long description
52
+ Second line
53
+ """,
54
+ "Short description",
55
+ "Long description\nSecond line",
56
+ True,
57
+ ),
58
+ (
59
+ "Short description\nLong description",
60
+ "Short description",
61
+ "Long description",
62
+ False,
63
+ ),
64
+ (
65
+ """
66
+ Short description
67
+ Long description
68
+ """,
69
+ "Short description",
70
+ "Long description",
71
+ False,
72
+ ),
73
+ (
74
+ "\nShort description\nLong description\n",
75
+ "Short description",
76
+ "Long description",
77
+ False,
78
+ ),
79
+ (
80
+ """
81
+ Short description
82
+ Long description
83
+ Second line
84
+ """,
85
+ "Short description",
86
+ "Long description\nSecond line",
87
+ False,
88
+ ),
89
+ ],
90
+ )
91
+ def test_long_description(
92
+ source: str,
93
+ expected_short_desc: str,
94
+ expected_long_desc: str,
95
+ expected_blank: bool,
96
+ ) -> None:
97
+ """Test parsing long description."""
98
+ docstring = parse(source)
99
+ assert docstring.short_description == expected_short_desc
100
+ assert docstring.long_description == expected_long_desc
101
+ assert docstring.blank_after_short_description == expected_blank
102
+ assert not docstring.meta
103
+
104
+
105
+ @pytest.mark.parametrize(
106
+ "source, expected_short_desc, expected_long_desc, "
107
+ "expected_blank_short_desc, expected_blank_long_desc",
108
+ [
109
+ (
110
+ """
111
+ Short description
112
+ @meta: asd
113
+ """,
114
+ "Short description",
115
+ None,
116
+ False,
117
+ False,
118
+ ),
119
+ (
120
+ """
121
+ Short description
122
+ Long description
123
+ @meta: asd
124
+ """,
125
+ "Short description",
126
+ "Long description",
127
+ False,
128
+ False,
129
+ ),
130
+ (
131
+ """
132
+ Short description
133
+ First line
134
+ Second line
135
+ @meta: asd
136
+ """,
137
+ "Short description",
138
+ "First line\n Second line",
139
+ False,
140
+ False,
141
+ ),
142
+ (
143
+ """
144
+ Short description
145
+
146
+ First line
147
+ Second line
148
+ @meta: asd
149
+ """,
150
+ "Short description",
151
+ "First line\n Second line",
152
+ True,
153
+ False,
154
+ ),
155
+ (
156
+ """
157
+ Short description
158
+
159
+ First line
160
+ Second line
161
+
162
+ @meta: asd
163
+ """,
164
+ "Short description",
165
+ "First line\n Second line",
166
+ True,
167
+ True,
168
+ ),
169
+ (
170
+ """
171
+ @meta: asd
172
+ """,
173
+ None,
174
+ None,
175
+ False,
176
+ False,
177
+ ),
178
+ ],
179
+ )
180
+ def test_meta_newlines(
181
+ source: str,
182
+ expected_short_desc: T.Optional[str],
183
+ expected_long_desc: T.Optional[str],
184
+ expected_blank_short_desc: bool,
185
+ expected_blank_long_desc: bool,
186
+ ) -> None:
187
+ """Test parsing newlines around description sections."""
188
+ docstring = parse(source)
189
+ assert docstring.short_description == expected_short_desc
190
+ assert docstring.long_description == expected_long_desc
191
+ assert docstring.blank_after_short_description == expected_blank_short_desc
192
+ assert docstring.blank_after_long_description == expected_blank_long_desc
193
+ assert len(docstring.meta) == 1
194
+
195
+
196
+ def test_meta_with_multiline_description() -> None:
197
+ """Test parsing multiline meta documentation."""
198
+ docstring = parse(
199
+ """
200
+ Short description
201
+
202
+ @meta: asd
203
+ 1
204
+ 2
205
+ 3
206
+ """
207
+ )
208
+ assert docstring.short_description == "Short description"
209
+ assert len(docstring.meta) == 1
210
+ assert docstring.meta[0].args == ["meta"]
211
+ assert docstring.meta[0].description == "asd\n1\n 2\n3"
212
+
213
+
214
+ def test_multiple_meta() -> None:
215
+ """Test parsing multiple meta."""
216
+ docstring = parse(
217
+ """
218
+ Short description
219
+
220
+ @meta1: asd
221
+ 1
222
+ 2
223
+ 3
224
+ @meta2: herp
225
+ @meta3: derp
226
+ """
227
+ )
228
+ assert docstring.short_description == "Short description"
229
+ assert len(docstring.meta) == 3
230
+ assert docstring.meta[0].args == ["meta1"]
231
+ assert docstring.meta[0].description == "asd\n1\n 2\n3"
232
+ assert docstring.meta[1].args == ["meta2"]
233
+ assert docstring.meta[1].description == "herp"
234
+ assert docstring.meta[2].args == ["meta3"]
235
+ assert docstring.meta[2].description == "derp"
236
+
237
+
238
+ def test_meta_with_args() -> None:
239
+ """Test parsing meta with additional arguments."""
240
+ docstring = parse(
241
+ """
242
+ Short description
243
+
244
+ @meta ene due rabe: asd
245
+ """
246
+ )
247
+ assert docstring.short_description == "Short description"
248
+ assert len(docstring.meta) == 1
249
+ assert docstring.meta[0].args == ["meta", "ene", "due", "rabe"]
250
+ assert docstring.meta[0].description == "asd"
251
+
252
+
253
+ def test_params() -> None:
254
+ """Test parsing params."""
255
+ docstring = parse("Short description")
256
+ assert len(docstring.params) == 0
257
+
258
+ docstring = parse(
259
+ """
260
+ Short description
261
+
262
+ @param name: description 1
263
+ @param priority: description 2
264
+ @type priority: int
265
+ @param sender: description 3
266
+ @type sender: str?
267
+ @param message: description 4, defaults to 'hello'
268
+ @type message: str?
269
+ @param multiline: long description 5,
270
+ defaults to 'bye'
271
+ @type multiline: str?
272
+ """
273
+ )
274
+ assert len(docstring.params) == 5
275
+ assert docstring.params[0].arg_name == "name"
276
+ assert docstring.params[0].type_name is None
277
+ assert docstring.params[0].description == "description 1"
278
+ assert docstring.params[0].default is None
279
+ assert not docstring.params[0].is_optional
280
+ assert docstring.params[1].arg_name == "priority"
281
+ assert docstring.params[1].type_name == "int"
282
+ assert docstring.params[1].description == "description 2"
283
+ assert not docstring.params[1].is_optional
284
+ assert docstring.params[1].default is None
285
+ assert docstring.params[2].arg_name == "sender"
286
+ assert docstring.params[2].type_name == "str"
287
+ assert docstring.params[2].description == "description 3"
288
+ assert docstring.params[2].is_optional
289
+ assert docstring.params[2].default is None
290
+ assert docstring.params[3].arg_name == "message"
291
+ assert docstring.params[3].type_name == "str"
292
+ assert (
293
+ docstring.params[3].description == "description 4, defaults to 'hello'"
294
+ )
295
+ assert docstring.params[3].is_optional
296
+ assert docstring.params[3].default == "'hello'"
297
+ assert docstring.params[4].arg_name == "multiline"
298
+ assert docstring.params[4].type_name == "str"
299
+ assert (
300
+ docstring.params[4].description
301
+ == "long description 5,\ndefaults to 'bye'"
302
+ )
303
+ assert docstring.params[4].is_optional
304
+ assert docstring.params[4].default == "'bye'"
305
+
306
+
307
+ def test_returns() -> None:
308
+ """Test parsing returns."""
309
+ docstring = parse(
310
+ """
311
+ Short description
312
+ """
313
+ )
314
+ assert docstring.returns is None
315
+
316
+ docstring = parse(
317
+ """
318
+ Short description
319
+ @return: description
320
+ """
321
+ )
322
+ assert docstring.returns is not None
323
+ assert docstring.returns.type_name is None
324
+ assert docstring.returns.description == "description"
325
+ assert not docstring.returns.is_generator
326
+
327
+ docstring = parse(
328
+ """
329
+ Short description
330
+ @return: description
331
+ @rtype: int
332
+ """
333
+ )
334
+ assert docstring.returns is not None
335
+ assert docstring.returns.type_name == "int"
336
+ assert docstring.returns.description == "description"
337
+ assert not docstring.returns.is_generator
338
+
339
+
340
+ def test_yields() -> None:
341
+ """Test parsing yields."""
342
+ docstring = parse(
343
+ """
344
+ Short description
345
+ """
346
+ )
347
+ assert docstring.returns is None
348
+
349
+ docstring = parse(
350
+ """
351
+ Short description
352
+ @yield: description
353
+ """
354
+ )
355
+ assert docstring.returns is not None
356
+ assert docstring.returns.type_name is None
357
+ assert docstring.returns.description == "description"
358
+ assert docstring.returns.is_generator
359
+
360
+ docstring = parse(
361
+ """
362
+ Short description
363
+ @yield: description
364
+ @ytype: int
365
+ """
366
+ )
367
+ assert docstring.returns is not None
368
+ assert docstring.returns.type_name == "int"
369
+ assert docstring.returns.description == "description"
370
+ assert docstring.returns.is_generator
371
+
372
+
373
+ def test_raises() -> None:
374
+ """Test parsing raises."""
375
+ docstring = parse(
376
+ """
377
+ Short description
378
+ """
379
+ )
380
+ assert len(docstring.raises) == 0
381
+
382
+ docstring = parse(
383
+ """
384
+ Short description
385
+ @raise: description
386
+ """
387
+ )
388
+ assert len(docstring.raises) == 1
389
+ assert docstring.raises[0].type_name is None
390
+ assert docstring.raises[0].description == "description"
391
+
392
+ docstring = parse(
393
+ """
394
+ Short description
395
+ @raise ValueError: description
396
+ """
397
+ )
398
+ assert len(docstring.raises) == 1
399
+ assert docstring.raises[0].type_name == "ValueError"
400
+ assert docstring.raises[0].description == "description"
401
+
402
+
403
+ def test_broken_meta() -> None:
404
+ """Test parsing broken meta."""
405
+ with pytest.raises(ParseError):
406
+ parse("@")
407
+
408
+ with pytest.raises(ParseError):
409
+ parse("@param herp derp")
410
+
411
+ with pytest.raises(ParseError):
412
+ parse("@param: invalid")
413
+
414
+ with pytest.raises(ParseError):
415
+ parse("@param with too many args: desc")
416
+
417
+ # these should not raise any errors
418
+ parse("@sthstrange: desc")
419
+
420
+
421
+ @pytest.mark.parametrize(
422
+ "source, expected",
423
+ [
424
+ ("", ""),
425
+ ("\n", ""),
426
+ ("Short description", "Short description"),
427
+ ("\nShort description\n", "Short description"),
428
+ ("\n Short description\n", "Short description"),
429
+ (
430
+ "Short description\n\nLong description",
431
+ "Short description\n\nLong description",
432
+ ),
433
+ (
434
+ """
435
+ Short description
436
+
437
+ Long description
438
+ """,
439
+ "Short description\n\nLong description",
440
+ ),
441
+ (
442
+ """
443
+ Short description
444
+
445
+ Long description
446
+ Second line
447
+ """,
448
+ "Short description\n\nLong description\nSecond line",
449
+ ),
450
+ (
451
+ "Short description\nLong description",
452
+ "Short description\nLong description",
453
+ ),
454
+ (
455
+ """
456
+ Short description
457
+ Long description
458
+ """,
459
+ "Short description\nLong description",
460
+ ),
461
+ (
462
+ "\nShort description\nLong description\n",
463
+ "Short description\nLong description",
464
+ ),
465
+ (
466
+ """
467
+ Short description
468
+ Long description
469
+ Second line
470
+ """,
471
+ "Short description\nLong description\nSecond line",
472
+ ),
473
+ (
474
+ """
475
+ Short description
476
+ @meta: asd
477
+ """,
478
+ "Short description\n@meta: asd",
479
+ ),
480
+ (
481
+ """
482
+ Short description
483
+ Long description
484
+ @meta: asd
485
+ """,
486
+ "Short description\nLong description\n@meta: asd",
487
+ ),
488
+ (
489
+ """
490
+ Short description
491
+ First line
492
+ Second line
493
+ @meta: asd
494
+ """,
495
+ "Short description\nFirst line\n Second line\n@meta: asd",
496
+ ),
497
+ (
498
+ """
499
+ Short description
500
+
501
+ First line
502
+ Second line
503
+ @meta: asd
504
+ """,
505
+ "Short description\n"
506
+ "\n"
507
+ "First line\n"
508
+ " Second line\n"
509
+ "@meta: asd",
510
+ ),
511
+ (
512
+ """
513
+ Short description
514
+
515
+ First line
516
+ Second line
517
+
518
+ @meta: asd
519
+ """,
520
+ "Short description\n"
521
+ "\n"
522
+ "First line\n"
523
+ " Second line\n"
524
+ "\n"
525
+ "@meta: asd",
526
+ ),
527
+ (
528
+ """
529
+ @meta: asd
530
+ """,
531
+ "@meta: asd",
532
+ ),
533
+ (
534
+ """
535
+ Short description
536
+
537
+ @meta: asd
538
+ 1
539
+ 2
540
+ 3
541
+ """,
542
+ "Short description\n"
543
+ "\n"
544
+ "@meta: asd\n"
545
+ " 1\n"
546
+ " 2\n"
547
+ " 3",
548
+ ),
549
+ (
550
+ """
551
+ Short description
552
+
553
+ @meta1: asd
554
+ 1
555
+ 2
556
+ 3
557
+ @meta2: herp
558
+ @meta3: derp
559
+ """,
560
+ "Short description\n"
561
+ "\n@meta1: asd\n"
562
+ " 1\n"
563
+ " 2\n"
564
+ " 3\n@meta2: herp\n"
565
+ "@meta3: derp",
566
+ ),
567
+ (
568
+ """
569
+ Short description
570
+
571
+ @meta ene due rabe: asd
572
+ """,
573
+ "Short description\n\n@meta ene due rabe: asd",
574
+ ),
575
+ (
576
+ """
577
+ Short description
578
+
579
+ @param name: description 1
580
+ @param priority: description 2
581
+ @type priority: int
582
+ @param sender: description 3
583
+ @type sender: str?
584
+ @type message: str?
585
+ @param message: description 4, defaults to 'hello'
586
+ @type multiline: str?
587
+ @param multiline: long description 5,
588
+ defaults to 'bye'
589
+ """,
590
+ "Short description\n"
591
+ "\n"
592
+ "@param name: description 1\n"
593
+ "@type priority: int\n"
594
+ "@param priority: description 2\n"
595
+ "@type sender: str?\n"
596
+ "@param sender: description 3\n"
597
+ "@type message: str?\n"
598
+ "@param message: description 4, defaults to 'hello'\n"
599
+ "@type multiline: str?\n"
600
+ "@param multiline: long description 5,\n"
601
+ " defaults to 'bye'",
602
+ ),
603
+ (
604
+ """
605
+ Short description
606
+ @raise: description
607
+ """,
608
+ "Short description\n@raise: description",
609
+ ),
610
+ (
611
+ """
612
+ Short description
613
+ @raise ValueError: description
614
+ """,
615
+ "Short description\n@raise ValueError: description",
616
+ ),
617
+ ],
618
+ )
619
+ def test_compose(source: str, expected: str) -> None:
620
+ """Test compose in default mode."""
621
+ assert compose(parse(source)) == expected
622
+
623
+
624
+ @pytest.mark.parametrize(
625
+ "source, expected",
626
+ [
627
+ (
628
+ """
629
+ Short description
630
+
631
+ @param name: description 1
632
+ @param priority: description 2
633
+ @type priority: int
634
+ @param sender: description 3
635
+ @type sender: str?
636
+ @type message: str?
637
+ @param message: description 4, defaults to 'hello'
638
+ @type multiline: str?
639
+ @param multiline: long description 5,
640
+ defaults to 'bye'
641
+ """,
642
+ "Short description\n"
643
+ "\n"
644
+ "@param name:\n"
645
+ " description 1\n"
646
+ "@type priority: int\n"
647
+ "@param priority:\n"
648
+ " description 2\n"
649
+ "@type sender: str?\n"
650
+ "@param sender:\n"
651
+ " description 3\n"
652
+ "@type message: str?\n"
653
+ "@param message:\n"
654
+ " description 4, defaults to 'hello'\n"
655
+ "@type multiline: str?\n"
656
+ "@param multiline:\n"
657
+ " long description 5,\n"
658
+ " defaults to 'bye'",
659
+ ),
660
+ ],
661
+ )
662
+ def test_compose_clean(source: str, expected: str) -> None:
663
+ """Test compose in clean mode."""
664
+ assert (
665
+ compose(parse(source), rendering_style=RenderingStyle.CLEAN)
666
+ == expected
667
+ )
668
+
669
+
670
+ @pytest.mark.parametrize(
671
+ "source, expected",
672
+ [
673
+ (
674
+ """
675
+ Short description
676
+
677
+ @param name: description 1
678
+ @param priority: description 2
679
+ @type priority: int
680
+ @param sender: description 3
681
+ @type sender: str?
682
+ @type message: str?
683
+ @param message: description 4, defaults to 'hello'
684
+ @type multiline: str?
685
+ @param multiline: long description 5,
686
+ defaults to 'bye'
687
+ """,
688
+ "Short description\n"
689
+ "\n"
690
+ "@param name:\n"
691
+ " description 1\n"
692
+ "@type priority:\n"
693
+ " int\n"
694
+ "@param priority:\n"
695
+ " description 2\n"
696
+ "@type sender:\n"
697
+ " str?\n"
698
+ "@param sender:\n"
699
+ " description 3\n"
700
+ "@type message:\n"
701
+ " str?\n"
702
+ "@param message:\n"
703
+ " description 4, defaults to 'hello'\n"
704
+ "@type multiline:\n"
705
+ " str?\n"
706
+ "@param multiline:\n"
707
+ " long description 5,\n"
708
+ " defaults to 'bye'",
709
+ ),
710
+ ],
711
+ )
712
+ def test_compose_expanded(source: str, expected: str) -> None:
713
+ """Test compose in expanded mode."""
714
+ assert (
715
+ compose(parse(source), rendering_style=RenderingStyle.EXPANDED)
716
+ == expected
717
+ )
718
+
719
+
720
+ def test_short_rtype() -> None:
721
+ """Test abbreviated docstring with only return type information."""
722
+ string = "Short description.\n\n@rtype: float"
723
+ docstring = parse(string)
724
+ assert compose(docstring) == string
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_google.py ADDED
@@ -0,0 +1,1000 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for Google-style docstring routines."""
2
+
3
+ import typing as T
4
+
5
+ import pytest
6
+ from docstring_parser.common import ParseError, RenderingStyle
7
+ from docstring_parser.google import (
8
+ GoogleParser,
9
+ Section,
10
+ SectionType,
11
+ compose,
12
+ parse,
13
+ )
14
+
15
+
16
+ def test_google_parser_unknown_section() -> None:
17
+ """Test parsing an unknown section with default GoogleParser
18
+ configuration.
19
+ """
20
+ parser = GoogleParser()
21
+ docstring = parser.parse(
22
+ """
23
+ Unknown:
24
+ spam: a
25
+ """
26
+ )
27
+ assert docstring.short_description == "Unknown:"
28
+ assert docstring.long_description == "spam: a"
29
+ assert len(docstring.meta) == 0
30
+
31
+
32
+ def test_google_parser_multi_line_parameter_type() -> None:
33
+ """Test parsing a multi-line parameter type with default GoogleParser"""
34
+ parser = GoogleParser()
35
+ docstring = parser.parse(
36
+ """Description of the function.
37
+
38
+ Args:
39
+ output_type (Literal["searchResults", "sourcedAnswer",
40
+ "structured"]): The type of output.
41
+ This can be one of the following:
42
+ - "searchResults": Represents the search results.
43
+ - "sourcedAnswer": Represents a sourced answer.
44
+ - "structured": Represents a structured output format.
45
+
46
+ Returns:
47
+ bool: Indicates success or failure.
48
+
49
+ """
50
+ )
51
+ assert docstring.params[0].arg_name == "output_type"
52
+
53
+
54
+ def test_google_parser_custom_sections() -> None:
55
+ """Test parsing an unknown section with custom GoogleParser
56
+ configuration.
57
+ """
58
+ parser = GoogleParser(
59
+ [
60
+ Section("DESCRIPTION", "desc", SectionType.SINGULAR),
61
+ Section("ARGUMENTS", "param", SectionType.MULTIPLE),
62
+ Section("ATTRIBUTES", "attribute", SectionType.MULTIPLE),
63
+ Section("EXAMPLES", "examples", SectionType.SINGULAR),
64
+ ],
65
+ title_colon=False,
66
+ )
67
+ docstring = parser.parse(
68
+ """
69
+ DESCRIPTION
70
+ This is the description.
71
+
72
+ ARGUMENTS
73
+ arg1: first arg
74
+ arg2: second arg
75
+
76
+ ATTRIBUTES
77
+ attr1: first attribute
78
+ attr2: second attribute
79
+
80
+ EXAMPLES
81
+ Many examples
82
+ More examples
83
+ """
84
+ )
85
+
86
+ assert docstring.short_description is None
87
+ assert docstring.long_description is None
88
+ assert len(docstring.meta) == 6
89
+ assert docstring.meta[0].args == ["desc"]
90
+ assert docstring.meta[0].description == "This is the description."
91
+ assert docstring.meta[1].args == ["param", "arg1"]
92
+ assert docstring.meta[1].description == "first arg"
93
+ assert docstring.meta[2].args == ["param", "arg2"]
94
+ assert docstring.meta[2].description == "second arg"
95
+ assert docstring.meta[3].args == ["attribute", "attr1"]
96
+ assert docstring.meta[3].description == "first attribute"
97
+ assert docstring.meta[4].args == ["attribute", "attr2"]
98
+ assert docstring.meta[4].description == "second attribute"
99
+ assert docstring.meta[5].args == ["examples"]
100
+ assert docstring.meta[5].description == "Many examples\nMore examples"
101
+
102
+
103
+ def test_google_parser_custom_sections_after() -> None:
104
+ """Test parsing an unknown section with custom GoogleParser configuration
105
+ that was set at a runtime.
106
+ """
107
+ parser = GoogleParser(title_colon=False)
108
+ parser.add_section(Section("Note", "note", SectionType.SINGULAR))
109
+ docstring = parser.parse(
110
+ """
111
+ short description
112
+
113
+ Note:
114
+ a note
115
+ """
116
+ )
117
+ assert docstring.short_description == "short description"
118
+ assert docstring.long_description == "Note:\n a note"
119
+
120
+ docstring = parser.parse(
121
+ """
122
+ short description
123
+
124
+ Note a note
125
+ """
126
+ )
127
+ assert docstring.short_description == "short description"
128
+ assert docstring.long_description == "Note a note"
129
+
130
+ docstring = parser.parse(
131
+ """
132
+ short description
133
+
134
+ Note
135
+ a note
136
+ """
137
+ )
138
+ assert len(docstring.meta) == 1
139
+ assert docstring.meta[0].args == ["note"]
140
+ assert docstring.meta[0].description == "a note"
141
+
142
+
143
+ @pytest.mark.parametrize(
144
+ "source, expected",
145
+ [
146
+ ("", None),
147
+ ("\n", None),
148
+ ("Short description", "Short description"),
149
+ ("\nShort description\n", "Short description"),
150
+ ("\n Short description\n", "Short description"),
151
+ ],
152
+ )
153
+ def test_short_description(source: str, expected: str) -> None:
154
+ """Test parsing short description."""
155
+ docstring = parse(source)
156
+ assert docstring.short_description == expected
157
+ assert docstring.long_description is None
158
+ assert not docstring.meta
159
+
160
+
161
+ @pytest.mark.parametrize(
162
+ "source, expected_short_desc, expected_long_desc, expected_blank",
163
+ [
164
+ (
165
+ "Short description\n\nLong description",
166
+ "Short description",
167
+ "Long description",
168
+ True,
169
+ ),
170
+ (
171
+ """
172
+ Short description
173
+
174
+ Long description
175
+ """,
176
+ "Short description",
177
+ "Long description",
178
+ True,
179
+ ),
180
+ (
181
+ """
182
+ Short description
183
+
184
+ Long description
185
+ Second line
186
+ """,
187
+ "Short description",
188
+ "Long description\nSecond line",
189
+ True,
190
+ ),
191
+ (
192
+ "Short description\nLong description",
193
+ "Short description",
194
+ "Long description",
195
+ False,
196
+ ),
197
+ (
198
+ """
199
+ Short description
200
+ Long description
201
+ """,
202
+ "Short description",
203
+ "Long description",
204
+ False,
205
+ ),
206
+ (
207
+ "\nShort description\nLong description\n",
208
+ "Short description",
209
+ "Long description",
210
+ False,
211
+ ),
212
+ (
213
+ """
214
+ Short description
215
+ Long description
216
+ Second line
217
+ """,
218
+ "Short description",
219
+ "Long description\nSecond line",
220
+ False,
221
+ ),
222
+ ],
223
+ )
224
+ def test_long_description(
225
+ source: str,
226
+ expected_short_desc: str,
227
+ expected_long_desc: str,
228
+ expected_blank: bool,
229
+ ) -> None:
230
+ """Test parsing long description."""
231
+ docstring = parse(source)
232
+ assert docstring.short_description == expected_short_desc
233
+ assert docstring.long_description == expected_long_desc
234
+ assert docstring.blank_after_short_description == expected_blank
235
+ assert not docstring.meta
236
+
237
+
238
+ @pytest.mark.parametrize(
239
+ "source, expected_short_desc, expected_long_desc, "
240
+ "expected_blank_short_desc, expected_blank_long_desc",
241
+ [
242
+ (
243
+ """
244
+ Short description
245
+ Args:
246
+ asd:
247
+ """,
248
+ "Short description",
249
+ None,
250
+ False,
251
+ False,
252
+ ),
253
+ (
254
+ """
255
+ Short description
256
+ Long description
257
+ Args:
258
+ asd:
259
+ """,
260
+ "Short description",
261
+ "Long description",
262
+ False,
263
+ False,
264
+ ),
265
+ (
266
+ """
267
+ Short description
268
+ First line
269
+ Second line
270
+ Args:
271
+ asd:
272
+ """,
273
+ "Short description",
274
+ "First line\n Second line",
275
+ False,
276
+ False,
277
+ ),
278
+ (
279
+ """
280
+ Short description
281
+
282
+ First line
283
+ Second line
284
+ Args:
285
+ asd:
286
+ """,
287
+ "Short description",
288
+ "First line\n Second line",
289
+ True,
290
+ False,
291
+ ),
292
+ (
293
+ """
294
+ Short description
295
+
296
+ First line
297
+ Second line
298
+
299
+ Args:
300
+ asd:
301
+ """,
302
+ "Short description",
303
+ "First line\n Second line",
304
+ True,
305
+ True,
306
+ ),
307
+ (
308
+ """
309
+ Args:
310
+ asd:
311
+ """,
312
+ None,
313
+ None,
314
+ False,
315
+ False,
316
+ ),
317
+ ],
318
+ )
319
+ def test_meta_newlines(
320
+ source: str,
321
+ expected_short_desc: T.Optional[str],
322
+ expected_long_desc: T.Optional[str],
323
+ expected_blank_short_desc: bool,
324
+ expected_blank_long_desc: bool,
325
+ ) -> None:
326
+ """Test parsing newlines around description sections."""
327
+ docstring = parse(source)
328
+ assert docstring.short_description == expected_short_desc
329
+ assert docstring.long_description == expected_long_desc
330
+ assert docstring.blank_after_short_description == expected_blank_short_desc
331
+ assert docstring.blank_after_long_description == expected_blank_long_desc
332
+ assert len(docstring.meta) == 1
333
+
334
+
335
+ def test_meta_with_multiline_description() -> None:
336
+ """Test parsing multiline meta documentation."""
337
+ docstring = parse(
338
+ """
339
+ Short description
340
+
341
+ Args:
342
+ spam: asd
343
+ 1
344
+ 2
345
+ 3
346
+ """
347
+ )
348
+ assert docstring.short_description == "Short description"
349
+ assert len(docstring.meta) == 1
350
+ assert docstring.meta[0].args == ["param", "spam"]
351
+ assert docstring.meta[0].arg_name == "spam"
352
+ assert docstring.meta[0].description == "asd\n1\n 2\n3"
353
+
354
+
355
+ def test_default_args() -> None:
356
+ """Test parsing default arguments."""
357
+ docstring = parse(
358
+ """A sample function
359
+
360
+ A function the demonstrates docstrings
361
+
362
+ Args:
363
+ arg1 (int): The firsty arg
364
+ arg2 (str): The second arg
365
+ arg3 (float, optional): The third arg. Defaults to 1.0.
366
+ arg4 (Optional[Dict[str, Any]], optional): The last arg. Defaults to None.
367
+ arg5 (str, optional): The fifth arg. Defaults to DEFAULT_ARG5.
368
+
369
+ Returns:
370
+ Mapping[str, Any]: The args packed in a mapping
371
+ """
372
+ )
373
+ assert docstring is not None
374
+ assert len(docstring.params) == 5
375
+
376
+ arg4 = docstring.params[3]
377
+ assert arg4.arg_name == "arg4"
378
+ assert arg4.is_optional
379
+ assert arg4.type_name == "Optional[Dict[str, Any]]"
380
+ assert arg4.default == "None"
381
+ assert arg4.description == "The last arg. Defaults to None."
382
+
383
+
384
+ def test_multiple_meta() -> None:
385
+ """Test parsing multiple meta."""
386
+ docstring = parse(
387
+ """
388
+ Short description
389
+
390
+ Args:
391
+ spam: asd
392
+ 1
393
+ 2
394
+ 3
395
+
396
+ Raises:
397
+ bla: herp
398
+ yay: derp
399
+ """
400
+ )
401
+ assert docstring.short_description == "Short description"
402
+ assert len(docstring.meta) == 3
403
+ assert docstring.meta[0].args == ["param", "spam"]
404
+ assert docstring.meta[0].arg_name == "spam"
405
+ assert docstring.meta[0].description == "asd\n1\n 2\n3"
406
+ assert docstring.meta[1].args == ["raises", "bla"]
407
+ assert docstring.meta[1].type_name == "bla"
408
+ assert docstring.meta[1].description == "herp"
409
+ assert docstring.meta[2].args == ["raises", "yay"]
410
+ assert docstring.meta[2].type_name == "yay"
411
+ assert docstring.meta[2].description == "derp"
412
+
413
+
414
+ def test_params() -> None:
415
+ """Test parsing params."""
416
+ docstring = parse("Short description")
417
+ assert len(docstring.params) == 0
418
+
419
+ docstring = parse(
420
+ """
421
+ Short description
422
+
423
+ Args:
424
+ name: description 1
425
+ priority (int): description 2
426
+ sender (str?): description 3
427
+ ratio (Optional[float], optional): description 4
428
+ """
429
+ )
430
+ assert len(docstring.params) == 4
431
+ assert docstring.params[0].arg_name == "name"
432
+ assert docstring.params[0].type_name is None
433
+ assert docstring.params[0].description == "description 1"
434
+ assert not docstring.params[0].is_optional
435
+ assert docstring.params[1].arg_name == "priority"
436
+ assert docstring.params[1].type_name == "int"
437
+ assert docstring.params[1].description == "description 2"
438
+ assert not docstring.params[1].is_optional
439
+ assert docstring.params[2].arg_name == "sender"
440
+ assert docstring.params[2].type_name == "str"
441
+ assert docstring.params[2].description == "description 3"
442
+ assert docstring.params[2].is_optional
443
+ assert docstring.params[3].arg_name == "ratio"
444
+ assert docstring.params[3].type_name == "Optional[float]"
445
+ assert docstring.params[3].description == "description 4"
446
+ assert docstring.params[3].is_optional
447
+
448
+ docstring = parse(
449
+ """
450
+ Short description
451
+
452
+ Args:
453
+ name: description 1
454
+ with multi-line text
455
+ priority (int): description 2
456
+ """
457
+ )
458
+ assert len(docstring.params) == 2
459
+ assert docstring.params[0].arg_name == "name"
460
+ assert docstring.params[0].type_name is None
461
+ assert docstring.params[0].description == (
462
+ "description 1\nwith multi-line text"
463
+ )
464
+ assert docstring.params[1].arg_name == "priority"
465
+ assert docstring.params[1].type_name == "int"
466
+ assert docstring.params[1].description == "description 2"
467
+
468
+
469
+ def test_attributes() -> None:
470
+ """Test parsing attributes."""
471
+ docstring = parse("Short description")
472
+ assert len(docstring.params) == 0
473
+
474
+ docstring = parse(
475
+ """
476
+ Short description
477
+
478
+ Attributes:
479
+ name: description 1
480
+ priority (int): description 2
481
+ sender (str?): description 3
482
+ ratio (Optional[float], optional): description 4
483
+ """
484
+ )
485
+ assert len(docstring.params) == 4
486
+ assert docstring.params[0].arg_name == "name"
487
+ assert docstring.params[0].type_name is None
488
+ assert docstring.params[0].description == "description 1"
489
+ assert not docstring.params[0].is_optional
490
+ assert docstring.params[1].arg_name == "priority"
491
+ assert docstring.params[1].type_name == "int"
492
+ assert docstring.params[1].description == "description 2"
493
+ assert not docstring.params[1].is_optional
494
+ assert docstring.params[2].arg_name == "sender"
495
+ assert docstring.params[2].type_name == "str"
496
+ assert docstring.params[2].description == "description 3"
497
+ assert docstring.params[2].is_optional
498
+ assert docstring.params[3].arg_name == "ratio"
499
+ assert docstring.params[3].type_name == "Optional[float]"
500
+ assert docstring.params[3].description == "description 4"
501
+ assert docstring.params[3].is_optional
502
+
503
+ docstring = parse(
504
+ """
505
+ Short description
506
+
507
+ Attributes:
508
+ name: description 1
509
+ with multi-line text
510
+ priority (int): description 2
511
+ """
512
+ )
513
+ assert len(docstring.params) == 2
514
+ assert docstring.params[0].arg_name == "name"
515
+ assert docstring.params[0].type_name is None
516
+ assert docstring.params[0].description == (
517
+ "description 1\nwith multi-line text"
518
+ )
519
+ assert docstring.params[1].arg_name == "priority"
520
+ assert docstring.params[1].type_name == "int"
521
+ assert docstring.params[1].description == "description 2"
522
+
523
+
524
+ def test_returns() -> None:
525
+ """Test parsing returns."""
526
+ docstring = parse(
527
+ """
528
+ Short description
529
+ """
530
+ )
531
+ assert docstring.returns is None
532
+ assert docstring.many_returns is not None
533
+ assert len(docstring.many_returns) == 0
534
+
535
+ docstring = parse(
536
+ """
537
+ Short description
538
+ Returns:
539
+ description
540
+ """
541
+ )
542
+ assert docstring.returns is not None
543
+ assert docstring.returns.type_name is None
544
+ assert docstring.returns.description == "description"
545
+ assert docstring.many_returns is not None
546
+ assert len(docstring.many_returns) == 1
547
+ assert docstring.many_returns[0] == docstring.returns
548
+
549
+ docstring = parse(
550
+ """
551
+ Short description
552
+ Returns:
553
+ description with: a colon!
554
+ """
555
+ )
556
+ assert docstring.returns is not None
557
+ assert docstring.returns.type_name is None
558
+ assert docstring.returns.description == "description with: a colon!"
559
+ assert docstring.many_returns is not None
560
+ assert len(docstring.many_returns) == 1
561
+ assert docstring.many_returns[0] == docstring.returns
562
+
563
+ docstring = parse(
564
+ """
565
+ Short description
566
+ Returns:
567
+ int: description
568
+ """
569
+ )
570
+ assert docstring.returns is not None
571
+ assert docstring.returns.type_name == "int"
572
+ assert docstring.returns.description == "description"
573
+ assert docstring.many_returns is not None
574
+ assert len(docstring.many_returns) == 1
575
+ assert docstring.many_returns[0] == docstring.returns
576
+
577
+ docstring = parse(
578
+ """
579
+ Returns:
580
+ Optional[Mapping[str, List[int]]]: A description: with a colon
581
+ """
582
+ )
583
+ assert docstring.returns is not None
584
+ assert docstring.returns.type_name == "Optional[Mapping[str, List[int]]]"
585
+ assert docstring.returns.description == "A description: with a colon"
586
+ assert docstring.many_returns is not None
587
+ assert len(docstring.many_returns) == 1
588
+ assert docstring.many_returns[0] == docstring.returns
589
+
590
+ docstring = parse(
591
+ """
592
+ Short description
593
+ Yields:
594
+ int: description
595
+ """
596
+ )
597
+ assert docstring.returns is not None
598
+ assert docstring.returns.type_name == "int"
599
+ assert docstring.returns.description == "description"
600
+ assert docstring.many_returns is not None
601
+ assert len(docstring.many_returns) == 1
602
+ assert docstring.many_returns[0] == docstring.returns
603
+
604
+ docstring = parse(
605
+ """
606
+ Short description
607
+ Returns:
608
+ int: description
609
+ with much text
610
+
611
+ even some spacing
612
+ """
613
+ )
614
+ assert docstring.returns is not None
615
+ assert docstring.returns.type_name == "int"
616
+ assert docstring.returns.description == (
617
+ "description\nwith much text\n\neven some spacing"
618
+ )
619
+ assert docstring.many_returns is not None
620
+ assert len(docstring.many_returns) == 1
621
+ assert docstring.many_returns[0] == docstring.returns
622
+
623
+
624
+ def test_raises() -> None:
625
+ """Test parsing raises."""
626
+ docstring = parse(
627
+ """
628
+ Short description
629
+ """
630
+ )
631
+ assert len(docstring.raises) == 0
632
+
633
+ docstring = parse(
634
+ """
635
+ Short description
636
+ Raises:
637
+ ValueError: description
638
+ """
639
+ )
640
+ assert len(docstring.raises) == 1
641
+ assert docstring.raises[0].type_name == "ValueError"
642
+ assert docstring.raises[0].description == "description"
643
+
644
+
645
+ def test_examples() -> None:
646
+ """Test parsing examples."""
647
+ docstring = parse(
648
+ """
649
+ Short description
650
+ Example:
651
+ example: 1
652
+ Examples:
653
+ long example
654
+
655
+ more here
656
+ """
657
+ )
658
+ assert len(docstring.examples) == 2
659
+ assert docstring.examples[0].description == "example: 1"
660
+ assert docstring.examples[1].description == "long example\n\nmore here"
661
+
662
+
663
+ def test_broken_meta() -> None:
664
+ """Test parsing broken meta."""
665
+ with pytest.raises(ParseError):
666
+ parse("Args:")
667
+
668
+ with pytest.raises(ParseError):
669
+ parse("Args:\n herp derp")
670
+
671
+
672
+ def test_unknown_meta() -> None:
673
+ """Test parsing unknown meta."""
674
+ docstring = parse(
675
+ """Short desc
676
+
677
+ Unknown 0:
678
+ title0: content0
679
+
680
+ Args:
681
+ arg0: desc0
682
+ arg1: desc1
683
+
684
+ Unknown1:
685
+ title1: content1
686
+
687
+ Unknown2:
688
+ title2: content2
689
+ """
690
+ )
691
+
692
+ assert docstring.params[0].arg_name == "arg0"
693
+ assert docstring.params[0].description == "desc0"
694
+ assert docstring.params[1].arg_name == "arg1"
695
+ assert docstring.params[1].description == "desc1"
696
+
697
+
698
+ def test_broken_arguments() -> None:
699
+ """Test parsing broken arguments."""
700
+ with pytest.raises(ParseError):
701
+ parse(
702
+ """This is a test
703
+
704
+ Args:
705
+ param - poorly formatted
706
+ """
707
+ )
708
+
709
+
710
+ def test_empty_example() -> None:
711
+ """Test parsing empty examples section."""
712
+ docstring = parse(
713
+ """Short description
714
+
715
+ Example:
716
+
717
+ Raises:
718
+ IOError: some error
719
+ """
720
+ )
721
+
722
+ assert len(docstring.examples) == 1
723
+ assert docstring.examples[0].args == ["examples"]
724
+ assert docstring.examples[0].description == ""
725
+
726
+
727
+ @pytest.mark.parametrize(
728
+ "source, expected",
729
+ [
730
+ ("", ""),
731
+ ("\n", ""),
732
+ ("Short description", "Short description"),
733
+ ("\nShort description\n", "Short description"),
734
+ ("\n Short description\n", "Short description"),
735
+ (
736
+ "Short description\n\nLong description",
737
+ "Short description\n\nLong description",
738
+ ),
739
+ (
740
+ """
741
+ Short description
742
+
743
+ Long description
744
+ """,
745
+ "Short description\n\nLong description",
746
+ ),
747
+ (
748
+ """
749
+ Short description
750
+
751
+ Long description
752
+ Second line
753
+ """,
754
+ "Short description\n\nLong description\nSecond line",
755
+ ),
756
+ (
757
+ "Short description\nLong description",
758
+ "Short description\nLong description",
759
+ ),
760
+ (
761
+ """
762
+ Short description
763
+ Long description
764
+ """,
765
+ "Short description\nLong description",
766
+ ),
767
+ (
768
+ "\nShort description\nLong description\n",
769
+ "Short description\nLong description",
770
+ ),
771
+ (
772
+ """
773
+ Short description
774
+ Long description
775
+ Second line
776
+ """,
777
+ "Short description\nLong description\nSecond line",
778
+ ),
779
+ (
780
+ """
781
+ Short description
782
+ Meta:
783
+ asd
784
+ """,
785
+ "Short description\nMeta:\n asd",
786
+ ),
787
+ (
788
+ """
789
+ Short description
790
+ Long description
791
+ Meta:
792
+ asd
793
+ """,
794
+ "Short description\nLong description\nMeta:\n asd",
795
+ ),
796
+ (
797
+ """
798
+ Short description
799
+ First line
800
+ Second line
801
+ Meta:
802
+ asd
803
+ """,
804
+ "Short description\n"
805
+ "First line\n"
806
+ " Second line\n"
807
+ "Meta:\n"
808
+ " asd",
809
+ ),
810
+ (
811
+ """
812
+ Short description
813
+
814
+ First line
815
+ Second line
816
+ Meta:
817
+ asd
818
+ """,
819
+ "Short description\n"
820
+ "\n"
821
+ "First line\n"
822
+ " Second line\n"
823
+ "Meta:\n"
824
+ " asd",
825
+ ),
826
+ (
827
+ """
828
+ Short description
829
+
830
+ First line
831
+ Second line
832
+
833
+ Meta:
834
+ asd
835
+ """,
836
+ "Short description\n"
837
+ "\n"
838
+ "First line\n"
839
+ " Second line\n"
840
+ "\n"
841
+ "Meta:\n"
842
+ " asd",
843
+ ),
844
+ (
845
+ """
846
+ Short description
847
+
848
+ Meta:
849
+ asd
850
+ 1
851
+ 2
852
+ 3
853
+ """,
854
+ "Short description\n"
855
+ "\n"
856
+ "Meta:\n"
857
+ " asd\n"
858
+ " 1\n"
859
+ " 2\n"
860
+ " 3",
861
+ ),
862
+ (
863
+ """
864
+ Short description
865
+
866
+ Meta1:
867
+ asd
868
+ 1
869
+ 2
870
+ 3
871
+ Meta2:
872
+ herp
873
+ Meta3:
874
+ derp
875
+ """,
876
+ "Short description\n"
877
+ "\n"
878
+ "Meta1:\n"
879
+ " asd\n"
880
+ " 1\n"
881
+ " 2\n"
882
+ " 3\n"
883
+ "Meta2:\n"
884
+ " herp\n"
885
+ "Meta3:\n"
886
+ " derp",
887
+ ),
888
+ (
889
+ """
890
+ Short description
891
+
892
+ Args:
893
+ name: description 1
894
+ priority (int): description 2
895
+ sender (str, optional): description 3
896
+ message (str, optional): description 4, defaults to 'hello'
897
+ multiline (str?):
898
+ long description 5,
899
+ defaults to 'bye'
900
+ """,
901
+ "Short description\n"
902
+ "\n"
903
+ "Args:\n"
904
+ " name: description 1\n"
905
+ " priority (int): description 2\n"
906
+ " sender (str?): description 3\n"
907
+ " message (str?): description 4, defaults to 'hello'\n"
908
+ " multiline (str?): long description 5,\n"
909
+ " defaults to 'bye'",
910
+ ),
911
+ (
912
+ """
913
+ Short description
914
+ Raises:
915
+ ValueError: description
916
+ """,
917
+ "Short description\nRaises:\n ValueError: description",
918
+ ),
919
+ ],
920
+ )
921
+ def test_compose(source: str, expected: str) -> None:
922
+ """Test compose in default mode."""
923
+ assert compose(parse(source)) == expected
924
+
925
+
926
+ @pytest.mark.parametrize(
927
+ "source, expected",
928
+ [
929
+ (
930
+ """
931
+ Short description
932
+
933
+ Args:
934
+ name: description 1
935
+ priority (int): description 2
936
+ sender (str, optional): description 3
937
+ message (str, optional): description 4, defaults to 'hello'
938
+ multiline (str?):
939
+ long description 5,
940
+ defaults to 'bye'
941
+ """,
942
+ "Short description\n"
943
+ "\n"
944
+ "Args:\n"
945
+ " name: description 1\n"
946
+ " priority (int): description 2\n"
947
+ " sender (str, optional): description 3\n"
948
+ " message (str, optional): description 4, defaults to 'hello'\n"
949
+ " multiline (str, optional): long description 5,\n"
950
+ " defaults to 'bye'",
951
+ ),
952
+ ],
953
+ )
954
+ def test_compose_clean(source: str, expected: str) -> None:
955
+ """Test compose in clean mode."""
956
+ assert (
957
+ compose(parse(source), rendering_style=RenderingStyle.CLEAN)
958
+ == expected
959
+ )
960
+
961
+
962
+ @pytest.mark.parametrize(
963
+ "source, expected",
964
+ [
965
+ (
966
+ """
967
+ Short description
968
+
969
+ Args:
970
+ name: description 1
971
+ priority (int): description 2
972
+ sender (str, optional): description 3
973
+ message (str, optional): description 4, defaults to 'hello'
974
+ multiline (str?):
975
+ long description 5,
976
+ defaults to 'bye'
977
+ """,
978
+ "Short description\n"
979
+ "\n"
980
+ "Args:\n"
981
+ " name:\n"
982
+ " description 1\n"
983
+ " priority (int):\n"
984
+ " description 2\n"
985
+ " sender (str, optional):\n"
986
+ " description 3\n"
987
+ " message (str, optional):\n"
988
+ " description 4, defaults to 'hello'\n"
989
+ " multiline (str, optional):\n"
990
+ " long description 5,\n"
991
+ " defaults to 'bye'",
992
+ ),
993
+ ],
994
+ )
995
+ def test_compose_expanded(source: str, expected: str) -> None:
996
+ """Test compose in expanded mode."""
997
+ assert (
998
+ compose(parse(source), rendering_style=RenderingStyle.EXPANDED)
999
+ == expected
1000
+ )
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_numpydoc.py ADDED
@@ -0,0 +1,1088 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for numpydoc-style docstring routines."""
2
+
3
+ import typing as T
4
+
5
+ import pytest
6
+ from docstring_parser.numpydoc import compose, parse
7
+
8
+
9
+ @pytest.mark.parametrize(
10
+ "source, expected",
11
+ [
12
+ ("", None),
13
+ ("\n", None),
14
+ ("Short description", "Short description"),
15
+ ("\nShort description\n", "Short description"),
16
+ ("\n Short description\n", "Short description"),
17
+ ],
18
+ )
19
+ def test_short_description(source: str, expected: str) -> None:
20
+ """Test parsing short description."""
21
+ docstring = parse(source)
22
+ assert docstring.short_description == expected
23
+ assert docstring.long_description is None
24
+ assert not docstring.meta
25
+
26
+
27
+ @pytest.mark.parametrize(
28
+ "source, expected_short_desc, expected_long_desc, expected_blank",
29
+ [
30
+ (
31
+ "Short description\n\nLong description",
32
+ "Short description",
33
+ "Long description",
34
+ True,
35
+ ),
36
+ (
37
+ """
38
+ Short description
39
+
40
+ Long description
41
+ """,
42
+ "Short description",
43
+ "Long description",
44
+ True,
45
+ ),
46
+ (
47
+ """
48
+ Short description
49
+
50
+ Long description
51
+ Second line
52
+ """,
53
+ "Short description",
54
+ "Long description\nSecond line",
55
+ True,
56
+ ),
57
+ (
58
+ "Short description\nLong description",
59
+ "Short description",
60
+ "Long description",
61
+ False,
62
+ ),
63
+ (
64
+ """
65
+ Short description
66
+ Long description
67
+ """,
68
+ "Short description",
69
+ "Long description",
70
+ False,
71
+ ),
72
+ (
73
+ "\nShort description\nLong description\n",
74
+ "Short description",
75
+ "Long description",
76
+ False,
77
+ ),
78
+ (
79
+ """
80
+ Short description
81
+ Long description
82
+ Second line
83
+ """,
84
+ "Short description",
85
+ "Long description\nSecond line",
86
+ False,
87
+ ),
88
+ ],
89
+ )
90
+ def test_long_description(
91
+ source: str,
92
+ expected_short_desc: str,
93
+ expected_long_desc: str,
94
+ expected_blank: bool,
95
+ ) -> None:
96
+ """Test parsing long description."""
97
+ docstring = parse(source)
98
+ assert docstring.short_description == expected_short_desc
99
+ assert docstring.long_description == expected_long_desc
100
+ assert docstring.blank_after_short_description == expected_blank
101
+ assert not docstring.meta
102
+
103
+
104
+ @pytest.mark.parametrize(
105
+ "source, expected_short_desc, expected_long_desc, "
106
+ "expected_blank_short_desc, expected_blank_long_desc",
107
+ [
108
+ (
109
+ """
110
+ Short description
111
+ Parameters
112
+ ----------
113
+ asd
114
+ """,
115
+ "Short description",
116
+ None,
117
+ False,
118
+ False,
119
+ ),
120
+ (
121
+ """
122
+ Short description
123
+ Long description
124
+ Parameters
125
+ ----------
126
+ asd
127
+ """,
128
+ "Short description",
129
+ "Long description",
130
+ False,
131
+ False,
132
+ ),
133
+ (
134
+ """
135
+ Short description
136
+ First line
137
+ Second line
138
+ Parameters
139
+ ----------
140
+ asd
141
+ """,
142
+ "Short description",
143
+ "First line\n Second line",
144
+ False,
145
+ False,
146
+ ),
147
+ (
148
+ """
149
+ Short description
150
+
151
+ First line
152
+ Second line
153
+ Parameters
154
+ ----------
155
+ asd
156
+ """,
157
+ "Short description",
158
+ "First line\n Second line",
159
+ True,
160
+ False,
161
+ ),
162
+ (
163
+ """
164
+ Short description
165
+
166
+ First line
167
+ Second line
168
+
169
+ Parameters
170
+ ----------
171
+ asd
172
+ """,
173
+ "Short description",
174
+ "First line\n Second line",
175
+ True,
176
+ True,
177
+ ),
178
+ (
179
+ """
180
+ Parameters
181
+ ----------
182
+ asd
183
+ """,
184
+ None,
185
+ None,
186
+ False,
187
+ False,
188
+ ),
189
+ ],
190
+ )
191
+ def test_meta_newlines(
192
+ source: str,
193
+ expected_short_desc: T.Optional[str],
194
+ expected_long_desc: T.Optional[str],
195
+ expected_blank_short_desc: bool,
196
+ expected_blank_long_desc: bool,
197
+ ) -> None:
198
+ """Test parsing newlines around description sections."""
199
+ docstring = parse(source)
200
+ assert docstring.short_description == expected_short_desc
201
+ assert docstring.long_description == expected_long_desc
202
+ assert docstring.blank_after_short_description == expected_blank_short_desc
203
+ assert docstring.blank_after_long_description == expected_blank_long_desc
204
+ assert len(docstring.meta) == 1
205
+
206
+
207
+ def test_meta_with_multiline_description() -> None:
208
+ """Test parsing multiline meta documentation."""
209
+ docstring = parse(
210
+ """
211
+ Short description
212
+
213
+ Parameters
214
+ ----------
215
+ spam
216
+ asd
217
+ 1
218
+ 2
219
+ 3
220
+ """
221
+ )
222
+ assert docstring.short_description == "Short description"
223
+ assert len(docstring.meta) == 1
224
+ assert docstring.meta[0].args == ["param", "spam"]
225
+ assert docstring.meta[0].arg_name == "spam"
226
+ assert docstring.meta[0].description == "asd\n1\n 2\n3"
227
+
228
+
229
+ @pytest.mark.parametrize(
230
+ "source, expected_is_optional, expected_type_name, expected_default",
231
+ [
232
+ (
233
+ """
234
+ Parameters
235
+ ----------
236
+ arg1 : int
237
+ The first arg
238
+ """,
239
+ False,
240
+ "int",
241
+ None,
242
+ ),
243
+ (
244
+ """
245
+ Parameters
246
+ ----------
247
+ arg2 : str
248
+ The second arg
249
+ """,
250
+ False,
251
+ "str",
252
+ None,
253
+ ),
254
+ (
255
+ """
256
+ Parameters
257
+ ----------
258
+ arg3 : float, optional
259
+ The third arg. Default is 1.0.
260
+ """,
261
+ True,
262
+ "float",
263
+ "1.0",
264
+ ),
265
+ (
266
+ """
267
+ Parameters
268
+ ----------
269
+ arg4 : Optional[Dict[str, Any]], optional
270
+ The fourth arg. Defaults to None
271
+ """,
272
+ True,
273
+ "Optional[Dict[str, Any]]",
274
+ "None",
275
+ ),
276
+ (
277
+ """
278
+ Parameters
279
+ ----------
280
+ arg5 : str, optional
281
+ The fifth arg. Default: DEFAULT_ARGS
282
+ """,
283
+ True,
284
+ "str",
285
+ "DEFAULT_ARGS",
286
+ ),
287
+ (
288
+ """
289
+ Parameters
290
+ ----------
291
+ parameter_without_default : int
292
+ The parameter_without_default is required.
293
+ """,
294
+ False,
295
+ "int",
296
+ None,
297
+ ),
298
+ ],
299
+ )
300
+ def test_default_args(
301
+ source: str,
302
+ expected_is_optional: bool,
303
+ expected_type_name: T.Optional[str],
304
+ expected_default: T.Optional[str],
305
+ ) -> None:
306
+ """Test parsing default arguments."""
307
+ docstring = parse(source)
308
+ assert docstring is not None
309
+ assert len(docstring.params) == 1
310
+
311
+ arg1 = docstring.params[0]
312
+ assert arg1.is_optional == expected_is_optional
313
+ assert arg1.type_name == expected_type_name
314
+ assert arg1.default == expected_default
315
+
316
+
317
+ def test_multiple_meta() -> None:
318
+ """Test parsing multiple meta."""
319
+ docstring = parse(
320
+ """
321
+ Short description
322
+
323
+ Parameters
324
+ ----------
325
+ spam
326
+ asd
327
+ 1
328
+ 2
329
+ 3
330
+
331
+ Raises
332
+ ------
333
+ bla
334
+ herp
335
+ yay
336
+ derp
337
+ """
338
+ )
339
+ assert docstring.short_description == "Short description"
340
+ assert len(docstring.meta) == 3
341
+ assert docstring.meta[0].args == ["param", "spam"]
342
+ assert docstring.meta[0].arg_name == "spam"
343
+ assert docstring.meta[0].description == "asd\n1\n 2\n3"
344
+ assert docstring.meta[1].args == ["raises", "bla"]
345
+ assert docstring.meta[1].type_name == "bla"
346
+ assert docstring.meta[1].description == "herp"
347
+ assert docstring.meta[2].args == ["raises", "yay"]
348
+ assert docstring.meta[2].type_name == "yay"
349
+ assert docstring.meta[2].description == "derp"
350
+
351
+
352
+ def test_params() -> None:
353
+ """Test parsing params."""
354
+ docstring = parse("Short description")
355
+ assert len(docstring.params) == 0
356
+
357
+ docstring = parse(
358
+ """
359
+ Short description
360
+
361
+ Parameters
362
+ ----------
363
+ name
364
+ description 1
365
+ priority : int
366
+ description 2
367
+ sender : str, optional
368
+ description 3
369
+ ratio : Optional[float], optional
370
+ description 4
371
+ """
372
+ )
373
+ assert len(docstring.params) == 4
374
+ assert docstring.params[0].arg_name == "name"
375
+ assert docstring.params[0].type_name is None
376
+ assert docstring.params[0].description == "description 1"
377
+ assert not docstring.params[0].is_optional
378
+ assert docstring.params[1].arg_name == "priority"
379
+ assert docstring.params[1].type_name == "int"
380
+ assert docstring.params[1].description == "description 2"
381
+ assert not docstring.params[1].is_optional
382
+ assert docstring.params[2].arg_name == "sender"
383
+ assert docstring.params[2].type_name == "str"
384
+ assert docstring.params[2].description == "description 3"
385
+ assert docstring.params[2].is_optional
386
+ assert docstring.params[3].arg_name == "ratio"
387
+ assert docstring.params[3].type_name == "Optional[float]"
388
+ assert docstring.params[3].description == "description 4"
389
+ assert docstring.params[3].is_optional
390
+
391
+ docstring = parse(
392
+ """
393
+ Short description
394
+
395
+ Parameters
396
+ ----------
397
+ name
398
+ description 1
399
+ with multi-line text
400
+ priority : int
401
+ description 2
402
+ """
403
+ )
404
+ assert len(docstring.params) == 2
405
+ assert docstring.params[0].arg_name == "name"
406
+ assert docstring.params[0].type_name is None
407
+ assert docstring.params[0].description == (
408
+ "description 1\nwith multi-line text"
409
+ )
410
+ assert docstring.params[1].arg_name == "priority"
411
+ assert docstring.params[1].type_name == "int"
412
+ assert docstring.params[1].description == "description 2"
413
+
414
+
415
+ def test_attributes() -> None:
416
+ """Test parsing attributes."""
417
+ docstring = parse("Short description")
418
+ assert len(docstring.params) == 0
419
+
420
+ docstring = parse(
421
+ """
422
+ Short description
423
+
424
+ Attributes
425
+ ----------
426
+ name
427
+ description 1
428
+ priority : int
429
+ description 2
430
+ sender : str, optional
431
+ description 3
432
+ ratio : Optional[float], optional
433
+ description 4
434
+ """
435
+ )
436
+ assert len(docstring.params) == 4
437
+ assert docstring.params[0].arg_name == "name"
438
+ assert docstring.params[0].type_name is None
439
+ assert docstring.params[0].description == "description 1"
440
+ assert not docstring.params[0].is_optional
441
+ assert docstring.params[1].arg_name == "priority"
442
+ assert docstring.params[1].type_name == "int"
443
+ assert docstring.params[1].description == "description 2"
444
+ assert not docstring.params[1].is_optional
445
+ assert docstring.params[2].arg_name == "sender"
446
+ assert docstring.params[2].type_name == "str"
447
+ assert docstring.params[2].description == "description 3"
448
+ assert docstring.params[2].is_optional
449
+ assert docstring.params[3].arg_name == "ratio"
450
+ assert docstring.params[3].type_name == "Optional[float]"
451
+ assert docstring.params[3].description == "description 4"
452
+ assert docstring.params[3].is_optional
453
+
454
+ docstring = parse(
455
+ """
456
+ Short description
457
+
458
+ Attributes
459
+ ----------
460
+ name
461
+ description 1
462
+ with multi-line text
463
+ priority : int
464
+ description 2
465
+ """
466
+ )
467
+ assert len(docstring.params) == 2
468
+ assert docstring.params[0].arg_name == "name"
469
+ assert docstring.params[0].type_name is None
470
+ assert docstring.params[0].description == (
471
+ "description 1\nwith multi-line text"
472
+ )
473
+ assert docstring.params[1].arg_name == "priority"
474
+ assert docstring.params[1].type_name == "int"
475
+ assert docstring.params[1].description == "description 2"
476
+
477
+
478
+ def test_other_params() -> None:
479
+ """Test parsing other parameters."""
480
+ docstring = parse(
481
+ """
482
+ Short description
483
+ Other Parameters
484
+ ----------------
485
+ only_seldom_used_keywords : type, optional
486
+ Explanation
487
+ common_parameters_listed_above : type, optional
488
+ Explanation
489
+ """
490
+ )
491
+ assert len(docstring.meta) == 2
492
+ assert docstring.meta[0].args == [
493
+ "other_param",
494
+ "only_seldom_used_keywords",
495
+ ]
496
+ assert docstring.meta[0].arg_name == "only_seldom_used_keywords"
497
+ assert docstring.meta[0].type_name == "type"
498
+ assert docstring.meta[0].is_optional
499
+ assert docstring.meta[0].description == "Explanation"
500
+
501
+ assert docstring.meta[1].args == [
502
+ "other_param",
503
+ "common_parameters_listed_above",
504
+ ]
505
+
506
+
507
+ def test_yields() -> None:
508
+ """Test parsing yields."""
509
+ docstring = parse(
510
+ """
511
+ Short description
512
+ Yields
513
+ ------
514
+ int
515
+ description
516
+ """
517
+ )
518
+ assert len(docstring.meta) == 1
519
+ assert docstring.meta[0].args == ["yields"]
520
+ assert docstring.meta[0].type_name == "int"
521
+ assert docstring.meta[0].description == "description"
522
+ assert docstring.meta[0].return_name is None
523
+ assert docstring.meta[0].is_generator
524
+
525
+
526
+ def test_returns() -> None:
527
+ """Test parsing returns."""
528
+ docstring = parse(
529
+ """
530
+ Short description
531
+ """
532
+ )
533
+ assert docstring.returns is None
534
+ assert docstring.many_returns is not None
535
+ assert len(docstring.many_returns) == 0
536
+
537
+ docstring = parse(
538
+ """
539
+ Short description
540
+ Returns
541
+ -------
542
+ type
543
+ """
544
+ )
545
+ assert docstring.returns is not None
546
+ assert docstring.returns.type_name == "type"
547
+ assert docstring.returns.description is None
548
+ assert docstring.many_returns is not None
549
+ assert len(docstring.many_returns) == 1
550
+ assert docstring.many_returns[0] == docstring.returns
551
+
552
+ docstring = parse(
553
+ """
554
+ Short description
555
+ Returns
556
+ -------
557
+ int
558
+ description
559
+ """
560
+ )
561
+ assert docstring.returns is not None
562
+ assert docstring.returns.type_name == "int"
563
+ assert docstring.returns.description == "description"
564
+ assert docstring.many_returns is not None
565
+ assert len(docstring.many_returns) == 1
566
+ assert docstring.many_returns[0] == docstring.returns
567
+
568
+ docstring = parse(
569
+ """
570
+ Returns
571
+ -------
572
+ Optional[Mapping[str, List[int]]]
573
+ A description: with a colon
574
+ """
575
+ )
576
+ assert docstring.returns is not None
577
+ assert docstring.returns.type_name == "Optional[Mapping[str, List[int]]]"
578
+ assert docstring.returns.description == "A description: with a colon"
579
+ assert docstring.many_returns is not None
580
+ assert len(docstring.many_returns) == 1
581
+ assert docstring.many_returns[0] == docstring.returns
582
+
583
+ docstring = parse(
584
+ """
585
+ Short description
586
+ Returns
587
+ -------
588
+ int
589
+ description
590
+ with much text
591
+
592
+ even some spacing
593
+ """
594
+ )
595
+ assert docstring.returns is not None
596
+ assert docstring.returns.type_name == "int"
597
+ assert docstring.returns.description == (
598
+ "description\nwith much text\n\neven some spacing"
599
+ )
600
+ assert docstring.many_returns is not None
601
+ assert len(docstring.many_returns) == 1
602
+ assert docstring.many_returns[0] == docstring.returns
603
+
604
+ docstring = parse(
605
+ """
606
+ Short description
607
+ Returns
608
+ -------
609
+ a : int
610
+ description for a
611
+ b : str
612
+ description for b
613
+ """
614
+ )
615
+ assert docstring.returns is not None
616
+ assert docstring.returns.type_name == "int"
617
+ assert docstring.returns.description == ("description for a")
618
+ assert docstring.many_returns is not None
619
+ assert len(docstring.many_returns) == 2
620
+ assert docstring.many_returns[0].type_name == "int"
621
+ assert docstring.many_returns[0].description == "description for a"
622
+ assert docstring.many_returns[0].return_name == "a"
623
+ assert docstring.many_returns[1].type_name == "str"
624
+ assert docstring.many_returns[1].description == "description for b"
625
+ assert docstring.many_returns[1].return_name == "b"
626
+
627
+
628
+ def test_raises() -> None:
629
+ """Test parsing raises."""
630
+ docstring = parse(
631
+ """
632
+ Short description
633
+ """
634
+ )
635
+ assert len(docstring.raises) == 0
636
+
637
+ docstring = parse(
638
+ """
639
+ Short description
640
+ Raises
641
+ ------
642
+ ValueError
643
+ description
644
+ """
645
+ )
646
+ assert len(docstring.raises) == 1
647
+ assert docstring.raises[0].type_name == "ValueError"
648
+ assert docstring.raises[0].description == "description"
649
+
650
+
651
+ def test_warns() -> None:
652
+ """Test parsing warns."""
653
+ docstring = parse(
654
+ """
655
+ Short description
656
+ Warns
657
+ -----
658
+ UserWarning
659
+ description
660
+ """
661
+ )
662
+ assert len(docstring.meta) == 1
663
+ assert docstring.meta[0].type_name == "UserWarning"
664
+ assert docstring.meta[0].description == "description"
665
+
666
+
667
+ def test_simple_sections() -> None:
668
+ """Test parsing simple sections."""
669
+ docstring = parse(
670
+ """
671
+ Short description
672
+
673
+ See Also
674
+ --------
675
+ something : some thing you can also see
676
+ actually, anything can go in this section
677
+
678
+ Warnings
679
+ --------
680
+ Here be dragons
681
+
682
+ Notes
683
+ -----
684
+ None of this is real
685
+
686
+ References
687
+ ----------
688
+ Cite the relevant literature, e.g. [1]_. You may also cite these
689
+ references in the notes section above.
690
+
691
+ .. [1] O. McNoleg, "The integration of GIS, remote sensing,
692
+ expert systems and adaptive co-kriging for environmental habitat
693
+ modelling of the Highland Haggis using object-oriented, fuzzy-logic
694
+ and neural-network techniques," Computers & Geosciences, vol. 22,
695
+ pp. 585-588, 1996.
696
+ """
697
+ )
698
+ assert len(docstring.meta) == 4
699
+ assert docstring.meta[0].args == ["see_also"]
700
+ assert docstring.meta[0].description == (
701
+ "something : some thing you can also see\n"
702
+ "actually, anything can go in this section"
703
+ )
704
+
705
+ assert docstring.meta[1].args == ["warnings"]
706
+ assert docstring.meta[1].description == "Here be dragons"
707
+
708
+ assert docstring.meta[2].args == ["notes"]
709
+ assert docstring.meta[2].description == "None of this is real"
710
+
711
+ assert docstring.meta[3].args == ["references"]
712
+
713
+
714
+ @pytest.mark.parametrize(
715
+ "source, expected_results",
716
+ [
717
+ (
718
+ "Description\nExamples\n--------\nlong example\n\nmore here",
719
+ [
720
+ (None, "long example\n\nmore here"),
721
+ ],
722
+ ),
723
+ (
724
+ "Description\nExamples\n--------\n>>> test",
725
+ [
726
+ (">>> test", ""),
727
+ ],
728
+ ),
729
+ (
730
+ "Description\nExamples\n--------\n>>> testa\n>>> testb",
731
+ [
732
+ (">>> testa\n>>> testb", ""),
733
+ ],
734
+ ),
735
+ (
736
+ "Description\nExamples\n--------\n>>> test1\ndesc1",
737
+ [
738
+ (">>> test1", "desc1"),
739
+ ],
740
+ ),
741
+ (
742
+ "Description\nExamples\n--------\n"
743
+ ">>> test1a\n>>> test1b\ndesc1a\ndesc1b",
744
+ [
745
+ (">>> test1a\n>>> test1b", "desc1a\ndesc1b"),
746
+ ],
747
+ ),
748
+ (
749
+ "Description\nExamples\n--------\n"
750
+ ">>> test1\ndesc1\n>>> test2\ndesc2",
751
+ [
752
+ (">>> test1", "desc1"),
753
+ (">>> test2", "desc2"),
754
+ ],
755
+ ),
756
+ (
757
+ "Description\nExamples\n--------\n"
758
+ ">>> test1a\n>>> test1b\ndesc1a\ndesc1b\n"
759
+ ">>> test2a\n>>> test2b\ndesc2a\ndesc2b\n",
760
+ [
761
+ (">>> test1a\n>>> test1b", "desc1a\ndesc1b"),
762
+ (">>> test2a\n>>> test2b", "desc2a\ndesc2b"),
763
+ ],
764
+ ),
765
+ (
766
+ "Description\nExamples\n--------\n"
767
+ " >>> test1a\n >>> test1b\n desc1a\n desc1b\n"
768
+ " >>> test2a\n >>> test2b\n desc2a\n desc2b\n",
769
+ [
770
+ (">>> test1a\n>>> test1b", "desc1a\ndesc1b"),
771
+ (">>> test2a\n>>> test2b", "desc2a\ndesc2b"),
772
+ ],
773
+ ),
774
+ ],
775
+ )
776
+ def test_examples(
777
+ source, expected_results: T.List[T.Tuple[T.Optional[str], str]]
778
+ ) -> None:
779
+ """Test parsing examples."""
780
+ docstring = parse(source)
781
+ assert len(docstring.meta) == len(expected_results)
782
+ for meta, expected_result in zip(docstring.meta, expected_results):
783
+ assert meta.description == expected_result[1]
784
+ assert len(docstring.examples) == len(expected_results)
785
+ for example, expected_result in zip(docstring.examples, expected_results):
786
+ assert example.snippet == expected_result[0]
787
+ assert example.description == expected_result[1]
788
+
789
+
790
+ @pytest.mark.parametrize(
791
+ "source, expected_depr_version, expected_depr_desc",
792
+ [
793
+ (
794
+ "Short description\n\n.. deprecated:: 1.6.0\n This is busted!",
795
+ "1.6.0",
796
+ "This is busted!",
797
+ ),
798
+ (
799
+ (
800
+ "Short description\n\n"
801
+ ".. deprecated:: 1.6.0\n"
802
+ " This description has\n"
803
+ " multiple lines!"
804
+ ),
805
+ "1.6.0",
806
+ "This description has\nmultiple lines!",
807
+ ),
808
+ ("Short description\n\n.. deprecated:: 1.6.0", "1.6.0", None),
809
+ (
810
+ "Short description\n\n.. deprecated::\n No version!",
811
+ None,
812
+ "No version!",
813
+ ),
814
+ ],
815
+ )
816
+ def test_deprecation(
817
+ source: str,
818
+ expected_depr_version: T.Optional[str],
819
+ expected_depr_desc: T.Optional[str],
820
+ ) -> None:
821
+ """Test parsing deprecation notes."""
822
+ docstring = parse(source)
823
+
824
+ assert docstring.deprecation is not None
825
+ assert docstring.deprecation.version == expected_depr_version
826
+ assert docstring.deprecation.description == expected_depr_desc
827
+
828
+
829
+ @pytest.mark.parametrize(
830
+ "source, expected",
831
+ [
832
+ ("", ""),
833
+ ("\n", ""),
834
+ ("Short description", "Short description"),
835
+ ("\nShort description\n", "Short description"),
836
+ ("\n Short description\n", "Short description"),
837
+ (
838
+ "Short description\n\nLong description",
839
+ "Short description\n\nLong description",
840
+ ),
841
+ (
842
+ """
843
+ Short description
844
+
845
+ Long description
846
+ """,
847
+ "Short description\n\nLong description",
848
+ ),
849
+ (
850
+ """
851
+ Short description
852
+
853
+ Long description
854
+ Second line
855
+ """,
856
+ "Short description\n\nLong description\nSecond line",
857
+ ),
858
+ (
859
+ "Short description\nLong description",
860
+ "Short description\nLong description",
861
+ ),
862
+ (
863
+ """
864
+ Short description
865
+ Long description
866
+ """,
867
+ "Short description\nLong description",
868
+ ),
869
+ (
870
+ "\nShort description\nLong description\n",
871
+ "Short description\nLong description",
872
+ ),
873
+ (
874
+ """
875
+ Short description
876
+ Long description
877
+ Second line
878
+ """,
879
+ "Short description\nLong description\nSecond line",
880
+ ),
881
+ (
882
+ """
883
+ Short description
884
+ Meta:
885
+ -----
886
+ asd
887
+ """,
888
+ "Short description\nMeta:\n-----\n asd",
889
+ ),
890
+ (
891
+ """
892
+ Short description
893
+ Long description
894
+ Meta:
895
+ -----
896
+ asd
897
+ """,
898
+ "Short description\n"
899
+ "Long description\n"
900
+ "Meta:\n"
901
+ "-----\n"
902
+ " asd",
903
+ ),
904
+ (
905
+ """
906
+ Short description
907
+ First line
908
+ Second line
909
+ Meta:
910
+ -----
911
+ asd
912
+ """,
913
+ "Short description\n"
914
+ "First line\n"
915
+ " Second line\n"
916
+ "Meta:\n"
917
+ "-----\n"
918
+ " asd",
919
+ ),
920
+ (
921
+ """
922
+ Short description
923
+
924
+ First line
925
+ Second line
926
+ Meta:
927
+ -----
928
+ asd
929
+ """,
930
+ "Short description\n"
931
+ "\n"
932
+ "First line\n"
933
+ " Second line\n"
934
+ "Meta:\n"
935
+ "-----\n"
936
+ " asd",
937
+ ),
938
+ (
939
+ """
940
+ Short description
941
+
942
+ First line
943
+ Second line
944
+
945
+ Meta:
946
+ -----
947
+ asd
948
+ """,
949
+ "Short description\n"
950
+ "\n"
951
+ "First line\n"
952
+ " Second line\n"
953
+ "\n"
954
+ "Meta:\n"
955
+ "-----\n"
956
+ " asd",
957
+ ),
958
+ (
959
+ """
960
+ Short description
961
+
962
+ Meta:
963
+ -----
964
+ asd
965
+ 1
966
+ 2
967
+ 3
968
+ """,
969
+ "Short description\n"
970
+ "\n"
971
+ "Meta:\n"
972
+ "-----\n"
973
+ " asd\n"
974
+ " 1\n"
975
+ " 2\n"
976
+ " 3",
977
+ ),
978
+ (
979
+ """
980
+ Short description
981
+
982
+ Meta1:
983
+ ------
984
+ asd
985
+ 1
986
+ 2
987
+ 3
988
+ Meta2:
989
+ ------
990
+ herp
991
+ Meta3:
992
+ ------
993
+ derp
994
+ """,
995
+ "Short description\n"
996
+ "\n"
997
+ "Meta1:\n"
998
+ "------\n"
999
+ " asd\n"
1000
+ " 1\n"
1001
+ " 2\n"
1002
+ " 3\n"
1003
+ "Meta2:\n"
1004
+ "------\n"
1005
+ " herp\n"
1006
+ "Meta3:\n"
1007
+ "------\n"
1008
+ " derp",
1009
+ ),
1010
+ (
1011
+ """
1012
+ Short description
1013
+
1014
+ Parameters:
1015
+ -----------
1016
+ name
1017
+ description 1
1018
+ priority: int
1019
+ description 2
1020
+ sender: str, optional
1021
+ description 3
1022
+ message: str, optional
1023
+ description 4, defaults to 'hello'
1024
+ multiline: str, optional
1025
+ long description 5,
1026
+ defaults to 'bye'
1027
+ """,
1028
+ "Short description\n"
1029
+ "\n"
1030
+ "Parameters:\n"
1031
+ "-----------\n"
1032
+ " name\n"
1033
+ " description 1\n"
1034
+ " priority: int\n"
1035
+ " description 2\n"
1036
+ " sender: str, optional\n"
1037
+ " description 3\n"
1038
+ " message: str, optional\n"
1039
+ " description 4, defaults to 'hello'\n"
1040
+ " multiline: str, optional\n"
1041
+ " long description 5,\n"
1042
+ " defaults to 'bye'",
1043
+ ),
1044
+ (
1045
+ """
1046
+ Short description
1047
+ Raises:
1048
+ -------
1049
+ ValueError
1050
+ description
1051
+ """,
1052
+ "Short description\n"
1053
+ "Raises:\n"
1054
+ "-------\n"
1055
+ " ValueError\n"
1056
+ " description",
1057
+ ),
1058
+ (
1059
+ """
1060
+ Description
1061
+ Examples:
1062
+ --------
1063
+ >>> test1a
1064
+ >>> test1b
1065
+ desc1a
1066
+ desc1b
1067
+ >>> test2a
1068
+ >>> test2b
1069
+ desc2a
1070
+ desc2b
1071
+ """,
1072
+ "Description\n"
1073
+ "Examples:\n"
1074
+ "--------\n"
1075
+ ">>> test1a\n"
1076
+ ">>> test1b\n"
1077
+ "desc1a\n"
1078
+ "desc1b\n"
1079
+ ">>> test2a\n"
1080
+ ">>> test2b\n"
1081
+ "desc2a\n"
1082
+ "desc2b",
1083
+ ),
1084
+ ],
1085
+ )
1086
+ def test_compose(source: str, expected: str) -> None:
1087
+ """Test compose in default mode."""
1088
+ assert compose(parse(source)) == expected
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_parse_from_object.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for parse_from_object function and attribute docstrings."""
2
+
3
+ from unittest.mock import patch
4
+
5
+ from docstring_parser import parse_from_object
6
+
7
+ module_attr: int = 1
8
+ """Description for module_attr"""
9
+
10
+
11
+ def test_from_module_attribute_docstrings() -> None:
12
+ """Test the parse of attribute docstrings from a module."""
13
+ from . import test_parse_from_object # pylint: disable=C0415,W0406
14
+
15
+ docstring = parse_from_object(test_parse_from_object)
16
+
17
+ assert "parse_from_object" in docstring.short_description
18
+ assert len(docstring.params) == 1
19
+ assert docstring.params[0].arg_name == "module_attr"
20
+ assert docstring.params[0].type_name == "int"
21
+ assert docstring.params[0].description == "Description for module_attr"
22
+
23
+
24
+ def test_from_class_attribute_docstrings() -> None:
25
+ """Test the parse of attribute docstrings from a class."""
26
+
27
+ class StandardCase:
28
+ """Short description
29
+ Long description
30
+ """
31
+
32
+ attr_one: str
33
+ """Description for attr_one"""
34
+ attr_two: bool = False
35
+ """Description for attr_two"""
36
+
37
+ docstring = parse_from_object(StandardCase)
38
+
39
+ assert docstring.short_description == "Short description"
40
+ assert docstring.long_description == "Long description"
41
+ assert docstring.description == "Short description\nLong description"
42
+ assert len(docstring.params) == 2
43
+ assert docstring.params[0].arg_name == "attr_one"
44
+ assert docstring.params[0].type_name == "str"
45
+ assert docstring.params[0].description == "Description for attr_one"
46
+ assert docstring.params[1].arg_name == "attr_two"
47
+ assert docstring.params[1].type_name == "bool"
48
+ assert docstring.params[1].description == "Description for attr_two"
49
+
50
+
51
+ def test_from_class_attribute_docstrings_without_type() -> None:
52
+ """Test the parse of untyped attribute docstrings."""
53
+
54
+ class WithoutType: # pylint: disable=missing-class-docstring
55
+ attr_one = "value"
56
+ """Description for attr_one"""
57
+
58
+ docstring = parse_from_object(WithoutType)
59
+
60
+ assert docstring.short_description is None
61
+ assert docstring.long_description is None
62
+ assert docstring.description is None
63
+ assert len(docstring.params) == 1
64
+ assert docstring.params[0].arg_name == "attr_one"
65
+ assert docstring.params[0].type_name is None
66
+ assert docstring.params[0].description == "Description for attr_one"
67
+
68
+
69
+ def test_from_class_without_source() -> None:
70
+ """Test the parse of class when source is unavailable."""
71
+
72
+ class WithoutSource:
73
+ """Short description"""
74
+
75
+ attr_one: str
76
+ """Description for attr_one"""
77
+
78
+ with patch(
79
+ "inspect.getsource", side_effect=OSError("could not get source code")
80
+ ):
81
+ docstring = parse_from_object(WithoutSource)
82
+
83
+ assert docstring.short_description == "Short description"
84
+ assert docstring.long_description is None
85
+ assert docstring.description == "Short description"
86
+ assert len(docstring.params) == 0
87
+
88
+
89
+ def test_from_function() -> None:
90
+ """Test the parse of a function docstring."""
91
+
92
+ def a_function(param1: str, param2: int = 2):
93
+ """Short description
94
+ Args:
95
+ param1: Description for param1
96
+ param2: Description for param2
97
+ """
98
+ return f"{param1} {param2}"
99
+
100
+ docstring = parse_from_object(a_function)
101
+
102
+ assert docstring.short_description == "Short description"
103
+ assert docstring.description == "Short description"
104
+ assert len(docstring.params) == 2
105
+ assert docstring.params[0].arg_name == "param1"
106
+ assert docstring.params[0].type_name is None
107
+ assert docstring.params[0].description == "Description for param1"
108
+ assert docstring.params[1].arg_name == "param2"
109
+ assert docstring.params[1].type_name is None
110
+ assert docstring.params[1].description == "Description for param2"
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_parser.py ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for generic docstring routines."""
2
+
3
+ import pytest
4
+ from docstring_parser.common import DocstringStyle, ParseError
5
+ from docstring_parser.parser import parse
6
+
7
+
8
+ def test_rest() -> None:
9
+ """Test ReST-style parser autodetection."""
10
+ docstring = parse(
11
+ """
12
+ Short description
13
+
14
+ Long description
15
+
16
+ Causing people to indent:
17
+
18
+ A lot sometimes
19
+
20
+ :param spam: spam desc
21
+ :param int bla: bla desc
22
+ :param str yay:
23
+ :raises ValueError: exc desc
24
+ :returns tuple: ret desc
25
+ """
26
+ )
27
+
28
+ assert docstring.style == DocstringStyle.REST
29
+ assert docstring.short_description == "Short description"
30
+ assert docstring.long_description == (
31
+ "Long description\n\n"
32
+ "Causing people to indent:\n\n"
33
+ " A lot sometimes"
34
+ )
35
+ assert docstring.description == (
36
+ "Short description\n\n"
37
+ "Long description\n\n"
38
+ "Causing people to indent:\n\n"
39
+ " A lot sometimes"
40
+ )
41
+ assert len(docstring.params) == 3
42
+ assert docstring.params[0].arg_name == "spam"
43
+ assert docstring.params[0].type_name is None
44
+ assert docstring.params[0].description == "spam desc"
45
+ assert docstring.params[1].arg_name == "bla"
46
+ assert docstring.params[1].type_name == "int"
47
+ assert docstring.params[1].description == "bla desc"
48
+ assert docstring.params[2].arg_name == "yay"
49
+ assert docstring.params[2].type_name == "str"
50
+ assert docstring.params[2].description == ""
51
+ assert len(docstring.raises) == 1
52
+ assert docstring.raises[0].type_name == "ValueError"
53
+ assert docstring.raises[0].description == "exc desc"
54
+ assert docstring.returns is not None
55
+ assert docstring.returns.type_name == "tuple"
56
+ assert docstring.returns.description == "ret desc"
57
+ assert docstring.many_returns is not None
58
+ assert len(docstring.many_returns) == 1
59
+ assert docstring.many_returns[0] == docstring.returns
60
+
61
+
62
+ def test_google() -> None:
63
+ """Test Google-style parser autodetection."""
64
+ docstring = parse(
65
+ """Short description
66
+
67
+ Long description
68
+
69
+ Causing people to indent:
70
+
71
+ A lot sometimes
72
+
73
+ Args:
74
+ spam: spam desc
75
+ bla (int): bla desc
76
+ yay (str):
77
+
78
+ Raises:
79
+ ValueError: exc desc
80
+
81
+ Returns:
82
+ tuple: ret desc
83
+ """
84
+ )
85
+
86
+ assert docstring.style == DocstringStyle.GOOGLE
87
+ assert docstring.short_description == "Short description"
88
+ assert docstring.long_description == (
89
+ "Long description\n\n"
90
+ "Causing people to indent:\n\n"
91
+ " A lot sometimes"
92
+ )
93
+ assert docstring.description == (
94
+ "Short description\n\n"
95
+ "Long description\n\n"
96
+ "Causing people to indent:\n\n"
97
+ " A lot sometimes"
98
+ )
99
+ assert len(docstring.params) == 3
100
+ assert docstring.params[0].arg_name == "spam"
101
+ assert docstring.params[0].type_name is None
102
+ assert docstring.params[0].description == "spam desc"
103
+ assert docstring.params[1].arg_name == "bla"
104
+ assert docstring.params[1].type_name == "int"
105
+ assert docstring.params[1].description == "bla desc"
106
+ assert docstring.params[2].arg_name == "yay"
107
+ assert docstring.params[2].type_name == "str"
108
+ assert docstring.params[2].description == ""
109
+ assert len(docstring.raises) == 1
110
+ assert docstring.raises[0].type_name == "ValueError"
111
+ assert docstring.raises[0].description == "exc desc"
112
+ assert docstring.returns is not None
113
+ assert docstring.returns.type_name == "tuple"
114
+ assert docstring.returns.description == "ret desc"
115
+ assert docstring.many_returns is not None
116
+ assert len(docstring.many_returns) == 1
117
+ assert docstring.many_returns[0] == docstring.returns
118
+
119
+
120
+ def test_numpydoc() -> None:
121
+ """Test numpydoc-style parser autodetection."""
122
+ docstring = parse(
123
+ """Short description
124
+
125
+ Long description
126
+
127
+ Causing people to indent:
128
+
129
+ A lot sometimes
130
+
131
+ Parameters
132
+ ----------
133
+ spam
134
+ spam desc
135
+ bla : int
136
+ bla desc
137
+ yay : str
138
+
139
+ Raises
140
+ ------
141
+ ValueError
142
+ exc desc
143
+
144
+ Other Parameters
145
+ ----------------
146
+ this_guy : int, optional
147
+ you know him
148
+
149
+ Returns
150
+ -------
151
+ tuple
152
+ ret desc
153
+
154
+ See Also
155
+ --------
156
+ multiple lines...
157
+ something else?
158
+
159
+ Warnings
160
+ --------
161
+ multiple lines...
162
+ none of this is real!
163
+ """
164
+ )
165
+
166
+ assert docstring.style == DocstringStyle.NUMPYDOC
167
+ assert docstring.short_description == "Short description"
168
+ assert docstring.long_description == (
169
+ "Long description\n\n"
170
+ "Causing people to indent:\n\n"
171
+ " A lot sometimes"
172
+ )
173
+ assert docstring.description == (
174
+ "Short description\n\n"
175
+ "Long description\n\n"
176
+ "Causing people to indent:\n\n"
177
+ " A lot sometimes"
178
+ )
179
+ assert len(docstring.params) == 4
180
+ assert docstring.params[0].arg_name == "spam"
181
+ assert docstring.params[0].type_name is None
182
+ assert docstring.params[0].description == "spam desc"
183
+ assert docstring.params[1].arg_name == "bla"
184
+ assert docstring.params[1].type_name == "int"
185
+ assert docstring.params[1].description == "bla desc"
186
+ assert docstring.params[2].arg_name == "yay"
187
+ assert docstring.params[2].type_name == "str"
188
+ assert docstring.params[2].description is None
189
+ assert docstring.params[3].arg_name == "this_guy"
190
+ assert docstring.params[3].type_name == "int"
191
+ assert docstring.params[3].is_optional
192
+ assert docstring.params[3].description == "you know him"
193
+
194
+ assert len(docstring.raises) == 1
195
+ assert docstring.raises[0].type_name == "ValueError"
196
+ assert docstring.raises[0].description == "exc desc"
197
+ assert docstring.returns is not None
198
+ assert docstring.returns.type_name == "tuple"
199
+ assert docstring.returns.description == "ret desc"
200
+ assert docstring.many_returns is not None
201
+ assert len(docstring.many_returns) == 1
202
+ assert docstring.many_returns[0] == docstring.returns
203
+
204
+
205
+ def test_autodetection_error_detection() -> None:
206
+ """Test autodection for the case where one of the parsers throws an error
207
+ and another one succeeds.
208
+ """
209
+ source = """
210
+ Does something useless
211
+
212
+ :param 3 + 3 a: a param
213
+ """
214
+
215
+ with pytest.raises(ParseError):
216
+ # assert that one of the parsers does raise
217
+ parse(source, DocstringStyle.REST)
218
+
219
+ # assert that autodetection still works
220
+ docstring = parse(source)
221
+
222
+ assert docstring
223
+ assert docstring.style == DocstringStyle.GOOGLE
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_rest.py ADDED
@@ -0,0 +1,542 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for ReST-style docstring routines."""
2
+
3
+ import typing as T
4
+
5
+ import pytest
6
+ from docstring_parser.common import ParseError, RenderingStyle
7
+ from docstring_parser.rest import compose, parse
8
+
9
+
10
+ @pytest.mark.parametrize(
11
+ "source, expected",
12
+ [
13
+ ("", None),
14
+ ("\n", None),
15
+ ("Short description", "Short description"),
16
+ ("\nShort description\n", "Short description"),
17
+ ("\n Short description\n", "Short description"),
18
+ ],
19
+ )
20
+ def test_short_description(source: str, expected: str) -> None:
21
+ """Test parsing short description."""
22
+ docstring = parse(source)
23
+ assert docstring.short_description == expected
24
+ assert docstring.description == expected
25
+ assert docstring.long_description is None
26
+ assert not docstring.meta
27
+
28
+
29
+ @pytest.mark.parametrize(
30
+ "source, expected_short_desc, expected_long_desc, expected_blank",
31
+ [
32
+ (
33
+ "Short description\n\nLong description",
34
+ "Short description",
35
+ "Long description",
36
+ True,
37
+ ),
38
+ (
39
+ """
40
+ Short description
41
+
42
+ Long description
43
+ """,
44
+ "Short description",
45
+ "Long description",
46
+ True,
47
+ ),
48
+ (
49
+ """
50
+ Short description
51
+
52
+ Long description
53
+ Second line
54
+ """,
55
+ "Short description",
56
+ "Long description\nSecond line",
57
+ True,
58
+ ),
59
+ (
60
+ "Short description\nLong description",
61
+ "Short description",
62
+ "Long description",
63
+ False,
64
+ ),
65
+ (
66
+ """
67
+ Short description
68
+ Long description
69
+ """,
70
+ "Short description",
71
+ "Long description",
72
+ False,
73
+ ),
74
+ (
75
+ "\nShort description\nLong description\n",
76
+ "Short description",
77
+ "Long description",
78
+ False,
79
+ ),
80
+ (
81
+ """
82
+ Short description
83
+ Long description
84
+ Second line
85
+ """,
86
+ "Short description",
87
+ "Long description\nSecond line",
88
+ False,
89
+ ),
90
+ ],
91
+ )
92
+ def test_long_description(
93
+ source: str,
94
+ expected_short_desc: str,
95
+ expected_long_desc: str,
96
+ expected_blank: bool,
97
+ ) -> None:
98
+ """Test parsing long description."""
99
+ docstring = parse(source)
100
+ assert docstring.short_description == expected_short_desc
101
+ assert docstring.long_description == expected_long_desc
102
+ assert docstring.blank_after_short_description == expected_blank
103
+ assert not docstring.meta
104
+
105
+
106
+ @pytest.mark.parametrize(
107
+ "source, expected_short_desc, expected_long_desc, "
108
+ "expected_blank_short_desc, expected_blank_long_desc, "
109
+ "expected_full_desc",
110
+ [
111
+ (
112
+ """
113
+ Short description
114
+ :meta: asd
115
+ """,
116
+ "Short description",
117
+ None,
118
+ False,
119
+ False,
120
+ "Short description",
121
+ ),
122
+ (
123
+ """
124
+ Short description
125
+ Long description
126
+ :meta: asd
127
+ """,
128
+ "Short description",
129
+ "Long description",
130
+ False,
131
+ False,
132
+ "Short description\nLong description",
133
+ ),
134
+ (
135
+ """
136
+ Short description
137
+ First line
138
+ Second line
139
+ :meta: asd
140
+ """,
141
+ "Short description",
142
+ "First line\n Second line",
143
+ False,
144
+ False,
145
+ "Short description\nFirst line\n Second line",
146
+ ),
147
+ (
148
+ """
149
+ Short description
150
+
151
+ First line
152
+ Second line
153
+ :meta: asd
154
+ """,
155
+ "Short description",
156
+ "First line\n Second line",
157
+ True,
158
+ False,
159
+ "Short description\n\nFirst line\n Second line",
160
+ ),
161
+ (
162
+ """
163
+ Short description
164
+
165
+ First line
166
+ Second line
167
+
168
+ :meta: asd
169
+ """,
170
+ "Short description",
171
+ "First line\n Second line",
172
+ True,
173
+ True,
174
+ "Short description\n\nFirst line\n Second line",
175
+ ),
176
+ (
177
+ """
178
+ :meta: asd
179
+ """,
180
+ None,
181
+ None,
182
+ False,
183
+ False,
184
+ None,
185
+ ),
186
+ ],
187
+ )
188
+ def test_meta_newlines(
189
+ source: str,
190
+ expected_short_desc: T.Optional[str],
191
+ expected_long_desc: T.Optional[str],
192
+ expected_blank_short_desc: bool,
193
+ expected_blank_long_desc: bool,
194
+ expected_full_desc: T.Optional[str],
195
+ ) -> None:
196
+ """Test parsing newlines around description sections."""
197
+ docstring = parse(source)
198
+ assert docstring.short_description == expected_short_desc
199
+ assert docstring.long_description == expected_long_desc
200
+ assert docstring.blank_after_short_description == expected_blank_short_desc
201
+ assert docstring.blank_after_long_description == expected_blank_long_desc
202
+ assert docstring.description == expected_full_desc
203
+ assert len(docstring.meta) == 1
204
+
205
+
206
+ def test_meta_with_multiline_description() -> None:
207
+ """Test parsing multiline meta documentation."""
208
+ docstring = parse(
209
+ """
210
+ Short description
211
+
212
+ :meta: asd
213
+ 1
214
+ 2
215
+ 3
216
+ """
217
+ )
218
+ assert docstring.short_description == "Short description"
219
+ assert len(docstring.meta) == 1
220
+ assert docstring.meta[0].args == ["meta"]
221
+ assert docstring.meta[0].description == "asd\n1\n 2\n3"
222
+
223
+
224
+ def test_multiple_meta() -> None:
225
+ """Test parsing multiple meta."""
226
+ docstring = parse(
227
+ """
228
+ Short description
229
+
230
+ :meta1: asd
231
+ 1
232
+ 2
233
+ 3
234
+ :meta2: herp
235
+ :meta3: derp
236
+ """
237
+ )
238
+ assert docstring.short_description == "Short description"
239
+ assert len(docstring.meta) == 3
240
+ assert docstring.meta[0].args == ["meta1"]
241
+ assert docstring.meta[0].description == "asd\n1\n 2\n3"
242
+ assert docstring.meta[1].args == ["meta2"]
243
+ assert docstring.meta[1].description == "herp"
244
+ assert docstring.meta[2].args == ["meta3"]
245
+ assert docstring.meta[2].description == "derp"
246
+
247
+
248
+ def test_meta_with_args() -> None:
249
+ """Test parsing meta with additional arguments."""
250
+ docstring = parse(
251
+ """
252
+ Short description
253
+
254
+ :meta ene due rabe: asd
255
+ """
256
+ )
257
+ assert docstring.short_description == "Short description"
258
+ assert len(docstring.meta) == 1
259
+ assert docstring.meta[0].args == ["meta", "ene", "due", "rabe"]
260
+ assert docstring.meta[0].description == "asd"
261
+
262
+
263
+ def test_params() -> None:
264
+ """Test parsing params."""
265
+ docstring = parse("Short description")
266
+ assert len(docstring.params) == 0
267
+
268
+ docstring = parse(
269
+ """
270
+ Short description
271
+
272
+ :param name: description 1
273
+ :param int priority: description 2
274
+ :param str? sender: description 3
275
+ :param str? message: description 4, defaults to 'hello'
276
+ :param str? multiline: long description 5,
277
+ defaults to 'bye'
278
+ """
279
+ )
280
+ assert len(docstring.params) == 5
281
+ assert docstring.params[0].arg_name == "name"
282
+ assert docstring.params[0].type_name is None
283
+ assert docstring.params[0].description == "description 1"
284
+ assert docstring.params[0].default is None
285
+ assert not docstring.params[0].is_optional
286
+ assert docstring.params[1].arg_name == "priority"
287
+ assert docstring.params[1].type_name == "int"
288
+ assert docstring.params[1].description == "description 2"
289
+ assert not docstring.params[1].is_optional
290
+ assert docstring.params[1].default is None
291
+ assert docstring.params[2].arg_name == "sender"
292
+ assert docstring.params[2].type_name == "str"
293
+ assert docstring.params[2].description == "description 3"
294
+ assert docstring.params[2].is_optional
295
+ assert docstring.params[2].default is None
296
+ assert docstring.params[3].arg_name == "message"
297
+ assert docstring.params[3].type_name == "str"
298
+ assert (
299
+ docstring.params[3].description == "description 4, defaults to 'hello'"
300
+ )
301
+ assert docstring.params[3].is_optional
302
+ assert docstring.params[3].default == "'hello'"
303
+ assert docstring.params[4].arg_name == "multiline"
304
+ assert docstring.params[4].type_name == "str"
305
+ assert (
306
+ docstring.params[4].description
307
+ == "long description 5,\ndefaults to 'bye'"
308
+ )
309
+ assert docstring.params[4].is_optional
310
+ assert docstring.params[4].default == "'bye'"
311
+
312
+ docstring = parse(
313
+ """
314
+ Short description
315
+
316
+ :param a: description a
317
+ :type a: int
318
+ :param int b: description b
319
+ """
320
+ )
321
+ assert len(docstring.params) == 2
322
+ assert docstring.params[0].arg_name == "a"
323
+ assert docstring.params[0].type_name == "int"
324
+ assert docstring.params[0].description == "description a"
325
+ assert docstring.params[0].default is None
326
+ assert not docstring.params[0].is_optional
327
+
328
+
329
+ def test_returns() -> None:
330
+ """Test parsing returns."""
331
+ docstring = parse(
332
+ """
333
+ Short description
334
+ """
335
+ )
336
+ assert docstring.returns is None
337
+ assert docstring.many_returns is not None
338
+ assert len(docstring.many_returns) == 0
339
+
340
+ docstring = parse(
341
+ """
342
+ Short description
343
+ :returns: description
344
+ """
345
+ )
346
+ assert docstring.returns is not None
347
+ assert docstring.returns.type_name is None
348
+ assert docstring.returns.description == "description"
349
+ assert not docstring.returns.is_generator
350
+ assert docstring.many_returns == [docstring.returns]
351
+
352
+ docstring = parse(
353
+ """
354
+ Short description
355
+ :returns int: description
356
+ """
357
+ )
358
+ assert docstring.returns is not None
359
+ assert docstring.returns.type_name == "int"
360
+ assert docstring.returns.description == "description"
361
+ assert not docstring.returns.is_generator
362
+ assert docstring.many_returns == [docstring.returns]
363
+
364
+ docstring = parse(
365
+ """
366
+ Short description
367
+ :returns: description
368
+ :rtype: int
369
+ """
370
+ )
371
+ assert docstring.returns is not None
372
+ assert docstring.returns.type_name == "int"
373
+ assert docstring.returns.description == "description"
374
+ assert not docstring.returns.is_generator
375
+ assert docstring.many_returns == [docstring.returns]
376
+
377
+
378
+ def test_yields() -> None:
379
+ """Test parsing yields."""
380
+ docstring = parse(
381
+ """
382
+ Short description
383
+ """
384
+ )
385
+ assert docstring.returns is None
386
+ assert docstring.many_returns is not None
387
+ assert len(docstring.many_returns) == 0
388
+
389
+ docstring = parse(
390
+ """
391
+ Short description
392
+ :yields: description
393
+ """
394
+ )
395
+ assert docstring.returns is not None
396
+ assert docstring.returns.type_name is None
397
+ assert docstring.returns.description == "description"
398
+ assert docstring.returns.is_generator
399
+ assert docstring.many_returns is not None
400
+ assert len(docstring.many_returns) == 1
401
+ assert docstring.many_returns[0] == docstring.returns
402
+
403
+ docstring = parse(
404
+ """
405
+ Short description
406
+ :yields int: description
407
+ """
408
+ )
409
+ assert docstring.returns is not None
410
+ assert docstring.returns.type_name == "int"
411
+ assert docstring.returns.description == "description"
412
+ assert docstring.returns.is_generator
413
+ assert docstring.many_returns is not None
414
+ assert len(docstring.many_returns) == 1
415
+ assert docstring.many_returns[0] == docstring.returns
416
+
417
+
418
+ def test_raises() -> None:
419
+ """Test parsing raises."""
420
+ docstring = parse(
421
+ """
422
+ Short description
423
+ """
424
+ )
425
+ assert len(docstring.raises) == 0
426
+
427
+ docstring = parse(
428
+ """
429
+ Short description
430
+ :raises: description
431
+ """
432
+ )
433
+ assert len(docstring.raises) == 1
434
+ assert docstring.raises[0].type_name is None
435
+ assert docstring.raises[0].description == "description"
436
+
437
+ docstring = parse(
438
+ """
439
+ Short description
440
+ :raises ValueError: description
441
+ """
442
+ )
443
+ assert len(docstring.raises) == 1
444
+ assert docstring.raises[0].type_name == "ValueError"
445
+ assert docstring.raises[0].description == "description"
446
+
447
+
448
+ def test_broken_meta() -> None:
449
+ """Test parsing broken meta."""
450
+ with pytest.raises(ParseError):
451
+ parse(":")
452
+
453
+ with pytest.raises(ParseError):
454
+ parse(":param herp derp")
455
+
456
+ with pytest.raises(ParseError):
457
+ parse(":param: invalid")
458
+
459
+ with pytest.raises(ParseError):
460
+ parse(":param with too many args: desc")
461
+
462
+ # these should not raise any errors
463
+ parse(":sthstrange: desc")
464
+
465
+
466
+ def test_deprecation() -> None:
467
+ """Test parsing deprecation notes."""
468
+ docstring = parse(":deprecation: 1.1.0 this function will be removed")
469
+ assert docstring.deprecation is not None
470
+ assert docstring.deprecation.version == "1.1.0"
471
+ assert docstring.deprecation.description == "this function will be removed"
472
+
473
+ docstring = parse(":deprecation: this function will be removed")
474
+ assert docstring.deprecation is not None
475
+ assert docstring.deprecation.version is None
476
+ assert docstring.deprecation.description == "this function will be removed"
477
+
478
+
479
+ @pytest.mark.parametrize(
480
+ "rendering_style, expected",
481
+ [
482
+ (
483
+ RenderingStyle.COMPACT,
484
+ "Short description.\n"
485
+ "\n"
486
+ "Long description.\n"
487
+ "\n"
488
+ ":param int foo: a description\n"
489
+ ":param int bar: another description\n"
490
+ ":returns float: a return",
491
+ ),
492
+ (
493
+ RenderingStyle.CLEAN,
494
+ "Short description.\n"
495
+ "\n"
496
+ "Long description.\n"
497
+ "\n"
498
+ ":param int foo: a description\n"
499
+ ":param int bar: another description\n"
500
+ ":returns float: a return",
501
+ ),
502
+ (
503
+ RenderingStyle.EXPANDED,
504
+ "Short description.\n"
505
+ "\n"
506
+ "Long description.\n"
507
+ "\n"
508
+ ":param foo:\n"
509
+ " a description\n"
510
+ ":type foo: int\n"
511
+ ":param bar:\n"
512
+ " another description\n"
513
+ ":type bar: int\n"
514
+ ":returns:\n"
515
+ " a return\n"
516
+ ":rtype: float",
517
+ ),
518
+ ],
519
+ )
520
+ def test_compose(rendering_style: RenderingStyle, expected: str) -> None:
521
+ """Test compose"""
522
+
523
+ docstring = parse(
524
+ """
525
+ Short description.
526
+
527
+ Long description.
528
+
529
+ :param int foo: a description
530
+ :param int bar: another description
531
+ :return float: a return
532
+ """
533
+ )
534
+ assert compose(docstring, rendering_style=rendering_style) == expected
535
+
536
+
537
+ def test_short_rtype() -> None:
538
+ """Test abbreviated docstring with only return type information."""
539
+ string = "Short description.\n\n:rtype: float"
540
+ docstring = parse(string)
541
+ rendering_style = RenderingStyle.EXPANDED
542
+ assert compose(docstring, rendering_style=rendering_style) == string
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/docstring_parser/tests/test_util.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Test for utility functions."""
2
+
3
+ from docstring_parser.common import DocstringReturns
4
+ from docstring_parser.util import combine_docstrings
5
+
6
+
7
+ def test_combine_docstrings() -> None:
8
+ """Test combine_docstrings wrapper."""
9
+
10
+ def fun1(arg_a, arg_b, arg_c, arg_d):
11
+ """short_description: fun1
12
+
13
+ :param arg_a: fun1
14
+ :param arg_b: fun1
15
+ :return: fun1
16
+ """
17
+ assert arg_a and arg_b and arg_c and arg_d
18
+
19
+ def fun2(arg_b, arg_c, arg_d, arg_e):
20
+ """short_description: fun2
21
+
22
+ long_description: fun2
23
+
24
+ :param arg_b: fun2
25
+ :param arg_c: fun2
26
+ :param arg_e: fun2
27
+ """
28
+ assert arg_b and arg_c and arg_d and arg_e
29
+
30
+ @combine_docstrings(fun1, fun2)
31
+ def decorated1(arg_a, arg_b, arg_c, arg_d, arg_e, arg_f):
32
+ """
33
+ :param arg_e: decorated
34
+ :param arg_f: decorated
35
+ """
36
+ assert arg_a and arg_b and arg_c and arg_d and arg_e and arg_f
37
+
38
+ assert decorated1.__doc__ == (
39
+ "short_description: fun2\n"
40
+ "\n"
41
+ "long_description: fun2\n"
42
+ "\n"
43
+ ":param arg_a: fun1\n"
44
+ ":param arg_b: fun1\n"
45
+ ":param arg_c: fun2\n"
46
+ ":param arg_e: fun2\n"
47
+ ":param arg_f: decorated\n"
48
+ ":returns: fun1"
49
+ )
50
+
51
+ @combine_docstrings(fun1, fun2, exclude=[DocstringReturns])
52
+ def decorated2(arg_a, arg_b, arg_c, arg_d, arg_e, arg_f):
53
+ assert arg_a and arg_b and arg_c and arg_d and arg_e and arg_f
54
+
55
+ assert decorated2.__doc__ == (
56
+ "short_description: fun2\n"
57
+ "\n"
58
+ "long_description: fun2\n"
59
+ "\n"
60
+ ":param arg_a: fun1\n"
61
+ ":param arg_b: fun1\n"
62
+ ":param arg_c: fun2\n"
63
+ ":param arg_e: fun2"
64
+ )
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (5.01 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/__main__.cpython-311.pyc ADDED
Binary file (5.5 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/_options.cpython-311.pyc ADDED
Binary file (18.5 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/appsettings.cpython-311.pyc ADDED
Binary file (7.29 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/audit.cpython-311.pyc ADDED
Binary file (30.2 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/bbox.cpython-311.pyc ADDED
Binary file (7.23 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/blkrefs.cpython-311.pyc ADDED
Binary file (11.1 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/colors.cpython-311.pyc ADDED
Binary file (15.9 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/commands.cpython-311.pyc ADDED
Binary file (48.5 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/comments.cpython-311.pyc ADDED
Binary file (2.71 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/disassemble.cpython-311.pyc ADDED
Binary file (32 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/document.cpython-311.pyc ADDED
Binary file (78.2 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/dwginfo.cpython-311.pyc ADDED
Binary file (1.98 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/dynblkhelper.cpython-311.pyc ADDED
Binary file (3.04 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/edgeminer.cpython-311.pyc ADDED
Binary file (64.2 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/edgesmith.cpython-311.pyc ADDED
Binary file (55 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/entitydb.cpython-311.pyc ADDED
Binary file (23.8 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/enums.cpython-311.pyc ADDED
Binary file (11.4 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/explode.cpython-311.pyc ADDED
Binary file (18.3 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/eztypes.cpython-311.pyc ADDED
Binary file (2.3 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/filemanagement.cpython-311.pyc ADDED
Binary file (12.2 kB). View file
 
data/miniconda3/envs/catiagent/lib/python3.11/site-packages/ezdxf/__pycache__/gfxattribs.cpython-311.pyc ADDED
Binary file (16.6 kB). View file