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

Function extract_parameters_section_numpy

python/src/workflow/node.rs:748–785  ·  view source on GitHub ↗

Extract Parameters section from NumPy/Sphinx-style docstring

(docstring: &str)

Source from the content-addressed store, hash-verified

746
747/// Extract Parameters section from NumPy/Sphinx-style docstring
748fn extract_parameters_section_numpy(docstring: &str) -> Option<String> {
749 let lines: Vec<&str> = docstring.lines().collect();
750 let mut in_params_section = false;
751 let mut params_lines = Vec::new();
752
753 for line in lines {
754 let trimmed = line.trim();
755
756 if trimmed == "Parameters"
757 || trimmed == "Parameters:"
758 || trimmed.starts_with("Parameters\n")
759 || trimmed.starts_with("Parameters\r\n")
760 {
761 in_params_section = true;
762 continue;
763 }
764
765 if in_params_section {
766 // Check if we've reached another section
767 if trimmed == "Returns"
768 || trimmed == "Returns:"
769 || trimmed == "Raises"
770 || trimmed == "Raises:"
771 || trimmed == "Examples"
772 || trimmed == "Examples:"
773 {
774 break;
775 }
776 params_lines.push(line);
777 }
778 }
779
780 if params_lines.is_empty() {
781 None
782 } else {
783 Some(params_lines.join("\n"))
784 }
785}
786
787/// Parse a single parameter line from NumPy/Sphinx-style docstring
788fn parse_numpy_param_line(line: &str) -> Option<(String, String)> {

Callers 1

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected