@@ -435,10 +435,29 @@ impl Compiler {
435435 let lines: Vec < & str > = file_str. split ( '\n' ) . collect ( ) ;
436436 let mut last_line = String :: from ( "" ) ;
437437 /* analyse each line */
438+ let mut inside_docstring = false ;
438439 for line in lines. iter ( ) {
439440 let mut line = line. replace ( "\r " , "" ) ;
440- /* replace \t with 4 spaces */
441441 line = line. replace ( "\t " , " " ) ;
442+
443+ // Check for docstring blocks (both single-line and multi-line)
444+ if line. trim ( ) . contains ( "\" \" \" " ) {
445+ let count = line. matches ( "\" \" \" " ) . count ( ) ;
446+ if count == 1 {
447+ // If we encounter just one set of """ and we are not inside a docstring block, start or end the block
448+ inside_docstring = !inside_docstring;
449+ continue ;
450+ } else if count == 2 {
451+ // If there are two sets of """ on the same line, it's a single-line docstring, skip it
452+ continue ;
453+ }
454+ }
455+
456+ // Skip lines inside the docstring block
457+ if inside_docstring {
458+ continue ;
459+ }
460+
442461 if line. contains ( "(" ) && !line. contains ( ")" ) {
443462 last_line = line. clone ( ) ;
444463 continue ;
@@ -452,6 +471,7 @@ impl Compiler {
452471 continue ;
453472 }
454473 }
474+
455475 self = match pkg_type {
456476 PackageType :: CPackageTop | PackageType :: CPackageInner => {
457477 Compiler :: analyse_pyi_line ( self , line. to_string ( ) , & file_name, is_top_c_pkg)
@@ -461,6 +481,7 @@ impl Compiler {
461481 }
462482 } ;
463483 }
484+
464485 return self ;
465486 }
466487
0 commit comments