You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It can be useful in combination with mkdocstrings-python and custom templates, to iterate over object values or their attributes that couldn't be loaded by Griffe itself (for example, objects built dynamically and loaded as attributes won't have "members" to iterate over).
Copy file name to clipboardExpand all lines: docs/guide/contributors/architecture.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ descriptions = {
23
23
"site": "Documentation site, built with `make run mkdocs build` (git-ignored).",
24
24
"src": "The source of our Python package(s). See [Sources](#sources) and [Program structure](#program-structure).",
25
25
"src/griffe": "Our public API, exposed to users. See [Program structure](#program-structure).",
26
-
"src/griffe/_internal": "Our internal API, hidden from users. See [Program structure](#program-structure).",
26
+
"packages/griffelib/src/griffelib/_internal": "Our internal API, hidden from users. See [Program structure](#program-structure).",
27
27
"tests": "Our test suite. See [Tests](#tests).",
28
28
".copier-answers.yml": "The answers file generated by [Copier](https://copier.readthedocs.io/en/stable/). See [Boilerplate](#boilerplate).",
29
29
"devdeps.txt": "Our development dependencies specification. See [`make setup`][command-setup] command.",
@@ -104,11 +104,11 @@ Sources are located in the `src` folder, following the [src-layout](https://pack
104
104
105
105
Our test suite is located in the `tests` folder. It is located outside of the sources as to not pollute distributions (it would be very wrong to publish a `tests` package as part of our distributions, since this name is extremely common), or worse, the public API. The `tests` folder is however included in our source distributions (`.tar.gz`), alongside most of our metadata and configuration files. Check out `pyproject.toml` to get the full list of files included in our source distributions.
106
106
107
-
The test suite is based on [pytest](https://docs.pytest.org/en/8.2.x/). Test modules reflect our internal API structure, and except for a few test modules that test specific aspects of our API, each test module tests the logic from the corresponding module in the internal API. For example, `test_finder.py` tests code of the `griffe._internal.finder` internal module, while `test_functions` tests our ability to extract correct information from function signatures, statically. The general rule of thumb when writing new tests is to mirror the internal API. If a test touches to many aspects of the loading process, it can be added to the `test_loader` test module.
107
+
The test suite is based on [pytest](https://docs.pytest.org/en/8.2.x/). Test modules reflect our internal API structure, and except for a few test modules that test specific aspects of our API, each test module tests the logic from the corresponding module in the internal API. For example, `test_finder.py` tests code of the `griffelib._internal.finder` internal module, while `test_functions` tests our ability to extract correct information from function signatures, statically. The general rule of thumb when writing new tests is to mirror the internal API. If a test touches to many aspects of the loading process, it can be added to the `test_loader` test module.
108
108
109
109
## Program structure
110
110
111
-
The internal API is contained within the `src/griffe/_internal` folder. The top-level `griffe/__init__.py` module exposes all the public API, by importing the internal objects from various submodules of `griffe._internal`.
111
+
The internal API is contained within the `packages/griffelib/src/griffelib/_internal` folder. The top-level `griffe/__init__.py` module exposes all the public API, by importing the internal objects from `griffelib`, which itself imports from various submodules of `griffelib._internal`.
112
112
113
113
Users then import `griffe` directly, or import objects from it.
114
114
@@ -122,7 +122,7 @@ if os.getenv("DEPLOY") == "true":
@@ -226,13 +226,13 @@ The above exception was the direct cause of the following exception:
226
226
227
227
Traceback (most recent call last):
228
228
File "<stdin>", line 1, in <module>
229
-
File "griffe/_internal/dataclasses.py", line 1310, in target
229
+
File "griffelib/_internal/dataclasses.py", line 1310, in target
230
230
self.resolve_target()
231
-
File "griffe/_internal/dataclasses.py", line 1369, in resolve_target
231
+
File "griffelib/_internal/dataclasses.py", line 1369, in resolve_target
232
232
self._resolve_target()
233
-
File "griffe/_internal/dataclasses.py", line 1377, in _resolve_target
233
+
File "griffelib/_internal/dataclasses.py", line 1377, in _resolve_target
234
234
raise AliasResolutionError(self) from error
235
-
griffe._internal.exceptions.AliasResolutionError: Could not resolve alias package2.X pointing at package1.X (in package2/__init__.py:1)
235
+
griffelib._internal.exceptions.AliasResolutionError: Could not resolve alias package2.X pointing at package1.X (in package2/__init__.py:1)
236
236
```
237
237
238
238
As you can see in the interpreter session above, Griffe did not resolve the `X` alias. When we tried to access its target object anyway, it failed with a `KeyError`, which was raised again as an [`AliasResolutionError`][griffe.AliasResolutionError].
@@ -250,7 +250,7 @@ False # Hmm?
250
250
>>> package2["X"].target
251
251
Traceback (most recent call last):
252
252
...
253
-
griffe._internal.exceptions.AliasResolutionError: Could not resolve alias package2.X pointing at package1.X (in package2/__init__.py:1)
253
+
griffelib._internal.exceptions.AliasResolutionError: Could not resolve alias package2.X pointing at package1.X (in package2/__init__.py:1)
254
254
```
255
255
256
256
The same exception again? What happened here? We loaded both packages, but Griffe still failed to resolve the alias. That is expected; here is the explanation.
However deep the object is, Griffe loads the entire package. It means that in all the cases above, Griffe loaded the whole `markdown` package. The model instance Griffe gives you back is therefore part of a tree that you can navigate.
0 commit comments