def _extract_definitions(self, code: str) -> list[str]:
        """Extract class and function definitions with their docstrings."""
        definitions = []

        # Pattern for class and function definitions
        def_pattern = r'((?:def|class)\s+\w+(?:\(.*?\))?\s*(?:->.*?)?:)(?:\s*"""(.*?)"""|\s*\'\'\'(.*?)\'\'\')?'
        matches = re.finditer(def_pattern, code, re.DOTALL)

        for match in matches:
            definition = match.group(1).strip()
            docstring = match.group(2) or match.group(3)

            definitions.append(definition)
            if docstring:
                # Format the docstring with indentation
                formatted_docstring = "\n".join(
                    f"  {line.strip()}"
                    for line in docstring.strip().split("\n")
                )
                definitions.append(formatted_docstring)

            definitions.append("")  # Add empty line for readability

        return definitions
Extract class and function definitions with their docstrings.
py/core/parsers/text/python_parser.py