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

Function _shape_method_docs

src/ifcmcp/ifcmcp/core.py:92–136  ·  view source on GitHub ↗

Return full documentation for a single ShapeBuilder method.

(method_name: str)

Source from the content-addressed store, hash-verified

90
91
92def _shape_method_docs(method_name: str) -> dict:
93 """Return full documentation for a single ShapeBuilder method."""
94 import typing
95
96 from ifcedit.discover import (
97 _extract_params,
98 _format_type_hint,
99 _parse_docstring_body,
100 _parse_param_docs,
101 _parse_return_doc,
102 )
103 from ifcopenshell.util.shape_builder import ShapeBuilder
104
105 if method_name.startswith("_"):
106 raise ValueError(f"ShapeBuilder has no method '{method_name}'")
107 fn = getattr(ShapeBuilder, method_name, None)
108 if fn is None:
109 raise ValueError(f"ShapeBuilder has no method '{method_name}'")
110
111 doc = fn.__doc__ or ""
112 description, long_description = _parse_docstring_body(doc)
113 params = _extract_params(fn)
114 for param in params:
115 param_desc = _parse_param_docs(doc)
116 if param["name"] in param_desc:
117 param["description"] = param_desc[param["name"]]
118
119 try:
120 hints = typing.get_type_hints(fn)
121 except Exception:
122 hints = {}
123
124 result: dict[str, Any] = {
125 "method": method_name,
126 "description": description,
127 "long_description": long_description,
128 "params": params,
129 }
130 return_type = _format_type_hint(hints.get("return"))
131 if return_type:
132 result["return_type"] = return_type
133 return_description = _parse_return_doc(doc)
134 if return_description:
135 result["return_description"] = return_description
136 return result
137
138
139def _coerce_shape_params(fn: Callable, raw_kwargs: dict, model: ifcopenshell.file) -> dict:

Callers 1

ifc_shape_docsMethod · 0.85

Calls 6

_parse_docstring_bodyFunction · 0.90
_extract_paramsFunction · 0.90
_parse_param_docsFunction · 0.90
_format_type_hintFunction · 0.90
_parse_return_docFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected