List all API modules with their function counts and descriptions. Returns a list of dicts: [{"module": "root", "description": "...", "functions": [...], "count": 4}, ...]
()
| 34 | |
| 35 | |
| 36 | def list_modules() -> list[dict]: |
| 37 | """List all API modules with their function counts and descriptions. |
| 38 | |
| 39 | Returns a list of dicts: [{"module": "root", "description": "...", "functions": [...], "count": 4}, ...] |
| 40 | """ |
| 41 | api_path = _api_package_path() |
| 42 | modules = [] |
| 43 | for child in sorted(api_path.iterdir()): |
| 44 | if not child.is_dir() or child.name.startswith("_"): |
| 45 | continue |
| 46 | init_file = child / "__init__.py" |
| 47 | if not init_file.exists(): |
| 48 | continue |
| 49 | try: |
| 50 | mod = importlib.import_module(f"ifcopenshell.api.{child.name}") |
| 51 | except Exception: |
| 52 | continue |
| 53 | all_names = getattr(mod, "__all__", []) |
| 54 | if not all_names: |
| 55 | continue |
| 56 | description = "" |
| 57 | if mod.__doc__: |
| 58 | description = mod.__doc__.strip().split("\n")[0] |
| 59 | modules.append( |
| 60 | { |
| 61 | "module": child.name, |
| 62 | "description": description, |
| 63 | "functions": list(all_names), |
| 64 | "count": len(all_names), |
| 65 | } |
| 66 | ) |
| 67 | return modules |
| 68 | |
| 69 | |
| 70 | def list_functions(module: str) -> list[dict]: |