fortls
fortls copied to clipboard
Doxygen style comments are sometimes picked up in the wrong place
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
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.
I think that it's not bug. If I change the !>
to !<
it would work properly.