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

Function parse_numpy_param_line

python/src/workflow/node.rs:788–809  ·  view source on GitHub ↗

Parse a single parameter line from NumPy/Sphinx-style docstring

(line: &str)

Source from the content-addressed store, hash-verified

786
787/// Parse a single parameter line from NumPy/Sphinx-style docstring
788fn parse_numpy_param_line(line: &str) -> Option<(String, String)> {
789 let trimmed = line.trim();
790
791 // Look for pattern: "param_name : type" followed by description on next lines
792 // For simplicity, we'll look for lines that start with a word followed by space and colon
793 if let Some(colon_pos) = trimmed.find(" :") {
794 let param_name = trimmed[..colon_pos].trim();
795 let rest = trimmed[colon_pos + 2..].trim();
796
797 if !param_name.is_empty() {
798 // For NumPy style, description might be on the same line after type
799 let description = if rest.is_empty() {
800 format!("Parameter {}", param_name)
801 } else {
802 rest.to_string()
803 };
804 return Some((param_name.to_string(), description));
805 }
806 }
807
808 None
809}
810
811/// Map Python type annotations to JSON Schema types
812fn map_python_type_to_json_schema(type_str: &str) -> &'static str {

Callers 1

Calls 2

to_stringMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected