@@ -59,19 +59,42 @@ def hub_builder(
5959 build = lambda : _build (self ),
6060 pip_parse = lambda * a , ** k : _pip_parse (self , * a , ** k ),
6161
62- # build output
62+ # Build output related
63+
64+ # The set of package names to expose. Dict acting as set
65+ # dict[str package, None]
6366 _exposed_packages = {}, # modified by _add_exposed_packages
67+ # Map of the per-package aliases.
68+ # The nested dict is a dict acting as a set.
69+ # dict[str whl_name, dict[str alias_name, bool]]
6470 _extra_aliases = {}, # modified by _add_extra_aliases
71+ # dict[str group_name, list[str]]
6572 _group_map = {}, # modified by _add_group_map
73+ # Mapping of whl_library repo names and their kwargs.
74+ # dict[str repo_name, dict[str, object] kwargs]
6675 _whl_libraries = {}, # modified by _add_whl_library
76+ # Map of repos and their config settings, and repo the config
77+ # setting originated from.
78+ # dict[str whl_name, dict[str config_setting, str repo_name]]
6779 _whl_map = {}, # modified by _add_whl_library
68- # internal
80+
81+ # Internal
82+
83+ # dict[str python_version, dict[str platform, PlatformInfo]]
84+ # where `PlatformInfo` is from `_platforms()`
6985 _platforms = {},
86+ # Supplemental index of `_group_map`
87+ # dict[str whl_name, str group_name]
7088 _group_name_by_whl = {},
89+ # Functions to download according to the config
90+ # dict[str python_version, callable]
7191 _get_index_urls = {},
92+ # Tells whether to use the downloader for a package.
93+ # dict[str python_version, dict[str package_name, bool use_downloader]]
7294 _use_downloader = {},
7395 _simpleapi_cache = simpleapi_cache ,
74- # instance constants
96+
97+ # Instance constants passed in by callers
7598 _config = config ,
7699 _whl_overrides = whl_overrides ,
77100 _evaluate_markers_fn = evaluate_markers_fn ,
@@ -103,13 +126,24 @@ def _build(self):
103126 whl_map .setdefault (key , {}).setdefault (repo , []).append (setting )
104127
105128 return struct (
129+ # The config settings for matching repo spokes.
130+ # dict[str repo_name, dict[str repo_name, list[str]]]
106131 whl_map = whl_map ,
132+ # Maps a wheel to a list of groups
133+ # dict[str group_name, list[str]]
107134 group_map = self ._group_map ,
135+ # The per-package aliases for the hub to create.
136+ # dict[str package, list[str]]
108137 extra_aliases = {
109138 whl : sorted (aliases )
110139 for whl , aliases in self ._extra_aliases .items ()
111140 },
141+ # The list of exposed packages in the hub.
142+ # list[str]
112143 exposed_packages = sorted (self ._exposed_packages ),
144+
145+ # Mapping of whl_library repo names and their kwargs.
146+ # dict[str repo_name, dict[str, object] kwargs]
113147 whl_libraries = self ._whl_libraries ,
114148 )
115149
@@ -171,6 +205,13 @@ def _pip_parse(self, module_ctx, pip_attr):
171205### setters for build outputs
172206
173207def _add_exposed_packages (self , exposed_packages ):
208+ """Add packages that are exposed.
209+
210+ Args:
211+ self: implicitly added
212+ exposed_packages: {type}`dict[str package, None]` a dict acting as
213+ a set. The set of packages that should be exposed.
214+ """
174215 if self ._exposed_packages :
175216 intersection = {}
176217 for pkg in exposed_packages :
@@ -183,6 +224,13 @@ def _add_exposed_packages(self, exposed_packages):
183224 self ._exposed_packages .update (exposed_packages )
184225
185226def _add_group_map (self , group_map ):
227+ """Adds a group mapping for cycle breaking.
228+
229+ Args:
230+ self: implicitly added.
231+ group_map: {type}`dict[str name, list[str]]`
232+ """
233+
186234 # TODO @aignas 2024-04-05: how do we support different requirement
187235 # cycles for different abis/oses? For now we will need the users to
188236 # assume the same groups across all versions/platforms until we start
@@ -202,6 +250,13 @@ def _add_group_map(self, group_map):
202250 })
203251
204252def _add_extra_aliases (self , extra_hub_aliases ):
253+ """Adds per-package aliases to the hub.
254+
255+ Args:
256+ self: Implicitly added
257+ extra_hub_aliases: {type}`dict[str package, list[str]]` Alias target
258+ names to add to a package's hub BUILD file.
259+ """
205260 for whl_name , aliases in extra_hub_aliases .items ():
206261 self ._extra_aliases .setdefault (whl_name , {}).update (
207262 {alias : True for alias in aliases },
@@ -246,6 +301,15 @@ def _diff_dict(first, second):
246301 return None
247302
248303def _add_whl_library (self , * , python_version , whl , repo , enable_pipstar ):
304+ """Add a whl_library and kwargs to call it with for the hub.
305+
306+ Args:
307+ self: implicitly added
308+ python_version: {type}`str` the python version to assume
309+ whl: struct from `_whl_library_args()`
310+ repo: struct from `_whl_repo`
311+ enable_pipstar: {type}`bool` if pipstar is enabled.
312+ """
249313 if repo == None :
250314 # NOTE @aignas 2025-07-07: we guard against an edge-case where there
251315 # are more platforms defined than there are wheels for and users
0 commit comments