Parse docstring to extract parameter descriptions Supports Google, NumPy, and Sphinx docstring formats
(docstring: &str)
| 660 | /// Parse docstring to extract parameter descriptions |
| 661 | /// Supports Google, NumPy, and Sphinx docstring formats |
| 662 | fn parse_docstring_parameters(docstring: &str) -> std::collections::HashMap<String, String> { |
| 663 | use std::collections::HashMap; |
| 664 | |
| 665 | let mut param_descriptions = HashMap::new(); |
| 666 | |
| 667 | if docstring.is_empty() { |
| 668 | return param_descriptions; |
| 669 | } |
| 670 | |
| 671 | // Try Google-style docstring format first |
| 672 | if let Some(args_section) = extract_args_section_google(docstring) { |
| 673 | for line in args_section.lines() { |
| 674 | if let Some((param_name, description)) = parse_google_param_line(line) { |
| 675 | param_descriptions.insert(param_name, description); |
| 676 | } |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | // Try NumPy/Sphinx-style docstring format |
| 681 | if param_descriptions.is_empty() { |
| 682 | if let Some(params_section) = extract_parameters_section_numpy(docstring) { |
| 683 | for line in params_section.lines() { |
| 684 | if let Some((param_name, description)) = parse_numpy_param_line(line) { |
| 685 | param_descriptions.insert(param_name, description); |
| 686 | } |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | param_descriptions |
| 692 | } |
| 693 | |
| 694 | /// Extract Args section from Google-style docstring |
| 695 | fn extract_args_section_google(docstring: &str) -> Option<String> { |
no test coverage detected