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

Function _parse_docstring_body

src/ifcedit/ifcedit/discover.py:215–236  ·  view source on GitHub ↗

Parse the summary and long description from a docstring.

(docstring: str)

Source from the content-addressed store, hash-verified

213
214
215def _parse_docstring_body(docstring: str) -> tuple[str, str]:
216 """Parse the summary and long description from a docstring."""
217 lines = docstring.strip().split("\n")
218 summary = lines[0].strip() if lines else ""
219 body_lines = []
220 in_body = False
221 for line in lines[1:]:
222 stripped = line.strip()
223 if stripped.startswith(":param") or stripped.startswith(":return"):
224 break
225 if stripped.startswith("Example"):
226 break
227 if not in_body and not stripped:
228 in_body = True
229 continue
230 if in_body:
231 body_lines.append(stripped)
232
233 long_description = " ".join(body_lines).strip()
234 # collapse multiple spaces
235 long_description = re.sub(r"\s+", " ", long_description)
236 return summary, long_description
237
238
239_FIELD_MARKER = re.compile(r":(?:param|returns?|rtype|type|raises?)\b")

Callers 2

_shape_method_docsFunction · 0.90
function_docsFunction · 0.85

Calls 3

splitMethod · 0.80
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected