From 71b98fce22428473f67be4da72714a567f2fba7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Wed, 22 May 2024 16:33:57 +0200 Subject: [PATCH] wip --- ...7227330dbe89cad07bf5a88adca34dc4708bc.html | 374 ++++++++++++++++++ ...8a1d27e680374bc9a6ff3ce13c7bb27b2615d.html | 374 ++++++++++++++++++ ...a62cc75eb8bf7cf2675e6c89d895c49b9013d.html | 119 ++++++ ...2f072ac1ccbe97302b8014f6949e57ef0fd6d.html | 106 +++++ ...8bcff756b3b63779d86765368659525cfd045.html | 217 ++++++++++ ...fbc33490f8449db9d237cd8ab36ccf5f1f193.html | 217 ++++++++++ ...930b930c4df4a16b90e7963ecccd6f9160804.html | 119 ++++++ ...213f2018eb3e7f4799ad5cd99282b1b5de3d8.html | 8 + ...abe393886ec78bc66a478070ac9ee1eb94970.html | 217 ++++++++++ ...9230c808d939e79b77a142714d1a829fa8367.html | 106 +++++ duties.py | 2 +- tests/helpers.py | 93 +++++ tests/test_end_to_end.py | 14 +- time.txt | 18 + 14 files changed, 1982 insertions(+), 2 deletions(-) create mode 100644 config/.inline-snapshot/external/11cb9d233b07fb01b12a65afe3b7227330dbe89cad07bf5a88adca34dc4708bc.html create mode 100644 config/.inline-snapshot/external/1747398b77eabbad03f39c6cb108a1d27e680374bc9a6ff3ce13c7bb27b2615d.html create mode 100644 config/.inline-snapshot/external/2f61cc6f1d8f4eaaf7fdfca64dfa62cc75eb8bf7cf2675e6c89d895c49b9013d.html create mode 100644 config/.inline-snapshot/external/382504aaea00bcf0e05acfce8042f072ac1ccbe97302b8014f6949e57ef0fd6d.html create mode 100644 config/.inline-snapshot/external/413ea42ad86a9ede5245770d2938bcff756b3b63779d86765368659525cfd045.html create mode 100644 config/.inline-snapshot/external/4fa3ca1069c51fa4231a7dcc582fbc33490f8449db9d237cd8ab36ccf5f1f193.html create mode 100644 config/.inline-snapshot/external/63f54a7252bf222dae95adc40a8930b930c4df4a16b90e7963ecccd6f9160804.html create mode 100644 config/.inline-snapshot/external/988c916673a8dca64f4b152ca0c213f2018eb3e7f4799ad5cd99282b1b5de3d8.html create mode 100644 config/.inline-snapshot/external/b107f3837b916c1629bf712e9c0abe393886ec78bc66a478070ac9ee1eb94970.html create mode 100644 config/.inline-snapshot/external/d9a1ebc1cc86e0d0cebbc72ab979230c808d939e79b77a142714d1a829fa8367.html create mode 100644 tests/helpers.py create mode 100644 time.txt diff --git a/config/.inline-snapshot/external/11cb9d233b07fb01b12a65afe3b7227330dbe89cad07bf5a88adca34dc4708bc.html b/config/.inline-snapshot/external/11cb9d233b07fb01b12a65afe3b7227330dbe89cad07bf5a88adca34dc4708bc.html new file mode 100644 index 00000000..290d9cb8 --- /dev/null +++ b/config/.inline-snapshot/external/11cb9d233b07fb01b12a65afe3b7227330dbe89cad07bf5a88adca34dc4708bc.html @@ -0,0 +1,374 @@ +
+ + +
+
+
+

+ + + foo + + + ( + + + a + + + , + + + b + + + ) + + +

+
+

+ Docstring for + + foo + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
2
+3
+
+
+
+
def foo(a: int, b: str) -> None:
+    '''Docstring for `foo`.'''
+
+
+
+
+
+
+
+
+

+ + Bar + +

+
+

+ Docstring for + + Bar + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+
+
+
+
class Bar:
+    '''Docstring for `Bar`.'''
+
+    def __init__(self, a: int, b: str) -> None:
+        '''Docstring for `Bar.__init__`.'''
+        self.c = a + b
+        '''Docstring for `Bar.c`.'''
+
+    def foo(self, a: int, b: str) -> None:
+        '''Docstring.'''
+
+
+
+
+
+
+
+

+ + + __init__ + + + ( + + + a + + + , + + + b + + + ) + + +

+
+

+ Docstring for + + Bar.__init__ + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
 8
+ 9
+10
+11
+
+
+
+
def __init__(self, a: int, b: str) -> None:
+    '''Docstring for `Bar.__init__`.'''
+    self.c = a + b
+    '''Docstring for `Bar.c`.'''
+
+
+
+
+
+
+
+
+

+ + + c + + + = + + + a + + + + + + + b + + + + + + instance-attribute + + + +

+
+

+ Docstring for + + Bar.c + + . +

+
+
+
+

+ + + foo + + + ( + + + a + + + , + + + b + + + ) + + +

+
+

+ Docstring. +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
13
+14
+
+
+
+
def foo(self, a: int, b: str) -> None:
+    '''Docstring.'''
+
+
+
+
+
+
+
+
+
+
+
+

+ + + baz + + + : + + + int + + + = + + + 42 + + + + + + module-attribute + + + +

+
+

+ Docstring for + + baz + + . +

+
+
+
+

+ + Qux + +

+
+

+ Bases: + + + Bar + + +

+

+ Docstring for + + Qux + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
19
+20
+
+
+
+
class Qux(Bar):
+    '''Docstring for `Qux`.'''
+
+
+
+
+
+
+
+
+
+
diff --git a/config/.inline-snapshot/external/1747398b77eabbad03f39c6cb108a1d27e680374bc9a6ff3ce13c7bb27b2615d.html b/config/.inline-snapshot/external/1747398b77eabbad03f39c6cb108a1d27e680374bc9a6ff3ce13c7bb27b2615d.html new file mode 100644 index 00000000..5ee24501 --- /dev/null +++ b/config/.inline-snapshot/external/1747398b77eabbad03f39c6cb108a1d27e680374bc9a6ff3ce13c7bb27b2615d.html @@ -0,0 +1,374 @@ +
+ + +
+
+
+

+ + Bar + +

+
+

+ Docstring for + + Bar + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+
+
+
+
class Bar:
+    '''Docstring for `Bar`.'''
+
+    def __init__(self, a: int, b: str) -> None:
+        '''Docstring for `Bar.__init__`.'''
+        self.c = a + b
+        '''Docstring for `Bar.c`.'''
+
+    def foo(self, a: int, b: str) -> None:
+        '''Docstring.'''
+
+
+
+
+
+
+
+

+ + + __init__ + + + ( + + + a + + + , + + + b + + + ) + + +

+
+

+ Docstring for + + Bar.__init__ + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
 8
+ 9
+10
+11
+
+
+
+
def __init__(self, a: int, b: str) -> None:
+    '''Docstring for `Bar.__init__`.'''
+    self.c = a + b
+    '''Docstring for `Bar.c`.'''
+
+
+
+
+
+
+
+
+

+ + + c + + + = + + + a + + + + + + + b + + + + + + instance-attribute + + + +

+
+

+ Docstring for + + Bar.c + + . +

+
+
+
+

+ + + foo + + + ( + + + a + + + , + + + b + + + ) + + +

+
+

+ Docstring. +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
13
+14
+
+
+
+
def foo(self, a: int, b: str) -> None:
+    '''Docstring.'''
+
+
+
+
+
+
+
+
+
+
+
+

+ + Qux + +

+
+

+ Bases: + + + Bar + + +

+

+ Docstring for + + Qux + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
19
+20
+
+
+
+
class Qux(Bar):
+    '''Docstring for `Qux`.'''
+
+
+
+
+
+
+
+
+

+ + + baz + + + : + + + int + + + = + + + 42 + + + + + + module-attribute + + + +

+
+

+ Docstring for + + baz + + . +

+
+
+
+

+ + + foo + + + ( + + + a + + + , + + + b + + + ) + + +

+
+

+ Docstring for + + foo + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
2
+3
+
+
+
+
def foo(a: int, b: str) -> None:
+    '''Docstring for `foo`.'''
+
+
+
+
+
+
+
+
+
+
diff --git a/config/.inline-snapshot/external/2f61cc6f1d8f4eaaf7fdfca64dfa62cc75eb8bf7cf2675e6c89d895c49b9013d.html b/config/.inline-snapshot/external/2f61cc6f1d8f4eaaf7fdfca64dfa62cc75eb8bf7cf2675e6c89d895c49b9013d.html new file mode 100644 index 00000000..e4bd668d --- /dev/null +++ b/config/.inline-snapshot/external/2f61cc6f1d8f4eaaf7fdfca64dfa62cc75eb8bf7cf2675e6c89d895c49b9013d.html @@ -0,0 +1,119 @@ +
+ + +
+
+
+

+ + Qux + +

+
+

+ Bases: + + + Bar + + +

+

+ Docstring for + + Qux + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
19
+20
+
+
+
+
class Qux(Bar):
+    '''Docstring for `Qux`.'''
+
+
+
+
+
+
+
+
+

+ + + foo + + + ( + + + a + + + , + + + b + + + ) + + +

+
+

+ Docstring for + + foo + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
2
+3
+
+
+
+
def foo(a: int, b: str) -> None:
+    '''Docstring for `foo`.'''
+
+
+
+
+
+
+
+
+
+
diff --git a/config/.inline-snapshot/external/382504aaea00bcf0e05acfce8042f072ac1ccbe97302b8014f6949e57ef0fd6d.html b/config/.inline-snapshot/external/382504aaea00bcf0e05acfce8042f072ac1ccbe97302b8014f6949e57ef0fd6d.html new file mode 100644 index 00000000..d0c958c3 --- /dev/null +++ b/config/.inline-snapshot/external/382504aaea00bcf0e05acfce8042f072ac1ccbe97302b8014f6949e57ef0fd6d.html @@ -0,0 +1,106 @@ +
+ + +
+
+
+

+ + Bar + +

+
+

+ Docstring for + + Bar + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+
+
+
+
class Bar:
+    '''Docstring for `Bar`.'''
+
+    def __init__(self, a: int, b: str) -> None:
+        '''Docstring for `Bar.__init__`.'''
+        self.c = a + b
+        '''Docstring for `Bar.c`.'''
+
+    def foo(self, a: int, b: str) -> None:
+        '''Docstring.'''
+
+
+
+
+
+
+
+
+
+
+

+ + + baz + + + : + + + int + + + = + + + 42 + + + + + + module-attribute + + + +

+
+

+ Docstring for + + baz + + . +

+
+
+
+
+
diff --git a/config/.inline-snapshot/external/413ea42ad86a9ede5245770d2938bcff756b3b63779d86765368659525cfd045.html b/config/.inline-snapshot/external/413ea42ad86a9ede5245770d2938bcff756b3b63779d86765368659525cfd045.html new file mode 100644 index 00000000..22ae2bb3 --- /dev/null +++ b/config/.inline-snapshot/external/413ea42ad86a9ede5245770d2938bcff756b3b63779d86765368659525cfd045.html @@ -0,0 +1,217 @@ +
+ + +
+
+
+

+ + + foo + + + ( + + + a + + + , + + + b + + + ) + + +

+
+

+ Docstring for + + foo + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
2
+3
+
+
+
+
def foo(a: int, b: str) -> None:
+    '''Docstring for `foo`.'''
+
+
+
+
+
+
+
+
+

+ + Bar + +

+
+

+ Docstring for + + Bar + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+
+
+
+
class Bar:
+    '''Docstring for `Bar`.'''
+
+    def __init__(self, a: int, b: str) -> None:
+        '''Docstring for `Bar.__init__`.'''
+        self.c = a + b
+        '''Docstring for `Bar.c`.'''
+
+    def foo(self, a: int, b: str) -> None:
+        '''Docstring.'''
+
+
+
+
+
+
+
+
+
+
+

+ + + baz + + + : + + + int + + + = + + + 42 + + + + + + module-attribute + + + +

+
+

+ Docstring for + + baz + + . +

+
+
+
+

+ + Qux + +

+
+

+ Bases: + + + Bar + + +

+

+ Docstring for + + Qux + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
19
+20
+
+
+
+
class Qux(Bar):
+    '''Docstring for `Qux`.'''
+
+
+
+
+
+
+
+
+
+
diff --git a/config/.inline-snapshot/external/4fa3ca1069c51fa4231a7dcc582fbc33490f8449db9d237cd8ab36ccf5f1f193.html b/config/.inline-snapshot/external/4fa3ca1069c51fa4231a7dcc582fbc33490f8449db9d237cd8ab36ccf5f1f193.html new file mode 100644 index 00000000..aa7de224 --- /dev/null +++ b/config/.inline-snapshot/external/4fa3ca1069c51fa4231a7dcc582fbc33490f8449db9d237cd8ab36ccf5f1f193.html @@ -0,0 +1,217 @@ +
+ + +
+
+
+

+ + Bar + +

+
+

+ Docstring for + + Bar + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+
+
+
+
class Bar:
+    '''Docstring for `Bar`.'''
+
+    def __init__(self, a: int, b: str) -> None:
+        '''Docstring for `Bar.__init__`.'''
+        self.c = a + b
+        '''Docstring for `Bar.c`.'''
+
+    def foo(self, a: int, b: str) -> None:
+        '''Docstring.'''
+
+
+
+
+
+
+
+
+
+
+

+ + Qux + +

+
+

+ Bases: + + + Bar + + +

+

+ Docstring for + + Qux + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
19
+20
+
+
+
+
class Qux(Bar):
+    '''Docstring for `Qux`.'''
+
+
+
+
+
+
+
+
+

+ + + baz + + + : + + + int + + + = + + + 42 + + + + + + module-attribute + + + +

+
+

+ Docstring for + + baz + + . +

+
+
+
+

+ + + foo + + + ( + + + a + + + , + + + b + + + ) + + +

+
+

+ Docstring for + + foo + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
2
+3
+
+
+
+
def foo(a: int, b: str) -> None:
+    '''Docstring for `foo`.'''
+
+
+
+
+
+
+
+
+
+
diff --git a/config/.inline-snapshot/external/63f54a7252bf222dae95adc40a8930b930c4df4a16b90e7963ecccd6f9160804.html b/config/.inline-snapshot/external/63f54a7252bf222dae95adc40a8930b930c4df4a16b90e7963ecccd6f9160804.html new file mode 100644 index 00000000..19d06243 --- /dev/null +++ b/config/.inline-snapshot/external/63f54a7252bf222dae95adc40a8930b930c4df4a16b90e7963ecccd6f9160804.html @@ -0,0 +1,119 @@ +
+ + +
+
+
+

+ + + foo + + + ( + + + a + + + , + + + b + + + ) + + +

+
+

+ Docstring for + + foo + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
2
+3
+
+
+
+
def foo(a: int, b: str) -> None:
+    '''Docstring for `foo`.'''
+
+
+
+
+
+
+
+
+

+ + Qux + +

+
+

+ Bases: + + + Bar + + +

+

+ Docstring for + + Qux + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
19
+20
+
+
+
+
class Qux(Bar):
+    '''Docstring for `Qux`.'''
+
+
+
+
+
+
+
+
+
+
diff --git a/config/.inline-snapshot/external/988c916673a8dca64f4b152ca0c213f2018eb3e7f4799ad5cd99282b1b5de3d8.html b/config/.inline-snapshot/external/988c916673a8dca64f4b152ca0c213f2018eb3e7f4799ad5cd99282b1b5de3d8.html new file mode 100644 index 00000000..070e59df --- /dev/null +++ b/config/.inline-snapshot/external/988c916673a8dca64f4b152ca0c213f2018eb3e7f4799ad5cd99282b1b5de3d8.html @@ -0,0 +1,8 @@ +
+ + +
+
+
+
+
diff --git a/config/.inline-snapshot/external/b107f3837b916c1629bf712e9c0abe393886ec78bc66a478070ac9ee1eb94970.html b/config/.inline-snapshot/external/b107f3837b916c1629bf712e9c0abe393886ec78bc66a478070ac9ee1eb94970.html new file mode 100644 index 00000000..a1da3da8 --- /dev/null +++ b/config/.inline-snapshot/external/b107f3837b916c1629bf712e9c0abe393886ec78bc66a478070ac9ee1eb94970.html @@ -0,0 +1,217 @@ +
+ + +
+
+
+

+ + + baz + + + : + + + int + + + = + + + 42 + + + + + + module-attribute + + + +

+
+

+ Docstring for + + baz + + . +

+
+
+
+

+ + Bar + +

+
+

+ Docstring for + + Bar + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+
+
+
+
class Bar:
+    '''Docstring for `Bar`.'''
+
+    def __init__(self, a: int, b: str) -> None:
+        '''Docstring for `Bar.__init__`.'''
+        self.c = a + b
+        '''Docstring for `Bar.c`.'''
+
+    def foo(self, a: int, b: str) -> None:
+        '''Docstring.'''
+
+
+
+
+
+
+
+
+
+
+

