@@ -566,24 +566,12 @@ func (s *symbol) FormatDocs(ctx context.Context) string {
566566 var printed bool
567567 for _ , comments := range allComments {
568568 for i := 0 ; i < comments .Len (); i ++ {
569- comment := comments .Index (i ).RawText ()
570-
571569 // The compiler does not currently provide comments without their
572570 // delimited removed, so we have to do this ourselves.
573- if strings .HasPrefix (comment , "//" ) {
574- // NOTE: We do not trim the space here, because indentation is
575- // significant for Markdown code fences, and if every line
576- // starts with a space, Markdown will trim it for us, even off
577- // of code blocks.
578- comment = strings .TrimPrefix (comment , "//" )
579- } else {
580- comment = strings .TrimSuffix (strings .TrimPrefix (comment , "/*" ), "*/" )
581- }
582-
571+ comment := commentToMarkdown (comments .Index (i ).RawText ())
583572 if comment != "" {
584573 printed = true
585574 }
586-
587575 // No need to process Markdown in comment; this Just Works!
588576 fmt .Fprintln (& tooltip , comment )
589577 }
@@ -596,6 +584,41 @@ func (s *symbol) FormatDocs(ctx context.Context) string {
596584 return tooltip .String ()
597585}
598586
587+ // commentToMarkdown processes comment strings and formats them for markdown display.
588+ func commentToMarkdown (comment string ) string {
589+ if strings .HasPrefix (comment , "//" ) {
590+ // NOTE: We do not trim the space here, because indentation is
591+ // significant for Markdown code fences, and if every line
592+ // starts with a space, Markdown will trim it for us, even off
593+ // of code blocks.
594+ return strings .TrimPrefix (comment , "//" )
595+ }
596+
597+ if strings .HasPrefix (comment , "/**" ) && ! strings .HasPrefix (comment , "/**/" ) {
598+ // NOTE: Doxygen-style comments (/** ... */) to Markdown format
599+ // by removing comment delimiters and formatting the content.
600+ //
601+ // Example:
602+ // /**
603+ // * This is a Doxygen comment
604+ // * with multiple lines
605+ // */
606+ comment = strings .TrimSuffix (strings .TrimPrefix (comment , "/**" ), "*/" )
607+
608+ lines := strings .Split (strings .TrimSpace (comment ), "\n " )
609+ for i , line := range lines {
610+ line = strings .TrimSpace (line )
611+ line = strings .TrimPrefix (line , "*" )
612+ lines [i ] = line
613+ }
614+
615+ return strings .Join (lines , "\n " )
616+ }
617+
618+ // Handle standard multi-line comments (/* ... */)
619+ return strings .TrimSuffix (strings .TrimPrefix (comment , "/*" ), "*/" )
620+ }
621+
599622// symbolWalker is an AST walker that generates the symbol table for a file in IndexSymbols().
600623type symbolWalker struct {
601624 file * file
0 commit comments