@@ -41,25 +41,19 @@ pub fn get_parameter_documentation(docstring: &str) -> HashMap<String, String> {
4141 let mut param_docs = HashMap :: new ( ) ;
4242
4343 // Google-style docstrings
44- if let Some ( google_docs) = extract_google_style_params ( docstring) {
45- param_docs. extend ( google_docs) ;
46- }
44+ param_docs. extend ( extract_google_style_params ( docstring) ) ;
4745
4846 // NumPy-style docstrings
49- if let Some ( numpy_docs) = extract_numpy_style_params ( docstring) {
50- param_docs. extend ( numpy_docs) ;
51- }
47+ param_docs. extend ( extract_numpy_style_params ( docstring) ) ;
5248
5349 // reST/Sphinx-style docstrings
54- if let Some ( rest_docs) = extract_rest_style_params ( docstring) {
55- param_docs. extend ( rest_docs) ;
56- }
50+ param_docs. extend ( extract_rest_style_params ( docstring) ) ;
5751
5852 param_docs
5953}
6054
6155/// Extract parameter documentation from Google-style docstrings.
62- fn extract_google_style_params ( docstring : & str ) -> Option < HashMap < String , String > > {
56+ fn extract_google_style_params ( docstring : & str ) -> HashMap < String , String > {
6357 let mut param_docs = HashMap :: new ( ) ;
6458
6559 let mut in_args_section = false ;
@@ -138,11 +132,7 @@ fn extract_google_style_params(docstring: &str) -> Option<HashMap<String, String
138132 param_docs. insert ( param_name, current_doc. trim ( ) . to_string ( ) ) ;
139133 }
140134
141- if param_docs. is_empty ( ) {
142- None
143- } else {
144- Some ( param_docs)
145- }
135+ param_docs
146136}
147137
148138/// Calculate the indentation level of a line (number of leading whitespace characters)
@@ -151,7 +141,7 @@ fn get_indentation_level(line: &str) -> usize {
151141}
152142
153143/// Extract parameter documentation from NumPy-style docstrings.
154- fn extract_numpy_style_params ( docstring : & str ) -> Option < HashMap < String , String > > {
144+ fn extract_numpy_style_params ( docstring : & str ) -> HashMap < String , String > {
155145 let mut param_docs = HashMap :: new ( ) ;
156146
157147 let mut lines = docstring
@@ -314,15 +304,11 @@ fn extract_numpy_style_params(docstring: &str) -> Option<HashMap<String, String>
314304 param_docs. insert ( param_name, current_doc. trim ( ) . to_string ( ) ) ;
315305 }
316306
317- if param_docs. is_empty ( ) {
318- None
319- } else {
320- Some ( param_docs)
321- }
307+ param_docs
322308}
323309
324310/// Extract parameter documentation from reST/Sphinx-style docstrings.
325- fn extract_rest_style_params ( docstring : & str ) -> Option < HashMap < String , String > > {
311+ fn extract_rest_style_params ( docstring : & str ) -> HashMap < String , String > {
326312 let mut param_docs = HashMap :: new ( ) ;
327313
328314 let mut current_param: Option < String > = None ;
@@ -389,11 +375,7 @@ fn extract_rest_style_params(docstring: &str) -> Option<HashMap<String, String>>
389375 param_docs. insert ( param_name, current_doc. trim ( ) . to_string ( ) ) ;
390376 }
391377
392- if param_docs. is_empty ( ) {
393- None
394- } else {
395- Some ( param_docs)
396- }
378+ param_docs
397379}
398380
399381#[ cfg( test) ]
0 commit comments