Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/dev/plotting.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interactive session. The recommended way to achieve that is illustrated in the
example below.

```python
from typing import Any, List
import matplotlib.pyplot as plt

class Foo:
Expand Down
19 changes: 11 additions & 8 deletions docs/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@
"""
import inspect
import sys
from typing import Any, Dict, List, Pattern, Tuple
from typing import Any, Dict, List, Pattern, Tuple, Iterator

import os
import pathlib
import re

import pytest
Expand All @@ -74,17 +75,19 @@ def test_can_run_readme_code_snippets():
assert_file_has_working_code_snippets(readme_path, assume_import=False)


def find_docs_code_snippets_paths():
docs_folder = os.path.dirname(__file__)
for filename in os.listdir(docs_folder):
if not filename.endswith('.md') and not filename.endswith('.rst'):
continue
yield os.path.join(docs_folder, filename)
def find_docs_code_snippets_paths() -> Iterator[str]:
docs_folder = pathlib.Path(__file__).parent
for filename in docs_folder.rglob('*.md'):
yield str(filename.relative_to(docs_folder))
for filename in docs_folder.rglob('*.rst'):
yield str(filename.relative_to(docs_folder))


@pytest.mark.parametrize('path', find_docs_code_snippets_paths())
def test_can_run_docs_code_snippets(path):
assert_file_has_working_code_snippets(path, assume_import=True)
docs_folder = os.path.dirname(__file__)
assert_file_has_working_code_snippets(os.path.join(docs_folder, path),
assume_import=True)


def find_code_snippets(pattern: str, content: str) -> List[Tuple[str, int]]:
Expand Down