| 1 | """Tests for the docstrings utility functions.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from griffe import Docstring, Function, Parameter, ParameterKind, Parameters, Parser, parse |
| 6 | |
| 7 | |
| 8 | def test_can_warn_without_parent_module() -> None: |
| 9 | """Assert we can parse a docstring even if it does not have a parent module.""" |
| 10 | function = Function( |
| 11 | "func", |
| 12 | parameters=Parameters( |
| 13 | Parameter("param1", annotation=None, kind=ParameterKind.positional_or_keyword), |
| 14 | Parameter("param2", annotation="int", kind=ParameterKind.keyword_only), |
| 15 | ), |
| 16 | ) |
| 17 | text = """ |
| 18 | Hello I'm a docstring! |
| 19 | |
| 20 | Parameters: |
| 21 | param1: Description. |
| 22 | param2: Description. |
| 23 | """ |
| 24 | docstring = Docstring(text, lineno=1, parent=function) |
| 25 | assert parse(docstring, Parser.google) |