robocorp / robotframework-lsp

Robocorp extensions for VS Code: Robocorp Code and RFW LSP
https://robocorp.com/docs/developer-tools/visual-studio-code
Apache License 2.0
202 stars 91 forks source link

VSC RobotFramework LS not showing code and table mark upon hovering over keyword #697

Closed mtoskamp closed 2 years ago

mtoskamp commented 2 years ago

The issue In the current (0.48.2) and prior versions of the Robot Framework LSP it seems that rfdoc documentation is not working entirely as expected. In below example we can see a part of the documentation that we had written for our Browser extension.

mendixText.rfdoc = `
    Fills the given \`input\` into the corresponding text input element which is found by \`label\`.

    The keyword will wait for the input element, corresponding to \`label\`, to become visible and interactable before filling in the text.
    If the element is not an input element this keyword will fail.

    = Argument information =
    - \`label\`: Label corresponding to the input element.
    - \`input\`: The text to be filled in.
    - \`occurrence\`: If the combination \`label\` and \`input\` is not unique, within the current page, the occurrence can be used to select the needed element. By default occurrence is set to 1, but this can be changed to 2 or greater.
    - \`clear\`: By default every text input will be cleared before filling in the text. If this is not desired clear can be set to _false_ and thus add the text as an addition to the already existing text.

    = Examples =
    == Basic usage ==
    In below example the basic usage is illustrated where user wants to fill in username.
    | =Keyword= | =label= | =input= | =occurrence= | =clear= |
    | Mendix Text | Username | \${username} | _N/A_ | _N/A_ |

As we can see we're making use of code and table mark up, but once we hover over these keywords in VSC none of this is being shown correctly. See below screenshot where red outlined should have been code formatted and green should have been a table:

image

Note that also headers are not functioning entirely correct. Examples should have been a H1.

This issue is also occurring when hovering over Browser library keywords, which could imply that the LSP is currently not capable of handling languages other then Python? See below screenshot for documentation on Browser Click:

image

Preferred solution We want to be able and see the complete and correct documentation upon hovering over custom keywords, regardless of code language it was written in.

Alternatives A possible alternative would be switching to RobotCode extension as it shows documentation correctly. See below screenshot, made with only switching LSP and no other changes:

Schermafbeelding 2022-06-13 om 19 28 48

As we can see in above screenshot the documentation is showing correctly. However the RobotFramework LS is preferred by us and thus we would like to be able and stay with it.

Any other alternatives, except for exporting documentation to HTML so people can view it outside of VSC, were not found.

Contact In case there are any further questions or clarification is needed. I can be found on the Robot Framework slack channel as @mtoskamp

fabioz commented 2 years ago

Sorry for the delay in getting back to you (just back from vacation).

In my initial test I was unable to reproduce.

i.e.:

image

for the given contents:

*** Test Cases ***
Test case 1
    [Teardown]
    Demo2

*** Keyword ***
Demo2
    [Documentation]     Fills the given `input` into the corresponding text input element which is found by `label`.
    ...   The keyword will wait for the input element, corresponding to `label`, to become visible and interactable before filling in the text.
    ...   If the element is not an input element this keyword will fail.
    ...   
    ...   = Argument information =
    ...   - `label`: Label corresponding to the input element.
    ...   - `input`: The text to be filled in.
    ...   - `occurrence`: If the combination `label` and `input` is not unique, within the current page, the occurrence can be used to select the needed element. By default occurrence is set to 1, but this can be changed to 2 or greater.
    ...   - `clear`: By default every text input will be cleared before filling in the text. If this is not desired clear can be set to _false_ and thus add the text as an addition to the already existing text.
    ...   
    ...   = Examples =
    ...   == Basic usage ==
    ...   In below example the basic usage is illustrated where user wants to fill in username.
    ...   | =Keyword= | =label= | =input= | =occurrence= | =clear= |
    ...   | Mendix Text | Username | \${username} | _N/A_ | _N/A_ |

Seems to work.

And as a lib:

image

Given that my_lib.py contents are defined as below:

def method():
    '''
    Fills the given `input` into the corresponding text input element which is found by `label`.

    The keyword will wait for the input element, corresponding to `label`, to become visible and interactable before filling in the text.
    If the element is not an input element this keyword will fail.

    = Argument information =
    - `label`: Label corresponding to the input element.
    - `input`: The text to be filled in.
    - `occurrence`: If the combination `label` and `input` is not unique, within the current page, the occurrence can be used to select the needed element. By default occurrence is set to 1, but this can be changed to 2 or greater.
    - `clear`: By default every text input will be cleared before filling in the text. If this is not desired clear can be set to _false_ and thus add the text as an addition to the already existing text.

    = Examples =
    == Basic usage ==
    In below example the basic usage is illustrated where user wants to fill in username.
    | =Keyword= | =label= | =input= | =occurrence= | =clear= |
    | Mendix Text | Username | \${username} | _N/A_ | _N/A_ |
    '''

it also seems to work.

So, my question is, how exactly are you defining that... Can you provide a sample project where I could reproduce this? I think the problem is that in your particular case it's not detected as being using the robot format (seems like it could be ReST or maybe something else) and it's not using the appropriate format, but as I don't know how exactly that's being defined (since your example doesn't seem to be in Python), it's hard for me to know how to reproduce your use case.

mtoskamp commented 2 years ago

Hi @fabioz,

Sorry for my delay, but just like you I was enjoying some time off.

In your examples you're making use of Robot Framework keyword documentation and Python documentation. However the issue relates to none Python and RF documentation, but JS documentation and possibly other languages.

In my previous comment, the first code block, I showcased documentation that was part of a .js file. The formatting within this document seems to be incomplete within the LSP, but the same seems to be occuring for the Browser library itself.

I would suggest we get in touch so that i can show you how to reproduce this scenario?

Thanks for your time.

fabioz commented 2 years ago

@mtoskamp having an example would definitely be useful here. Can you provide more details on the issue itself on how to reproduce this scenario?

mtoskamp commented 2 years ago

@fabioz I've attached the project as a zip. This zip contains the .js file and corresponding libspec that I was referring to. Mendix extensie.zip

If anymore help is needed please let me know.

fabioz commented 2 years ago

I see that you generate the libspec manually and it's output is actually HTML...

Can you try to generate it with raw format to see if it fixes it for you?

i.e.:

python -m robot.libdoc --format XML --specdocformat RAW Browser::jsextension='<path to .js file>' '<path to libspec folder>'

mtoskamp commented 2 years ago

Adding the --specdocformat RAW did the trick indeed. I had tried multiple options except for this, so I'm glad you suggested it.

I've closed the issue as not planned.

Thanks for your time.