fortls icon indicating copy to clipboard operation
fortls copied to clipboard

Doxygen style comments are sometimes picked up in the wrong place

Open plevold opened this issue 2 years ago • 2 comments

Describe the bug Due to the way fortls parses Doxygen style comments they could appear in unexpected places if a developer is not careful about using !> comments.

To Reproduce In the following example:

subroutine sub_before
    integer :: i

    !> Trying to add a docstring to an expression
    i = 1
end subroutine


subroutine sub_no_doc
end subroutine

The comment !> Trying to add a docstring to an expression is added as a docstring to sub_no_doc.

Expected behavior When building the AST, pendic_doc should probably be cleared when something other than subroutine / function / type / module appears.

See also https://github.com/fortran-lang/fortls/issues/212#issuecomment-1299691619

plevold avatar Nov 16 '22 15:11 plevold

Cheers @plevold, so this should be attached to the integer :: i AST node. If placed in the same line as integer :: i then it attaches correctly. I suspect what I need to do is ignore new lines and attached to the previous AST node. Not sure if that will break the existing parser.

gnikit avatar Nov 16 '22 15:11 gnikit

I think that it's not bug. If I change the !> to !< it would work properly. image image

folk85 avatar Jun 18 '23 06:06 folk85