MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / function_docs

Function function_docs

src/ifcedit/ifcedit/discover.py:96–130  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

94
95
96def 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
133def _get_underlying_function(module: str, function: str):

Callers 9

ifc_docsMethod · 0.90
test_return_typeMethod · 0.90
test_edit_pset_docsMethod · 0.90
cmd_docsFunction · 0.90

Calls 7

_get_underlying_functionFunction · 0.85
_parse_docstring_bodyFunction · 0.85
_extract_paramsFunction · 0.85
_parse_param_docsFunction · 0.85
_format_type_hintFunction · 0.85
_parse_return_docFunction · 0.85
getMethod · 0.45

Tested by 7

test_return_typeMethod · 0.72
test_edit_pset_docsMethod · 0.72