List functions in an API module with one-line descriptions and parameter info. Returns a list of dicts: [{"name": "create_entity", "description": "...", "params": [...]}]
(module: str)
| 68 | |
| 69 | |
| 70 | def list_functions(module: str) -> list[dict]: |
| 71 | """List functions in an API module with one-line descriptions and parameter info. |
| 72 | |
| 73 | Returns a list of dicts: [{"name": "create_entity", "description": "...", "params": [...]}] |
| 74 | """ |
| 75 | mod = importlib.import_module(f"ifcopenshell.api.{module}") |
| 76 | all_names = getattr(mod, "__all__", []) |
| 77 | functions = [] |
| 78 | for name in all_names: |
| 79 | fn = _get_underlying_function(module, name) |
| 80 | if fn is None: |
| 81 | continue |
| 82 | description = "" |
| 83 | if fn.__doc__: |
| 84 | description = fn.__doc__.strip().split("\n")[0] |
| 85 | params = _extract_params(fn) |
| 86 | functions.append( |
| 87 | { |
| 88 | "name": name, |
| 89 | "description": description, |
| 90 | "params": params, |
| 91 | } |
| 92 | ) |
| 93 | return functions |
| 94 | |
| 95 | |
| 96 | def function_docs(module: str, function: str) -> dict: |