Full documentation for a single API function. Returns a dict with: module, function, description, params (with types/defaults/descriptions), return_type
(module: str, function: str)
| 94 | |
| 95 | |
| 96 | def function_docs(module: str, function: str) -> dict: |
| 97 | """Full documentation for a single API function. |
| 98 | |
| 99 | Returns a dict with: module, function, description, params (with types/defaults/descriptions), return_type |
| 100 | """ |
| 101 | fn = _get_underlying_function(module, function) |
| 102 | if fn is None: |
| 103 | raise ValueError(f"Function '{module}.{function}' not found") |
| 104 | |
| 105 | description = "" |
| 106 | long_description = "" |
| 107 | if fn.__doc__: |
| 108 | description, long_description = _parse_docstring_body(fn.__doc__) |
| 109 | |
| 110 | params = _extract_params(fn) |
| 111 | param_descriptions = _parse_param_docs(fn.__doc__ or "") |
| 112 | for param in params: |
| 113 | if param["name"] in param_descriptions: |
| 114 | param["description"] = param_descriptions[param["name"]] |
| 115 | |
| 116 | return_type = _format_type_hint(typing.get_type_hints(fn).get("return")) |
| 117 | return_description = _parse_return_doc(fn.__doc__ or "") |
| 118 | |
| 119 | result = { |
| 120 | "module": module, |
| 121 | "function": function, |
| 122 | "description": description, |
| 123 | "long_description": long_description, |
| 124 | "params": params, |
| 125 | } |
| 126 | if return_type: |
| 127 | result["return_type"] = return_type |
| 128 | if return_description: |
| 129 | result["return_description"] = return_description |
| 130 | return result |
| 131 | |
| 132 | |
| 133 | def _get_underlying_function(module: str, function: str): |