3131
3232class BomRefDiscriminator :
3333 """
34- Ensure that a collection of BomRef objects has unique, non‑empty values.
34+ Ensure that a collection of :class:`cyclonedx.model.bom_ref. BomRef` objects has unique, non‑empty values.
3535
3636 The discriminator inspects the provided BomRef instances and assigns new,
3737 automatically generated identifiers to any BomRef whose value is missing
38- or duplicates another. Original values are preserved so they can be
39- restored later via `reset()` or by using this class as a context manager.
38+ or duplicates another.
39+ Original values are preserved so they can be restored later via :meth: `reset()` or by using this class as a context manager.
4040 """
4141
4242 def __init__ (self , bomrefs : Iterable ['BomRef' ], prefix : str = 'BomRef' ) -> None :
43- # do not use dict/set here, different BomRefs with same value have same hash and would shadow each other
43+ # NOTE: do not use dict/set here, different BomRefs with same value
44+ # have same hash and would shadow each other.
4445 self ._bomrefs = tuple ((bomref , bomref .value ) for bomref in bomrefs )
4546 self ._prefix = prefix
4647
@@ -52,10 +53,11 @@ def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
5253
5354 def discriminate (self ) -> None :
5455 """
55- Enforce uniqueness across all BomRef values .
56+ Enforce uniqueness across all :attr:`cyclonedx.model.bom_ref. BomRef.value` .
5657
57- Any BomRef whose value is `None` or duplicates a previously encountered
58- value is assigned a newly generated unique identifier.
58+ .. note::
59+ Any BomRef whose value is ``None`` or duplicates a previously encountered
60+ value is assigned a newly generated unique identifier.
5961 """
6062 known_values = []
6163 for bomref , _ in self ._bomrefs :
@@ -67,7 +69,7 @@ def discriminate(self) -> None:
6769
6870 def reset (self ) -> None :
6971 """
70- Restore all BomRef values to their original state.
72+ Restore all :attr:`cyclonedx.model.bom_ref. BomRef.value` to their original state.
7173 """
7274 for bomref , original_value in self ._bomrefs :
7375 bomref .value = original_value
@@ -81,9 +83,9 @@ def from_bom(cls, bom: 'Bom', prefix: str = 'BomRef') -> 'BomRefDiscriminator':
8183 Create a discriminator for all BomRefs contained within a BOM.
8284
8385 This includes BomRefs from
84- - components
85- - services
86- - vulnerabilities
86+ * components
87+ * services
88+ * vulnerabilities
8789 """
8890 return cls (chain (
8991 map (lambda c : c .bom_ref , bom ._get_all_components ()),
0 commit comments