+ + Qux + +

+
+

+ Bases: + + + Bar + + +

+

+ Docstring for + + Qux + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
19
+20
+
+
+
+
class Qux(Bar):
+    '''Docstring for `Qux`.'''
+
+
+
+
+
+
+
+
+

+ + + foo + + + ( + + + a + + + , + + + b + + + ) + + +

+
+

+ Docstring for + + foo + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
2
+3
+
+
+
+
def foo(a: int, b: str) -> None:
+    '''Docstring for `foo`.'''
+
+
+
+
+
+
+
+
+
+
diff --git a/config/.inline-snapshot/external/d9a1ebc1cc86e0d0cebbc72ab979230c808d939e79b77a142714d1a829fa8367.html b/config/.inline-snapshot/external/d9a1ebc1cc86e0d0cebbc72ab979230c808d939e79b77a142714d1a829fa8367.html new file mode 100644 index 00000000..cd1e2d47 --- /dev/null +++ b/config/.inline-snapshot/external/d9a1ebc1cc86e0d0cebbc72ab979230c808d939e79b77a142714d1a829fa8367.html @@ -0,0 +1,106 @@ +
+ + +
+
+
+

+ + + baz + + + : + + + int + + + = + + + 42 + + + + + + module-attribute + + + +

+
+

+ Docstring for + + baz + + . +

+
+
+
+

+ + Bar + +

+
+

+ Docstring for + + Bar + + . +

+
+ + Source code in + + pkg/__init__.py + + +
+ + + + + +
+
+
 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+
+
+
+
class Bar:
+    '''Docstring for `Bar`.'''
+
+    def __init__(self, a: int, b: str) -> None:
+        '''Docstring for `Bar.__init__`.'''
+        self.c = a + b
+        '''Docstring for `Bar.c`.'''
+
+    def foo(self, a: int, b: str) -> None:
+        '''Docstring.'''
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/duties.py b/duties.py index 424538f7..4b6a0f50 100644 --- a/duties.py +++ b/duties.py @@ -277,7 +277,7 @@ def test(ctx: Context, match: str = "", snapshot: str = "") -> None: """ py_version = f"{sys.version_info.major}{sys.version_info.minor}" os.environ["COVERAGE_FILE"] = f".coverage.{py_version}" - args = [f"--inline-snapshot={snapshot}"] if snapshot else ["-n", "auto"] + args = [f"--inline-snapshot={snapshot}"] if snapshot else [] ctx.run( pytest.run(*args, "tests", config_file="config/pytest.ini", select=match, color="yes"), title=pyprefix("Running tests"), diff --git a/tests/helpers.py b/tests/helpers.py new file mode 100644 index 00000000..26ab948e --- /dev/null +++ b/tests/helpers.py @@ -0,0 +1,93 @@ +"""Configuration for the pytest test suite.""" + +from __future__ import annotations + +from collections import ChainMap +from contextlib import contextmanager +from typing import TYPE_CHECKING, Any, Iterator + +import pytest +from markdown.core import Markdown +from mkdocs.config.defaults import MkDocsConfig + +if TYPE_CHECKING: + from pathlib import Path + + from mkdocstrings.plugin import MkdocstringsPlugin + + from mkdocstrings_handlers.python.handler import PythonHandler + + +@contextmanager +def mkdocs_conf(request: pytest.FixtureRequest, tmp_path: Path) -> Iterator[MkDocsConfig]: + """Yield a MkDocs configuration object. + + Parameters: + request: Pytest request fixture. + tmp_path: Temporary path. + + Yields: + MkDocs config. + """ + conf = MkDocsConfig() + while hasattr(request, "_parent_request") and hasattr(request._parent_request, "_parent_request"): + request = request._parent_request + + conf_dict = { + "site_name": "foo", + "site_url": "https://example.org/", + "site_dir": str(tmp_path), + "plugins": [{"mkdocstrings": {"default_handler": "python"}}], + **getattr(request, "param", {}), + } + # Re-create it manually as a workaround for https://github.com/mkdocs/mkdocs/issues/2289 + mdx_configs: dict[str, Any] = dict(ChainMap(*conf_dict.get("markdown_extensions", []))) + + conf.load_dict(conf_dict) + assert conf.validate() == ([], []) + + conf["mdx_configs"] = mdx_configs + conf["markdown_extensions"].insert(0, "toc") # Guaranteed to be added by MkDocs. + + conf = conf["plugins"]["mkdocstrings"].on_config(conf) + conf = conf["plugins"]["autorefs"].on_config(conf) + yield conf + conf["plugins"]["mkdocstrings"].on_post_build(conf) + + +def plugin(mkdocs_conf: MkDocsConfig) -> MkdocstringsPlugin: + """Return a plugin instance. + + Parameters: + mkdocs_conf: MkDocs configuration. + + Returns: + mkdocstrings plugin instance. + """ + return mkdocs_conf["plugins"]["mkdocstrings"] + + +def ext_markdown(mkdocs_conf: MkDocsConfig) -> Markdown: + """Return a Markdown instance with MkdocstringsExtension. + + Parameters: + mkdocs_conf: MkDocs configuration. + + Returns: + A Markdown instance. + """ + return Markdown(extensions=mkdocs_conf["markdown_extensions"], extension_configs=mkdocs_conf["mdx_configs"]) + + +def handler(plugin: MkdocstringsPlugin, ext_markdown: Markdown) -> PythonHandler: + """Return a handler instance. + + Parameters: + plugin: Plugin instance. + + Returns: + A handler instance. + """ + handler = plugin.handlers.get_handler("python") + handler._update_env(ext_markdown, plugin.handlers._config) + return handler # type: ignore[return-value] diff --git a/tests/test_end_to_end.py b/tests/test_end_to_end.py index 5d191667..57130208 100644 --- a/tests/test_end_to_end.py +++ b/tests/test_end_to_end.py @@ -3,6 +3,8 @@ from __future__ import annotations import re +import sys +from datetime import datetime from typing import TYPE_CHECKING, Any import bs4 @@ -13,6 +15,13 @@ if TYPE_CHECKING: from mkdocstrings.handlers.python import PythonHandler + +def log(msg: str, file: str) -> None: + py = "python" + ".".join(str(v) for v in sys.version_info[:2]) + with open(file, "a") as f: + f.write(f"{py}: {datetime.now()}: {msg}\n") + + options = { # General options. "find_stubs_package": (True, False), @@ -111,7 +120,7 @@ def _render(handler: PythonHandler, final_options: dict[str, Any]) -> str: html = handler.render(data, handler_options) return _normalize_html(html) - +log("Loading snapshots", "time.txt") snapshots_signatures = snapshot( { ( @@ -3439,6 +3448,7 @@ def _render(handler: PythonHandler, final_options: dict[str, Any]) -> str: }, ) +log("Parametrizing tests", "time.txt") # Signature options @pytest.mark.parametrize("annotations_path", options["annotations_path"]) @@ -3494,3 +3504,5 @@ def test_end_to_end_for_members( html = _render(session_handler, final_options) snapshot_key = tuple(sorted(final_options.items())) assert outsource(html, suffix=".html") == snapshots_members[snapshot_key] + +log("Finished", "time.txt") diff --git a/time.txt b/time.txt new file mode 100644 index 00000000..58ca1867 --- /dev/null +++ b/time.txt @@ -0,0 +1,18 @@ +python3.8: 2024-05-22 16:05:11.021737: Loading snapshots +python3.8: 2024-05-22 16:05:24.253087: Parametrizing tests +python3.8: 2024-05-22 16:05:24.253426: Finished +python3.9: 2024-05-22 16:05:45.334478: Loading snapshots +python3.9: 2024-05-22 16:05:58.566244: Parametrizing tests +python3.9: 2024-05-22 16:05:58.566592: Finished +python3.10: 2024-05-22 16:06:20.746896: Loading snapshots +python3.10: 2024-05-22 16:06:42.528725: Parametrizing tests +python3.10: 2024-05-22 16:06:42.529088: Finished +python3.11: 2024-05-22 16:07:05.519604: Loading snapshots +python3.11: 2024-05-22 16:07:05.736831: Parametrizing tests +python3.11: 2024-05-22 16:07:05.737229: Finished +python3.12: 2024-05-22 16:07:31.673954: Loading snapshots +python3.12: 2024-05-22 16:07:31.977040: Parametrizing tests +python3.12: 2024-05-22 16:07:31.978833: Finished +python3.11: 2024-05-22 16:33:42.225503: Loading snapshots +python3.11: 2024-05-22 16:33:42.477051: Parametrizing tests +python3.11: 2024-05-22 16:33:42.477459: Finished