44
55"""Consistency checks between the public ``__all__`` surface and the API docs.
66
7- Covers the flat ``cuda.core`` namespace and every public subpackage
8- (``graph``, ``system``, ``texture``, ``utils``, and any added later) discovered
9- automatically from ``cuda.core.__path__``. For each public namespace, exported
10- ``__all__`` names must appear somewhere in ``cuda_core/docs/source``.
7+ Covers the flat ``cuda.core`` namespace and every public submodule
8+ (``checkpoint``, ``graph``, ``system``, ``texture``, ``typing``, ``utils``,
9+ and any added later) discovered automatically from ``cuda.core.__path__``.
10+ For each public namespace, exported ``__all__`` names must appear somewhere
11+ in ``cuda_core/docs/source``.
1112
1213The enforced direction is deliberately one-way (public export -> documented).
1314This is intentionally a *name-presence* check, and it does not verify:
4647# those are an internal packaging mechanism, not public API.
4748_VERSIONED_SUBPACKAGE = re .compile (r"^cu\d+$" )
4849
49- PUBLIC_SUBPACKAGES = sorted (
50+ PUBLIC_SUBMODULES = sorted (
5051 name
5152 for _ , name , ispkg in pkgutil .iter_modules (cuda .core .__path__ )
52- if ispkg and not name .startswith ("_" ) and not _VERSIONED_SUBPACKAGE .match (name )
53+ if not name .startswith ("_" ) and not _VERSIONED_SUBPACKAGE .match (name )
5354)
5455
5556
@@ -157,7 +158,7 @@ def _add_documented_name(documented, module, entry):
157158 documented [module ].add (entry )
158159 return
159160 sub , name = entry .split ("." , 1 )
160- if sub in PUBLIC_SUBPACKAGES and "." not in name :
161+ if sub in PUBLIC_SUBMODULES and "." not in name :
161162 documented [f"cuda.core.{ sub } " ].add (name )
162163 return
163164 if module .startswith ("cuda.core." ):
@@ -176,7 +177,7 @@ def _documented_names(docs_dir, *, exclude=frozenset()):
176177 return documented
177178
178179
179- PUBLIC_NAMESPACES = ("cuda.core" , * (f"cuda.core.{ sub } " for sub in PUBLIC_SUBPACKAGES ))
180+ PUBLIC_NAMESPACES = ("cuda.core" , * (f"cuda.core.{ sub } " for sub in PUBLIC_SUBMODULES ))
180181
181182
182183@pytest .fixture (scope = "module" )
@@ -199,10 +200,10 @@ def documented(docs_dir):
199200
200201
201202@pytest .mark .human_authored
202- def test_public_subpackages_discovered ():
203+ def test_public_submodules_discovered ():
203204 # Guards against a broken __path__ walk silently turning every
204- # parametrized subpackage check into a no-op.
205- assert PUBLIC_SUBPACKAGES , "no public cuda.core subpackages were discovered"
205+ # parametrized submodule check into a no-op.
206+ assert PUBLIC_SUBMODULES , "no public cuda.core submodules were discovered"
206207
207208
208209@pytest .mark .human_authored
@@ -219,7 +220,7 @@ def test_main_package_symbols_are_documented(exported, documented):
219220 assert not undocumented , f"public by cuda.core.__all__ but missing from docs/source/*.rst: { sorted (undocumented )} "
220221
221222
222- @pytest .mark .parametrize ("sub" , PUBLIC_SUBPACKAGES )
223+ @pytest .mark .parametrize ("sub" , PUBLIC_SUBMODULES )
223224def test_subpackage_symbols_define_all (sub ):
224225 module = importlib .import_module (f"cuda.core.{ sub } " )
225226 assert hasattr (module , "__all__" ), f"cuda.core.{ sub } does not define __all__"
@@ -228,7 +229,7 @@ def test_subpackage_symbols_define_all(sub):
228229
229230
230231@pytest .mark .human_authored
231- @pytest .mark .parametrize ("sub" , PUBLIC_SUBPACKAGES )
232+ @pytest .mark .parametrize ("sub" , PUBLIC_SUBMODULES )
232233def test_subpackage_exports_are_documented (sub , documented ):
233234 documented = documented [f"cuda.core.{ sub } " ]
234235 module = importlib .import_module (f"cuda.core.{ sub } " )
0 commit comments