codegraph_python/
lib.rs

1//! # codegraph-python
2//!
3//! Python parser plugin for CodeGraph - extracts code entities and relationships
4//! from Python source files.
5//!
6//! ## Features
7//!
8//! - Parse single Python files or entire projects
9//! - Extract functions, classes, methods with full metadata
10//! - Track relationships (calls, imports, inheritance)
11//! - Configurable behavior (visibility filtering, parallel processing)
12//! - Safe: No panics, graceful error handling
13//!
14//! ## Quick Start (New API - v0.2.0+)
15//!
16//! ```rust,no_run
17//! use codegraph_python::PythonParser;
18//! use codegraph_parser_api::CodeParser;
19//! use codegraph::CodeGraph;
20//! use std::path::Path;
21//!
22//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
23//! let mut graph = CodeGraph::in_memory()?;
24//! let parser = PythonParser::new();
25//!
26//! let file_info = parser.parse_file(Path::new("example.py"), &mut graph)?;
27//! println!("Parsed {} functions", file_info.functions.len());
28//! # Ok(())
29//! # }
30//! ```
31//!
32//! ## Legacy API (Deprecated in v0.2.0)
33//!
34//! ```rust,no_run,ignore
35//! use codegraph_python::Parser;
36//!
37//! // This API is deprecated - use PythonParser with CodeParser trait instead
38//! let parser = Parser::new();
39//! ```
40
41// Keep old config and error for backward compatibility with deprecated API
42pub mod config;
43pub mod error;
44
45mod builder;
46mod extractor;
47mod parser;
48mod parser_impl;
49// mod visitor; // Temporarily disabled - will be re-enabled in a future task
50
51// Re-export parser-api types for convenience
52pub use codegraph_parser_api::{
53    CodeParser, FileInfo as ApiFileInfo, ParserConfig as ApiParserConfig, ParserError,
54    ProjectInfo as ApiProjectInfo,
55};
56
57// Export new parser implementation
58pub use parser_impl::PythonParser;
59
60// Legacy exports (deprecated)
61pub use config::ParserConfig;
62pub use error::{ParseError, Result};
63
64#[deprecated(
65    since = "0.2.0",
66    note = "Use PythonParser with CodeParser trait instead"
67)]
68pub use parser::{FileInfo, Parser, ProjectInfo};