Skip to content

Commit 4abca8f

Browse files
committed
Update documentation
1 parent 3aeb2ab commit 4abca8f

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

docs/usage.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ Higher level analysis
304304
passing ``independent=False`` when instantiating the :class:`.Layer`. For convenience, if a layer consists
305305
only of one module name then a string may be passed in place of the :class:`.Layer` object. Additionally, if
306306
the layer consists of multiple *independent* modules, that can be passed as a set of strings instead of a
307-
:class:`.Layer` object.
307+
:class:`.Layer` object. A closed layer may be created by passing ``open=False`` (see below).
308308
*Any modules specified that don't exist in the graph will be silently ignored.*
309309
:param set[str] containers: The parent modules of the layers, as absolute names that you could
310310
import, such as ``mypackage.foo``. (Optional.)
@@ -409,6 +409,14 @@ Higher level analysis
409409
),
410410
)
411411

412+
Closed layers
413+
^^^^^^^^^^^^^
414+
415+
A closed layer may be created by passing ``open=False``. Imports from higher to lower
416+
layers cannot bypass closed layers - the closed layer must be included in the import
417+
chain. For example, given the layers high -> mid (closed) -> low then all import chains
418+
from high -> low must go via mid.
419+
412420
Return value
413421
^^^^^^^^^^^^
414422

@@ -575,4 +583,4 @@ Module expressions
575583
- ``mypackage.foo*``: is not a valid expression. (The wildcard must replace a whole module name.)
576584

577585
.. _namespace packages: https://docs.python.org/3/glossary.html#term-namespace-package
578-
.. _namespace portion: https://docs.python.org/3/glossary.html#term-portion
586+
.. _namespace portion: https://docs.python.org/3/glossary.html#term-portion

src/grimp/application/ports/graph.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,11 @@ def find_illegal_dependencies_for_layers(
373373
compatibility it is also possible to pass a simple `set[str]` to describe a layer. In this
374374
case the sibling modules within the layer will be considered independent.
375375
376+
By default layers are open. `Layer.open` can be set to false to create a closed layer.
377+
Imports from higher to lower layers cannot bypass closed layers - the closed layer must be
378+
included in the import chain. For example, given the layers high -> mid (closed) -> low then
379+
all import chains from high -> low must go via mid.
380+
376381
Arguments:
377382
378383
- layers: A sequence, each element of which consists either of a `Layer`, the name

0 commit comments

Comments
 (0)