Generate an `__all__` variable for the given names.
(code: CodeBlock)
| 221 | |
| 222 | |
| 223 | def generate_export(code: CodeBlock) -> None: |
| 224 | """Generate an `__all__` variable for the given names.""" |
| 225 | assert len(code.lines) >= 2 |
| 226 | |
| 227 | mod = code.param |
| 228 | code.lines = [ |
| 229 | code.lines[0], |
| 230 | "# fmt: off", |
| 231 | "# isort: off", |
| 232 | f"from .{mod} import * # noqa: F403", |
| 233 | f"from .{mod} import __all__ as {mod}__all__", |
| 234 | 'if "__all__" not in globals():', |
| 235 | " __all__ = []", |
| 236 | f"__all__.extend({mod}__all__)", |
| 237 | "# isort: on", |
| 238 | "# fmt: on", |
| 239 | code.lines[-1], |
| 240 | ] |
| 241 | |
| 242 | |
| 243 | def generate_ffi_api( |
no outgoing calls