/** * Code Comment Extraction Engine (SMCP-100) * * Extracts documentation comments from code files to make them searchable * via the docs search index (search_docs). Supports JSDoc, Python docstrings, * Rust doc comments, Go doc comments, and other language-specific formats. * * Features: * - Extract JSDoc/TSDoc from JS/TS files * - Extract docstrings from Python files * - Extract /// and //! comments from Rust files * - Extract Go package and function comments * - Link comments back to source code location * - Parse @tags (param, returns, example, etc.) * * @module commentExtractor */ import { type ASTLanguage } from './treeSitterParser.js'; /** * Type of documentation comment */ export type CommentType = 'jsdoc' | 'tsdoc' | 'docstring' | 'rustdoc' | 'javadoc' | 'xmldoc' | 'godoc' | 'block' | 'inline'; /** * Parsed tag from a documentation comment */ export interface CommentTag { /** Tag name (e.g., 'param', 'returns', 'example') */ name: string; /** Tag value/content */ value: string; /** For @param: the parameter name */ paramName?: string; /** For @param: the parameter type */ paramType?: string; } /** * Extracted documentation comment */ export interface ExtractedComment { /** Type of comment */ type: CommentType; /** Cleaned content (without markers) */ content: string; /** Original raw content (with markers) */ rawContent: string; /** Associated symbol name (function, class, etc.) */ symbol?: string; /** Symbol type (function, class, method, etc.) */ symbolType?: string; /** Relative file path */ filePath: string; /** Start line number (1-based) */ startLine: number; /** End line number (1-based) */ endLine: number; /** Parsed tags (@param, @returns, etc.) */ tags?: CommentTag[]; /** Language of the source file */ language: ASTLanguage | string; } /** * Comment extractor interface */ export interface CommentExtractor { /** Extract comments from source code */ extract(content: string, filePath: string): Promise; /** Check if this extractor supports the given file */ supports(filePath: string): boolean; } /** * Options for comment extraction */ export interface CommentExtractionOptions { /** Minimum comment length to extract (default: 20 characters) */ minLength?: number; /** Maximum comment length to extract (default: 10000 characters) */ maxLength?: number; /** Include inline comments (default: false - only doc comments) */ includeInlineComments?: boolean; /** Include block comments without special markers (default: false) */ includeBlockComments?: boolean; } /** * Default extraction options */ export declare const DEFAULT_COMMENT_OPTIONS: Required; /** * Supported file extensions for comment extraction */ export declare const SUPPORTED_EXTENSIONS: Record; /** * Parse JSDoc/TSDoc style tags from comment content */ export declare function parseJSDocTags(content: string): CommentTag[]; /** * Parse Python-style docstring tags (Args:, Returns:, etc.) * Supports Google-style docstrings with sections like Args:, Returns:, Raises: */ export declare function parsePythonDocTags(content: string): CommentTag[]; /** * Clean JSDoc-style comment content */ export declare function cleanJSDocContent(content: string): string; /** * Clean Python docstring content */ export declare function cleanPythonDocstring(content: string): string; /** * Clean Rust doc comment content (/// or //!) */ export declare function cleanRustDocContent(lines: string[]): string; /** * Clean Go doc comment content */ export declare function cleanGoDocContent(lines: string[]): string; /** * Extract documentation comments from a source file * * @param sourceCode - Source code content * @param filePath - Relative file path * @param options - Extraction options * @returns Array of extracted comments */ export declare function extractComments(sourceCode: string, filePath: string, options?: CommentExtractionOptions): Promise; /** * Check if a file type is supported for comment extraction * * @param filePath - File path to check * @returns true if the file type is supported */ export declare function supportsCommentExtraction(filePath: string): boolean; /** * Format an extracted comment for indexing in the docs search * * @param comment - Extracted comment * @returns Formatted text suitable for embedding and search */ export declare function formatCommentForIndex(comment: ExtractedComment): string; /** * Get the list of supported file extensions for comment extraction */ export declare function getSupportedExtensions(): string[]; //# sourceMappingURL=commentExtractor.d.ts.map