-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add hover info for modules and types including any docstring #212
feat: Add hover info for modules and types including any docstring #212
Conversation
Codecov Report
@@ Coverage Diff @@
## master #212 +/- ##
==========================================
- Coverage 86.03% 85.85% -0.18%
==========================================
Files 12 12
Lines 4439 4461 +22
==========================================
+ Hits 3819 3830 +11
- Misses 620 631 +11
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
eca301d
to
60e0646
Compare
Thanks for the PR and the issue @plevold. I will try and have a look this week and leave a review. 👍 |
The thing that you need to be extra careful is how Doxygen and modified FORD documentation can look very similar.
What do we expect the behaviour of the Document parser to be prefer 1 of the 2 docstrings (and if so why) or concatenate? FYI |
Agree and I see now that my initial issue description was incorrect in that regard. My changes actually doesn't do anything to the docstring parsing itself. The docstrings were already parsed correctly and added to the module and type objects. The only thing I had to add was to return the docstring in hover requests for module and type names. One thing I noticed during my testing is that Doxygen style comments (aka. subroutine sub_before
integer :: i
!> Trying to add a docstring to an expression
i = 1
end subroutine
subroutine sub_no_doc
end subroutine It will actually be added to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a couple of things are needed for this to be merged.
- rebase to master so the Markdown changes are ported
- use f-strings where possible instead of
format()
or"str" + "val"
- add unittests for the uncovered lines
The issue that you noted with Doxygen style comments being added to the wrong scope should also be ideally addressed since it can lead to quite a bit of a nightmare. Might be better if done in a separate PR though.
I will have some time this week after I finish the work with autocopmletions and Markdown to test your version of fortls locally and see if we need to add anything else in the hover signature and/or signature help and completions.
fortls/objects.py
Outdated
def get_hover(self, long=False, include_doc=True, drop_arg=-1): | ||
keywords = "" | ||
if self.abstract: | ||
keywords += ", ABSTRACT" | ||
if self.inherit: | ||
keywords += ", EXTENDS({})".format(self.inherit) | ||
hover = "TYPE{} :: {}".format(keywords, self.name) | ||
if include_doc: | ||
doc_str = self.get_documentation() | ||
if doc_str is not None: | ||
hover += "\n" + doc_str | ||
return hover, long |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use fstrings and consider using a list for keywords.
I think that explicit newline character might not be correct now that Markdown is being used for hover messages.
Also, we need to provide some unit tests for the non-covered lines.
60e0646
to
30c80f1
Compare
Codecov Report
@@ Coverage Diff @@
## master #212 +/- ##
==========================================
- Coverage 86.76% 86.76% -0.01%
==========================================
Files 12 12
Lines 4542 4489 -53
==========================================
- Hits 3941 3895 -46
+ Misses 601 594 -7
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There are some stuff that I need to change, style in fortran code, some changes you made that remove coverage, so if it's okay with you, I will push directly on this branch. |
Sure, no problem |
09a75d8
to
3e63fc1
Compare
3e63fc1
to
87cd3cc
Compare
I have no idea what's going on with the coverage reports in this PR. I have started a new one (#246) with your commit cherry-picked, but edited to undo some of the breaking changes like disabling autoupdating and |
Fixes #208
@gnikit I decided to clone the fortls repo and have a look around. Figured I actually had a shot a making #208 work myself. Here's my suggestion. Feel free to nitpick on potential issues or anything I might have overlooked!