MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / parse_docstring_parameters

Function parse_docstring_parameters

python/src/workflow/node.rs:662–692  ·  view source on GitHub ↗

Parse docstring to extract parameter descriptions Supports Google, NumPy, and Sphinx docstring formats

(docstring: &str)

Source from the content-addressed store, hash-verified

660/// Parse docstring to extract parameter descriptions
661/// Supports Google, NumPy, and Sphinx docstring formats
662fn 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
695fn extract_args_section_google(docstring: &str) -> Option<String> {

Callers 1

Calls 6

parse_google_param_lineFunction · 0.85
parse_numpy_param_lineFunction · 0.85
insertMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected