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

        # Pattern for definitions with preceding JSDoc comments
        # This captures JSDoc comments, export keywords, and various TypeScript definitions
        pattern = r"(?:/\*\*(.*?)\*/\s*)?(?:export\s+)?(?:(class|interface|type|enum|function|const|let|var)\s+\w+[\s\S]*?(?:\{|=>|;))"

        matches = re.finditer(pattern, code, re.DOTALL)

        for match in matches:
            jsdoc = match.group(1)
            definition = match.group(2) and match.group(0)[match.start(2) :]

            if jsdoc:
                # Format the JSDoc comment
                lines = [
                    line.strip().lstrip("*").strip()
                    for line in jsdoc.split("\n")
                ]
                formatted_jsdoc = "\n".join(line for line in lines if line)
                definitions.append(formatted_jsdoc)

            if definition:
                # Extract the first line or meaningful part of the definition
                def_lines = definition.strip().split("\n")
                if len(def_lines) > 3:  # If definition is long, abbreviate
                    short_def = "\n".join(def_lines[:3]) + "\n..."
                    definitions.append(short_def)
                else:
                    definitions.append(definition.strip())

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

        return definitions
Extract class, interface, type, and function definitions with their comments.
py/core/parsers/text/ts_parser.py