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

Function _parse_param_docs

src/ifcedit/ifcedit/discover.py:242–265  ·  view source on GitHub ↗

Extract :param name: description lines from a docstring.

(docstring: str)

Source from the content-addressed store, hash-verified

240
241
242def _parse_param_docs(docstring: str) -> dict[str, str]:
243 """Extract :param name: description lines from a docstring."""
244 params = {}
245 current_param = None
246 current_lines = []
247 for line in docstring.split("\n"):
248 stripped = line.strip()
249 match = re.match(r":param\s+(\w+):\s*(.*)", stripped)
250 if match:
251 if current_param:
252 params[current_param] = " ".join(current_lines).strip()
253 current_param = match.group(1)
254 current_lines = [match.group(2)]
255 elif current_param and stripped and not _FIELD_MARKER.match(stripped):
256 current_lines.append(stripped)
257 elif _FIELD_MARKER.match(stripped) or (stripped == "" and current_param):
258 if current_param:
259 params[current_param] = " ".join(current_lines).strip()
260 current_param = None
261 current_lines = []
262 if current_param:
263 params[current_param] = " ".join(current_lines).strip()
264 # collapse whitespace
265 return {k: re.sub(r"\s+", " ", v) for k, v in params.items()}
266
267
268def _parse_return_doc(docstring: str) -> str:

Callers 2

_shape_method_docsFunction · 0.90
function_docsFunction · 0.85

Calls 6

splitMethod · 0.80
matchMethod · 0.45
joinMethod · 0.45
groupMethod · 0.45
appendMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected