| 1 | """Pytest fixture for docstrings tests.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from typing import TYPE_CHECKING |
| 6 | |
| 7 | import pytest |
| 8 | |
| 9 | from griffe._internal.docstrings import google, numpy, sphinx |
| 10 | from tests.test_docstrings.helpers import ParserType, parser |
| 11 | |
| 12 | if TYPE_CHECKING: |
| 13 | from collections.abc import Iterator |
| 14 | |
| 15 | |
| 16 | @pytest.fixture |
| 17 | def parse_google() -> Iterator[ParserType]: |
| 18 | """Yield a function to parse Google docstrings. |
| 19 | |
| 20 | Yields: |
| 21 | A parser function. |
| 22 | """ |
| 23 | yield from parser(google) |
| 24 | |
| 25 | |
| 26 | @pytest.fixture |
| 27 | def parse_numpy() -> Iterator[ParserType]: |
| 28 | """Yield a function to parse Numpy docstrings. |
| 29 | |
| 30 | Yields: |
| 31 | A parser function. |
| 32 | """ |
| 33 | yield from parser(numpy) |
| 34 | |
| 35 | |
| 36 | @pytest.fixture |
| 37 | def parse_sphinx() -> Iterator[ParserType]: |
| 38 | """Yield a function to parse Sphinx docstrings. |
| 39 | |
| 40 | Yields: |
| 41 | A parser function. |
| 42 | """ |
| 43 | yield from parser(sphinx) |